TejAndrewsACC commited on
Commit
6424df9
·
verified ·
1 Parent(s): 2075ac1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -16,7 +16,7 @@ system_instructions = (
16
  def chat(user_input, history):
17
  global context
18
  if user_input.lower() == "exit":
19
- return history + [{"role": "assistant", "content": "Ending session. Goodbye!"}]
20
 
21
  # Construct the modified input including system instructions and context
22
  modified_input = (
@@ -34,13 +34,13 @@ def chat(user_input, history):
34
  # Update the context with the latest conversation
35
  context += f"User: {user_input}\nAI: {ai_response}\n"
36
 
37
- # Append the AI's response to the conversation history
38
- history.append({"role": "user", "content": user_input})
39
- history.append({"role": "assistant", "content": ai_response})
40
  return history
41
 
42
  # Gradio interface using ChatInterface
43
- interface = gr.ChatInterface(fn=chat)
44
 
45
  # Launch the chatbot
46
  interface.launch()
 
16
  def chat(user_input, history):
17
  global context
18
  if user_input.lower() == "exit":
19
+ return history + [("assistant", "Ending session. Goodbye!")] # Using tuples here to avoid errors
20
 
21
  # Construct the modified input including system instructions and context
22
  modified_input = (
 
34
  # Update the context with the latest conversation
35
  context += f"User: {user_input}\nAI: {ai_response}\n"
36
 
37
+ # Append the AI's response to the conversation history using the correct tuple format
38
+ history.append(("user", user_input))
39
+ history.append(("assistant", ai_response))
40
  return history
41
 
42
  # Gradio interface using ChatInterface
43
+ interface = gr.Interface(fn=chat, inputs=["text", "state"], outputs=["chatbot", "state"])
44
 
45
  # Launch the chatbot
46
  interface.launch()