Commit
·
10178ba
1
Parent(s):
e66ed0d
fix moderation
Browse files
app.py
CHANGED
|
@@ -235,6 +235,17 @@ def send_message(channel: str, username: str, message: str):
|
|
| 235 |
chatbot_formatted = format_history_for_chatbot_display(current_history)
|
| 236 |
return current_history, roundtable_json, chatbot_formatted, roundtable_json, ""
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
user_msg = {"role": "user", "username": username, "content": message}
|
| 239 |
with history_lock:
|
| 240 |
chat_histories[channel].append(user_msg)
|
|
|
|
| 235 |
chatbot_formatted = format_history_for_chatbot_display(current_history)
|
| 236 |
return current_history, roundtable_json, chatbot_formatted, roundtable_json, ""
|
| 237 |
|
| 238 |
+
moderation_result = moderate_with_llm(message)
|
| 239 |
+
if moderation_result:
|
| 240 |
+
with history_lock:
|
| 241 |
+
system_msg = {"role": "system_error", "content": moderation_result}
|
| 242 |
+
chat_histories[channel].append(system_msg)
|
| 243 |
+
final_history = chat_histories.get(channel, [])
|
| 244 |
+
final_roundtable_json = json.dumps(roundtable_states.get(channel, {}))
|
| 245 |
+
|
| 246 |
+
final_chatbot_formatted = format_history_for_chatbot_display(final_history)
|
| 247 |
+
return final_history, final_roundtable_json, final_chatbot_formatted, final_roundtable_json, ""
|
| 248 |
+
|
| 249 |
user_msg = {"role": "user", "username": username, "content": message}
|
| 250 |
with history_lock:
|
| 251 |
chat_histories[channel].append(user_msg)
|