Testinggrounds / app.py
sjdata's picture
fixed app.py
29f2930
raw
history blame
No virus
1.13 kB
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()