aeblymt commited on
Commit
c0d9073
·
verified ·
1 Parent(s): c691788

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -48,25 +48,28 @@ Keep your responses **supreme, professional, and focused on high-value business
48
  """
49
 
50
  # ✅ Function to handle chat responses
51
- def chatbot_response(user_input):
 
 
 
52
  try:
53
  response = client.chat.completions.create(
54
  model="gpt-3.5-turbo",
55
  messages=[
56
- {"role": "system", "content": system_prompt},
57
- {"role": "user", "content": user_input}
58
- ]
59
  )
60
  return response.choices[0].message.content.strip()
61
  except Exception as e:
62
  return f"Error: {str(e)}"
63
 
64
- # ✅ Gradio Chat Interface
65
  interface = gr.ChatInterface(
66
  chatbot_response,
67
  title="Eau Claire AI - AI Consulting Chatbot",
68
  theme="default",
69
  description="Ask me about AI automation, workflows, and consulting.",
 
70
  )
71
 
72
  # ✅ Launch the Gradio Chatbot
 
48
  """
49
 
50
  # ✅ Function to handle chat responses
51
+ def chatbot_response(messages):
52
+ """
53
+ Handles messages in OpenAI's format: [{"role": "user", "content": "Hello"}]
54
+ """
55
  try:
56
  response = client.chat.completions.create(
57
  model="gpt-3.5-turbo",
58
  messages=[
59
+ {"role": "system", "content": system_prompt}
60
+ ] + messages
 
61
  )
62
  return response.choices[0].message.content.strip()
63
  except Exception as e:
64
  return f"Error: {str(e)}"
65
 
66
+ # ✅ Updated Gradio Chat Interface (Fix for deprecated tuples format)
67
  interface = gr.ChatInterface(
68
  chatbot_response,
69
  title="Eau Claire AI - AI Consulting Chatbot",
70
  theme="default",
71
  description="Ask me about AI automation, workflows, and consulting.",
72
+ type="messages" # ✅ Fixes the "tuples format is deprecated" issue
73
  )
74
 
75
  # ✅ Launch the Gradio Chatbot