Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,22 @@ import gradio as gr
|
|
2 |
import time
|
3 |
import Content as con
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
time.sleep(0.03)
|
10 |
-
yield answer[:i+1]
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
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)
|