Spaces:
Runtime error
Runtime error
Fixed application file
Browse files
app.py
CHANGED
|
@@ -1,10 +1,27 @@
|
|
| 1 |
-
import random
|
| 2 |
import gradio as gr
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
return f"Yes, I do think that '{message}'"
|
| 7 |
-
else:
|
| 8 |
-
return "I don't think so"
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import hf_hub_download
|
| 3 |
+
from llama_cpp import Llama
|
| 4 |
|
| 5 |
+
hf_hub_download(repo_id="LLukas22/gpt4all-lora-quantized-ggjt", filename="ggjt-model.bin", local_dir=".")
|
| 6 |
+
llm = Llama(model_path="./ggjt-model.bin")
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
fixed_instruction = "You are a healthcare bot designed to give advice for the prevention and treatment of various illnesses."
|
| 9 |
+
|
| 10 |
+
def respond(message):
|
| 11 |
+
full_instruction = fixed_instruction + " " + message
|
| 12 |
+
bot_message = llm(full_instruction, stop=['### Instruction:', '### End'])
|
| 13 |
+
bot_message = bot_message['choices'][0]['text']
|
| 14 |
+
return bot_message
|
| 15 |
+
|
| 16 |
+
gr.ChatInterface(
|
| 17 |
+
fn=respond,
|
| 18 |
+
chatbot=gr.Chatbot(height=300),
|
| 19 |
+
textbox=gr.Textbox(placeholder="Ask me a question"),
|
| 20 |
+
title="Healthcare Bot",
|
| 21 |
+
description="Ask the Healthcare Bot any question",
|
| 22 |
+
examples = [
|
| 23 |
+
"Give me treatements for heart disease",
|
| 24 |
+
"I hate excercise, what else can I do to treat my high blood pressure",
|
| 25 |
+
"How can I avoid lung disease",
|
| 26 |
+
],
|
| 27 |
+
).launch()
|