rumaisa1054 commited on
Commit
c05ab08
·
verified ·
1 Parent(s): 5d137a6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from responser import res
3
+ # Initialize chat history
4
+ chat_history = []
5
+
6
+
7
+ def reset_chat():
8
+ global chat_history
9
+ chat_history = []
10
+ return chat_history
11
+
12
+ # Create Gradio interface
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# Doctor Chatbot")
15
+
16
+ # Chat history display
17
+ chatbox = gr.Chatbox(label="Chat History", elem_id="chatbox").style(height=400)
18
+
19
+ # User input
20
+ user_input = gr.Textbox(placeholder="Welcome - How can I help you?", label="Your Message")
21
+
22
+ # Submit button
23
+ submit_btn = gr.Button("Send")
24
+
25
+ # Reset button
26
+ reset_btn = gr.Button("Reset Chat")
27
+
28
+ # Define submission action
29
+ def submit_message(input_text):
30
+ if input_text:
31
+ chat_history = res(input_text)
32
+ return chat_history
33
+
34
+ # Bind actions
35
+ submit_btn.click(submit_message, user_input, chatbox)
36
+ reset_btn.click(reset_chat, None, chatbox)
37
+
38
+ # Launch the Gradio app
39
+ demo.launch()