File size: 920 Bytes
c05ab08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1557f
c05ab08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2875a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
from responser import res
# Initialize chat history
chat_history = []


def reset_chat():
    global chat_history
    chat_history = []
    return chat_history

# Create Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("# Doctor Chatbot")
    
    # Chat history display
    chatbox = gr.Chatbot(label="Chat History")
    
    # User input
    user_input = gr.Textbox(placeholder="Welcome - How can I help you?", label="Your Message")
    
    # Submit button
    submit_btn = gr.Button("Send")
    
    # Reset button
    reset_btn = gr.Button("Reset Chat")

    # Define submission action
    def submit_message(input_text):
        if input_text:
            chat_history = res(input_text)
            return chat_history

    # Bind actions
    submit_btn.click(submit_message, user_input, chatbox)
    reset_btn.click(reset_chat, None, chatbox)

# Launch the Gradio app
demo.launch()