DevXign commited on
Commit
ba20081
·
verified ·
1 Parent(s): 9b60009

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +6 -4
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🌿
4
  colorFrom: green
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.44.1
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 list of lists format
91
- history.append([message, response.text])
 
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([message, f"❌ Error: {str(e)}"])
 
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
- gradio==4.44.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