SanaAdeel commited on
Commit
3f47c6e
·
verified ·
1 Parent(s): a201e77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -69,15 +69,16 @@ def respond(
69
  connected, paywall_msg = check_paywall(user_id)
70
 
71
  if not connected:
72
- # When user is not connected, return empty history and paywall message string
73
- return [], paywall_msg
 
 
74
 
75
- # If connected, get chatbot reply
76
  reply_text = chat_completion(user_id, system_message, history, message, max_tokens, temperature, top_p)
77
-
78
- # Append new exchange to history
79
  new_history = history + [{"role": "user", "content": message}, {"role": "assistant", "content": reply_text}]
80
- return new_history, "" # second return clears the input box
 
81
 
82
  # Gradio UI setup with additional inputs
83
  chatbot = gr.ChatInterface(
 
69
  connected, paywall_msg = check_paywall(user_id)
70
 
71
  if not connected:
72
+ # Append paywall message as assistant role message
73
+ new_history = history + [{"role": "assistant", "content": paywall_msg}]
74
+ # Return updated chat history twice to satisfy Gradio's expected tuple of lists
75
+ return new_history, new_history
76
 
77
+ # User connected - get chatbot reply
78
  reply_text = chat_completion(user_id, system_message, history, message, max_tokens, temperature, top_p)
 
 
79
  new_history = history + [{"role": "user", "content": message}, {"role": "assistant", "content": reply_text}]
80
+ return new_history, new_history # Return two lists of messages as required
81
+
82
 
83
  # Gradio UI setup with additional inputs
84
  chatbot = gr.ChatInterface(