Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- README.md +1 -1
- app.py +6 -4
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🌿
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.8.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
app.py
CHANGED
|
@@ -87,14 +87,16 @@ def chat_with_ai(message, history):
|
|
| 87 |
|
| 88 |
response = chat.send_message(message)
|
| 89 |
|
| 90 |
-
# Append new message and response to history in
|
| 91 |
-
history.append(
|
|
|
|
| 92 |
|
| 93 |
return history, "" # Return updated history and empty string to clear input
|
| 94 |
except Exception as e:
|
| 95 |
if history is None:
|
| 96 |
history = []
|
| 97 |
-
history.append(
|
|
|
|
| 98 |
return history, ""
|
| 99 |
|
| 100 |
# Create Gradio Interface
|
|
@@ -132,7 +134,7 @@ with gr.Blocks(title="AyurVedik AI", theme=gr.themes.Soft()) as demo:
|
|
| 132 |
|
| 133 |
with gr.Tab("💬 Chat with AI"):
|
| 134 |
gr.Markdown("### Ask me anything about medicinal plants and Ayurveda!")
|
| 135 |
-
chatbot = gr.Chatbot(height=400)
|
| 136 |
msg = gr.Textbox(label="Your Question", placeholder="Ask about medicinal plants, Ayurveda, health benefits...")
|
| 137 |
|
| 138 |
msg.submit(chat_with_ai, [msg, chatbot], [chatbot, msg])
|
|
|
|
| 87 |
|
| 88 |
response = chat.send_message(message)
|
| 89 |
|
| 90 |
+
# Append new message and response to history in 'messages' format
|
| 91 |
+
history.append({"role": "user", "content": message})
|
| 92 |
+
history.append({"role": "assistant", "content": response.text})
|
| 93 |
|
| 94 |
return history, "" # Return updated history and empty string to clear input
|
| 95 |
except Exception as e:
|
| 96 |
if history is None:
|
| 97 |
history = []
|
| 98 |
+
history.append({"role": "user", "content": message})
|
| 99 |
+
history.append({"role": "assistant", "content": f"❌ Error: {str(e)}"})
|
| 100 |
return history, ""
|
| 101 |
|
| 102 |
# Create Gradio Interface
|
|
|
|
| 134 |
|
| 135 |
with gr.Tab("💬 Chat with AI"):
|
| 136 |
gr.Markdown("### Ask me anything about medicinal plants and Ayurveda!")
|
| 137 |
+
chatbot = gr.Chatbot(height=400, type="messages")
|
| 138 |
msg = gr.Textbox(label="Your Question", placeholder="Ask about medicinal plants, Ayurveda, health benefits...")
|
| 139 |
|
| 140 |
msg.submit(chat_with_ai, [msg, chatbot], [chatbot, msg])
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 3 |
torch==2.6.0+cpu
|
| 4 |
Pillow
|
|
|
|
| 1 |
+
pydantic>=2.0
|
| 2 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 3 |
torch==2.6.0+cpu
|
| 4 |
Pillow
|