Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load the tokenizer and model
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("mailboxlab11/llama-3-medicalassistant")
|
6 |
+
model = AutoModelForCausalLM.from_pretrained("mailboxlab11/llama-3-medicalassistant")
|
7 |
+
|
8 |
+
def generate(prompt):
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
13 |
+
|
14 |
+
# Create the Gradio interface
|
15 |
+
iface = gr.Interface(fn=generate, inputs="text", outputs="text", title="Medical Assistant", description="Ask me any medical question.")
|
16 |
+
|
17 |
+
# Launch the Gradio interface
|
18 |
+
iface.launch()
|