Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,23 @@ import gradio as gr
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
# Load BioGPT model
|
| 5 |
-
bio_gpt = pipeline("text-generation", model="microsoft/biogpt")
|
| 6 |
|
| 7 |
def medical_chatbot(query):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Create Gradio interface
|
| 12 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
iface.launch()
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
# Load BioGPT model
|
| 5 |
+
bio_gpt = pipeline("text-generation", model="microsoft/biogpt-large")
|
| 6 |
|
| 7 |
def medical_chatbot(query):
|
| 8 |
+
# Generate text using BioGPT
|
| 9 |
+
result = bio_gpt(query, max_length=100, num_return_sequences=1)
|
| 10 |
+
|
| 11 |
+
# Extract only the generated text from response
|
| 12 |
+
generated_text = result[0]["generated_text"]
|
| 13 |
+
|
| 14 |
+
return generated_text
|
| 15 |
|
| 16 |
# Create Gradio interface
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
fn=medical_chatbot,
|
| 19 |
+
inputs=gr.Textbox(placeholder="Ask me a medical question..."),
|
| 20 |
+
outputs="text",
|
| 21 |
+
title="Medical Chatbot"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
iface.launch()
|