Spaces:
Runtime error
Runtime error
fixed app.py
Browse files- .app.py.swp +0 -0
- 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 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
gr.ChatInterface(
|
21 |
-
fn=
|
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 |
-
|
28 |
-
|
29 |
-
|
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 |
+
|