Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Define the conversation flow with predefined questions and answers
4
+ conversation_flow = {
5
+ "hello": "Hi there! How can I help you?",
6
+ "ocular disease": "I'm just a computer program, but I'm doing fine. How about you?",
7
+ "bye": "Goodbye! Take care!",
8
+ "default": "I'm not sure how to respond to that. Can you ask me something else?"
9
+ }
10
+
11
+ # Define the chatbot function using the predefined conversation flow
12
+ def custom_chatbot(input_text):
13
+ # Check if the input text matches predefined questions
14
+ if input_text.lower() in conversation_flow:
15
+ response = conversation_flow[input_text.lower()]
16
+ else:
17
+ # If the input doesn't match, use the default response
18
+ response = conversation_flow["default"]
19
+
20
+ return response
21
+
22
+ # Create a Gradio interface for the chatbot with predefined questions and answers
23
+ chatbot_interface = gr.Interface(fn=custom_chatbot, inputs="text", outputs="text", title="Custom Chatbot")
24
+ chatbot_interface.launch()