File size: 1,131 Bytes
7a5420b
7617af6
22fe0e9
067b4cd
29f2930
 
 
22fe0e9
8d9cdc9
067b4cd
 
 
 
 
29f2930
20c5a04
29f2930
 
 
 
 
 
 
7617af6
29f2930
7617af6
 
 
 
 
29f2930
 
 
 
7617af6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from huggingface_hub import hf_hub_download

hf_hub_download(repo_id="LLukas22/gpt4all-lora-quantized-ggjt", filename="ggjt-model.bin", local_dir=".")

from llama_cpp import Llama

llm = Llama(model_path="./ggjt-model.bin")

ins = '''### Instruction:
{}
### Response:
'''

fixed_instruction = "You are a healthcare bot designed to give advice for the prevention and treatment of various illnesses."

def respond(message, chat_history):
    full_instruction = fixed_instruction + " " + message
    formatted_instruction = ins.format(full_instruction)
    bot_message = llm(formatted_instruction, stop=['### Instruction:', '### End'])
    bot_message = bot_message['choices'][0]['text']
    return bot_message
    
gr.ChatInterface(
    fn=respond,
    chatbot=gr.Chatbot(height=300),
    textbox=gr.Textbox(placeholder="Ask me a question"),
    title="Healthcare Bot",
    description="Ask the Healthcare Bot any question",
    examples = [
    "Give me treatements for heart disease",
    "I hate excercise, what else can I do to treat my high blood pressure",
    "How can I avoid lung disease",
],
).launch()