hpratapsingh commited on
Commit
10ebf33
·
verified ·
1 Parent(s): 2d497be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -2,13 +2,22 @@ import gradio as gr
2
  import time
3
  import Content as con
4
 
 
 
 
 
 
5
 
6
- def random_response(message,history):
7
- answer = con.starting(message.lower())
8
- for i in range(len(answer)):
9
- time.sleep(0.03)
10
- yield answer[:i+1]
11
 
 
 
 
12
 
13
- demo = gr.ChatInterface(random_response, title= "Prakriti Analyzer", description='This bot is made with love and care to guide you towards a better life by giving you a knowlege about your prakriti or your body costitution.',).queue()
14
- demo.launch(inbrowser=True)
 
 
 
 
2
  import time
3
  import Content as con
4
 
5
+ # Function to handle the chat response (without generator-based typing effect for simplicity)
6
+ def random_response(message, history):
7
+ answer = con.starting(message.lower()) # Get response from Content.py
8
+ history.append((message, answer)) # Append user message and bot's answer to history
9
+ return history
10
 
11
+ # Create the Gradio Chatbot interface
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("<h1>Prakriti Analyzer</h1><p>This bot helps you understand your body constitution using Ayurveda principles.</p>")
 
 
14
 
15
+ chatbot = gr.Chatbot() # Chatbot component to display conversation
16
+ msg = gr.Textbox(placeholder="Enter your message here...") # Input textbox
17
+ submit = gr.Button("Send") # Button to submit the message
18
 
19
+ # Link the submit button to the random_response function
20
+ submit.click(random_response, inputs=[msg, chatbot], outputs=chatbot)
21
+
22
+ # Launch the interface
23
+ demo.launch(inbrowser=True)