Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
|
4 |
+
# Load the model
|
5 |
+
llm = Llama.from_pretrained(
|
6 |
+
repo_id="thviet79/model-QA-medical-2024",
|
7 |
+
filename="models-7B-F16.gguf"
|
8 |
+
)
|
9 |
+
|
10 |
+
# Define the function to interact with the model
|
11 |
+
def chat_with_model(user_input):
|
12 |
+
response = llm.create_chat_completion(
|
13 |
+
messages=[
|
14 |
+
{"role": "user", "content": user_input}
|
15 |
+
]
|
16 |
+
)
|
17 |
+
return response['choices'][0]['message']['content']
|
18 |
+
|
19 |
+
# Create the Gradio interface
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=chat_with_model,
|
22 |
+
inputs="text",
|
23 |
+
outputs="text",
|
24 |
+
title="Llama Model Chatbot",
|
25 |
+
description="Ask the model any question!"
|
26 |
+
)
|
27 |
+
|
28 |
+
# Launch the interface
|
29 |
+
if __name__ == "__main__":
|
30 |
+
iface.launch()
|