TejAndrewsACC commited on
Commit
a704f51
·
verified ·
1 Parent(s): 05cf037

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -32,9 +32,8 @@ def chat_function(message, history):
32
  # Update the context with the latest conversation
33
  context += f"User: {message}\nAI: {response}\n"
34
 
35
- # Append to history for Gradio UI
36
- history.append({"role": "user", "content": message})
37
- history.append({"role": "assistant", "content": response})
38
 
39
  return response, history
40
 
@@ -44,7 +43,7 @@ def chat_function(message, history):
44
  # Set up Gradio UI
45
  with gr.Blocks() as demo:
46
  chatbot = gr.Chatbot()
47
- msg = gr.Textbox(placeholder="Type Something...")
48
  clear = gr.ClearButton([msg, chatbot])
49
 
50
  msg.submit(chat_function, [msg, chatbot], [msg, chatbot])
 
32
  # Update the context with the latest conversation
33
  context += f"User: {message}\nAI: {response}\n"
34
 
35
+ # Append to history for Gradio UI (in the correct format: a list of tuples)
36
+ history.append((message, response))
 
37
 
38
  return response, history
39
 
 
43
  # Set up Gradio UI
44
  with gr.Blocks() as demo:
45
  chatbot = gr.Chatbot()
46
+ msg = gr.Textbox(placeholder="Ask something...")
47
  clear = gr.ClearButton([msg, chatbot])
48
 
49
  msg.submit(chat_function, [msg, chatbot], [msg, chatbot])