Roy2003 commited on
Commit
ffc424d
1 Parent(s): 7e82d99

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+ import pandas as pd
4
+
5
+ df=pd.read_csv('healifyLLM_answer_dataset.csv')
6
+
7
+ with open('question_labels.json', 'r') as f:
8
+ questions_label = json.load(f)
9
+ que_classes = list(questions_label.keys())
10
+
11
+ def answering(text):
12
+ percentage = learner_inf.blurr_predict(text)[0]['score']* 100
13
+ index = learner_inf.blurr_predict(text)[0]['class_index']
14
+ label = learner_inf.blurr_predict(text)[0]['class_labels'][index]
15
+ result = df_answer[df_answer['label'] == label]['answer']
16
+ if percentage >= 35:
17
+ return result.iloc[0]
18
+ else:
19
+ return "My knowledge is limited. Ask some other medical question."
20
+
21
+ label = gr.components.Label(label="Answer")
22
+ iface = gr.Interface(fn=answering,inputs="text", outputs=label2, title="Disease QnA")
23
+ iface.launch(inline=False)
24
+
25
+