BINAII commited on
Commit
8e31d41
·
verified ·
1 Parent(s): d0ee8c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -1,9 +1,16 @@
1
- import json
 
2
 
3
- # Load the dataset (update 'your_file_path.json' with the actual file location)
4
- file_path = "https://huggingface.co/spaces/BINAII/Mini_Medical_Assistant/blob/main/release_conditions.json"
5
- with open(file_path, "r") as file:
6
- data = json.load(file)
7
 
8
- # Display a sample record
9
- print(data[0]) # Print the first patient record
 
 
 
 
 
 
 
 
 
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)