Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,15 +69,16 @@ def respond(
|
|
| 69 |
connected, paywall_msg = check_paywall(user_id)
|
| 70 |
|
| 71 |
if not connected:
|
| 72 |
-
#
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
#
|
| 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,
|
|
|
|
| 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(
|