Update app.py
Browse files
app.py
CHANGED
@@ -67,10 +67,11 @@ def AIPatient(message):
|
|
67 |
response = ""
|
68 |
# Here, you should add the code to generate the response using your model
|
69 |
# For example:
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
74 |
|
75 |
context += response
|
76 |
print (context)
|
@@ -78,27 +79,19 @@ def AIPatient(message):
|
|
78 |
history.append((message,response))
|
79 |
return history
|
80 |
|
81 |
-
with gr.Blocks() as demo:
|
82 |
-
gr.HTML("""<h1 align="center">So Rude</h1>""")
|
83 |
-
|
84 |
-
chatbot = gr.Chatbot()
|
85 |
-
with gr.Row():
|
86 |
-
with gr.Column(scale=4):
|
87 |
-
user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=8, elem_id="user_input")
|
88 |
-
submitBtn = gr.Button("Submit", variant="primary", elem_id="submit_btn")
|
89 |
-
with gr.Column(scale=1):
|
90 |
-
max_length = gr.Slider(0, 256, value=64, step=1.0, label="Maximum Length", interactive=True)
|
91 |
-
top_p = gr.Slider(0, 1, value=0.7, step=0.01, label="Top P", interactive=True)
|
92 |
-
temperature = gr.Slider(0, 2.0, value=0.95, step=0.01, label="Temperature", interactive=True)
|
93 |
-
emptyBtn = gr.Button("Clear History")
|
94 |
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
submitBtn.click(
|
98 |
-
predict, [user_input, chatbot, max_length, top_p, temperature, history], [chatbot, history], show_progress=True
|
99 |
-
)
|
100 |
-
submitBtn.click(reset_user_input, [], [user_input])
|
101 |
|
102 |
-
|
103 |
|
104 |
-
demo.
|
|
|
67 |
response = ""
|
68 |
# Here, you should add the code to generate the response using your model
|
69 |
# For example:
|
70 |
+
while(len(response) < 1):
|
71 |
+
print("here")
|
72 |
+
output = llm(context, max_tokens=400, stop=["Nurse:"], echo=False)
|
73 |
+
response = output["choices"][0]["text"]
|
74 |
+
response = response.strip()
|
75 |
|
76 |
context += response
|
77 |
print (context)
|
|
|
79 |
history.append((message,response))
|
80 |
return history
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
with gr.Blocks() as demo:
|
84 |
+
gr.Markdown("# AI Patient Chatbot")
|
85 |
+
with gr.Group():
|
86 |
+
with gr.Tab("Patient Chatbot"):
|
87 |
+
chatbot = gr.Chatbot()
|
88 |
+
message = gr.Textbox(label="Enter your message to Barry", placeholder="Type here...", lines=2)
|
89 |
+
send_message = gr.Button("Submit")
|
90 |
+
send_message.click(AIPatient, inputs=[message], outputs=[chatbot])
|
91 |
+
save_chatlog = gr.Button("Save Chatlog")
|
92 |
+
#send_message.click(SaveChatlog, inputs=[message], outputs=[chatbot])
|
93 |
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
#message.submit(AIPatient, inputs=[message], outputs=[chatbot])
|
96 |
|
97 |
+
demo.launch(debug=True,share=False,inbrowser=True)
|