sjdata commited on
Commit
067b4cd
1 Parent(s): 20c5a04

fixed app.py

Browse files
Files changed (2) hide show
  1. .app.py.swp +0 -0
  2. app.py +26 -17
.app.py.swp DELETED
Binary file (12.3 kB)
 
app.py CHANGED
@@ -1,31 +1,40 @@
1
  import gradio as gr
2
  from huggingface_hub import hf_hub_download
3
-
4
- hf_hub_download(repo_id="LLukas22/gpt4all-lora-quantized-ggjt", filename="ggjt-model.bin", local_dir=".")
5
-
6
  from llama_cpp import Llama
7
 
 
8
  llm = Llama(model_path="./ggjt-model.bin")
9
 
10
-
11
- fixed_instruction = "You are a healthcare bot designed to give advice for the prevention and treatment of various illnesses."
12
-
13
- def respond(message, chat_history):
14
- full_instruction = fixed_instruction + " " + message
15
- bot_message = llm(full_instruction, stop=['### Instruction:', '### End'])
16
- bot_message = bot_message['choices'][0]['text']
17
- return bot_message
18
-
 
 
 
 
 
 
 
 
 
19
 
20
  gr.ChatInterface(
21
- fn=respond,
22
  chatbot=gr.Chatbot(height=300),
23
  textbox=gr.Textbox(placeholder="Ask me a question"),
24
  title="Healthcare Bot",
25
  description="Ask the Healthcare Bot any question",
26
  examples = [
27
- "Give me treatements for heart disease",
28
- "I hate excercise, what else can I do to treat my high blood pressure",
29
- "How can I avoid lung disease",
30
- ],
 
31
  ).launch()
 
 
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
+ ins = '''### Instruction:
9
+ {}
10
+ ### Response:
11
+ '''
12
+
13
+ theme = gr.themes.Monochrome(
14
+ primary_hue="indigo",
15
+ secondary_hue="blue",
16
+ neutral_hue="slate",
17
+ radius_size=gr.themes.sizes.radius_sm,
18
+ font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
19
+ )
20
+
21
+ def generate(instruction):
22
+ result = ""
23
+ for x in llm(ins.format(instruction), stop=['### Instruction:', '### End'], stream=True):
24
+ result += x['choices'][0]['text']
25
+ yield result
26
 
27
  gr.ChatInterface(
28
+ fn=generate,
29
  chatbot=gr.Chatbot(height=300),
30
  textbox=gr.Textbox(placeholder="Ask me a question"),
31
  title="Healthcare Bot",
32
  description="Ask the Healthcare Bot any question",
33
  examples = [
34
+ "Give me treatments for heart disease",
35
+ "I hate exercise, what else can I do to treat my high blood pressure",
36
+ "How can I avoid lung disease",
37
+ ],
38
+ theme=theme,
39
  ).launch()
40
+