Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,16 @@
|
|
1 |
-
import
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
with open(file_path, "r") as file:
|
6 |
-
data = json.load(file)
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
model_name = "emilyalsentzer/Bio_ClinicalBERT"
|
5 |
+
nlp_pipeline = pipeline("fill-mask", model=model_name)
|
|
|
|
|
6 |
|
7 |
+
def medical_chatbot(user_input):
|
8 |
+
if "[MASK]" not in user_input:
|
9 |
+
user_input += " [MASK]"
|
10 |
+
|
11 |
+
response = nlp_pipeline(user_input)
|
12 |
+
return {"prediction": response[0]["sequence"], "confidence": response[0]["score"]}
|
13 |
+
|
14 |
+
# Create an API interface
|
15 |
+
interface = gr.Interface(fn=medical_chatbot, inputs="text", outputs="json")
|
16 |
+
interface.launch(share=True)
|