arpit13 commited on
Commit
694df17
·
verified ·
1 Parent(s): 8274289

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -58,7 +58,11 @@ def get_groq_response(message, category):
58
  # Chatbot function
59
  def chatbot(user_input, category, history=[]):
60
  bot_response = get_groq_response(user_input, category)
61
- history.append((f"You: {user_input}", f"Bot: {bot_response}"))
 
 
 
 
62
  return history, history
63
 
64
  # Categories grouped into main and subcategories
@@ -184,7 +188,7 @@ header {
184
  send_button = gr.Button("Send")
185
 
186
  with gr.Row():
187
- chatbot_output = gr.Chatbot(label="Chat History", type="messages")
188
 
189
  def handle_chat(user_input, sub_category, history):
190
  if not user_input.strip():
 
58
  # Chatbot function
59
  def chatbot(user_input, category, history=[]):
60
  bot_response = get_groq_response(user_input, category)
61
+
62
+ # Format messages to comply with 'messages' format
63
+ history.append({"role": "user", "content": user_input})
64
+ history.append({"role": "assistant", "content": bot_response})
65
+
66
  return history, history
67
 
68
  # Categories grouped into main and subcategories
 
188
  send_button = gr.Button("Send")
189
 
190
  with gr.Row():
191
+ chatbot_output = gr.Chatbot(label="Chat History", type="messages", elem_id="chat-container")
192
 
193
  def handle_chat(user_input, sub_category, history):
194
  if not user_input.strip():