Update app.py
Browse files
app.py
CHANGED
|
@@ -46,47 +46,50 @@ sys = "You are a general family physician. Your mission is to figure out the dia
|
|
| 46 |
end_sys_prompts = "\n\ngive correct treatment and most related diagnosis with ICD code don't ask any questions. if question is not related to provided data don't give answer from this provided data's"
|
| 47 |
|
| 48 |
|
| 49 |
-
# Initialize Gradio interface
|
| 50 |
with gr.Blocks() as demo:
|
| 51 |
chatbot = gr.Chatbot()
|
| 52 |
-
|
| 53 |
-
# Replace the text input with audio input
|
| 54 |
audio_input = gr.Audio(label="Voice Input")
|
| 55 |
-
|
| 56 |
-
response_text = gr.Textbox(label="Response")
|
| 57 |
-
|
| 58 |
clear = gr.Button("Clear.")
|
| 59 |
def clear_textbox():
|
| 60 |
-
global chain,
|
| 61 |
-
chain = ""
|
| 62 |
id = 0
|
| 63 |
clear.click(clear_textbox)
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
message
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
if id < len(medical_questionnaire):
|
| 76 |
-
if id == 0:
|
| 77 |
-
chain = chain + sys + "\n\n" + message + "\n\n" + medical_questionnaire[id] + "\n"
|
| 78 |
-
response_text = message + "\n\n" + medical_questionnaire[id]
|
| 79 |
-
id = id + 1
|
| 80 |
else:
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 84 |
else:
|
| 85 |
-
chain = chain
|
| 86 |
-
diagnosis_and_treatment = "
|
| 87 |
diagnosis_and_treatment = str(diagnosis_and_treatment)
|
| 88 |
-
chain = chain + "\n\ntreatment & diagnosis with ICD code below\n" + diagnosis_and_treatment
|
| 89 |
-
response_text = diagnosis_and_treatment
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
end_sys_prompts = "\n\ngive correct treatment and most related diagnosis with ICD code don't ask any questions. if question is not related to provided data don't give answer from this provided data's"
|
| 47 |
|
| 48 |
|
|
|
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
chatbot = gr.Chatbot()
|
| 51 |
+
msg = gr.Textbox(label="User Input:")
|
|
|
|
| 52 |
audio_input = gr.Audio(label="Voice Input")
|
|
|
|
|
|
|
|
|
|
| 53 |
clear = gr.Button("Clear.")
|
| 54 |
def clear_textbox():
|
| 55 |
+
global chain,id
|
| 56 |
+
chain = ""
|
| 57 |
id = 0
|
| 58 |
clear.click(clear_textbox)
|
| 59 |
|
| 60 |
+
|
| 61 |
+
def respond(audio,message, chat_history):
|
| 62 |
+
global chain,id
|
| 63 |
+
if id<len(medical_questionnaire):
|
| 64 |
+
if id==0:
|
| 65 |
+
chain = chain + sys +"\n\n"+message+"\n\n"+medical_questionnaire[id]+"\n"
|
| 66 |
+
chat_history.append((message,medical_questionnaire[id]))
|
| 67 |
+
id=id+1
|
| 68 |
+
return "", chat_history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
else:
|
| 70 |
+
|
| 71 |
+
chain = chain + message+"\n\n"+medical_questionnaire[id]+"\n"
|
| 72 |
+
chat_history.append((message, medical_questionnaire[id]))
|
| 73 |
+
id=id+1
|
| 74 |
+
return "", chat_history
|
| 75 |
+
|
| 76 |
else:
|
| 77 |
+
chain = chain+message+end_sys_prompts
|
| 78 |
+
diagnosis_and_treatment = "tretment"
|
| 79 |
diagnosis_and_treatment = str(diagnosis_and_treatment)
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
chain = chain+"\n\ntreatment & diagnosis with ICD code below\n"+diagnosis_and_treatment
|
| 82 |
+
print(chain)
|
| 83 |
+
print(id)
|
| 84 |
+
|
| 85 |
+
report = "report"
|
| 86 |
+
report = str(report)
|
| 87 |
+
chat_history.append((message,report.replace("\n","<br>")))
|
| 88 |
+
|
| 89 |
+
return "", chat_history
|
| 90 |
+
|
| 91 |
+
msg.submit(respond, [audio_input,msg, chatbot], [audio_input,msg, chatbot])
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
demo.launch()
|