Spaces:
Building
Building
Update websocket_handler.py
Browse files- websocket_handler.py +11 -7
websocket_handler.py
CHANGED
@@ -305,18 +305,22 @@ async def websocket_endpoint(websocket: WebSocket, session_id: str):
|
|
305 |
|
306 |
# Don't send welcome TTS here - it's already sent by the frontend
|
307 |
log_info(f"π¬ Ready for conversation", session_id=session_id)
|
308 |
-
|
309 |
# Send welcome message from session history
|
310 |
log_info(f"π Checking for welcome message in session history...", session_id=session_id)
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
313 |
|
314 |
# Get the last assistant message (welcome message)
|
315 |
-
for i, msg in enumerate(reversed(
|
316 |
-
log_debug(f"π Message {i}: role={msg
|
317 |
|
318 |
-
if msg
|
319 |
-
welcome_text = msg
|
320 |
log_info(f"π’ Found welcome message: {welcome_text[:50]}...", session_id=session_id)
|
321 |
|
322 |
# Send text first
|
|
|
305 |
|
306 |
# Don't send welcome TTS here - it's already sent by the frontend
|
307 |
log_info(f"π¬ Ready for conversation", session_id=session_id)
|
308 |
+
|
309 |
# Send welcome message from session history
|
310 |
log_info(f"π Checking for welcome message in session history...", session_id=session_id)
|
311 |
+
|
312 |
+
# Session'da chat_history kullanΔ±lΔ±yor
|
313 |
+
chat_history = session.chat_history if hasattr(session, 'chat_history') else []
|
314 |
+
|
315 |
+
if chat_history and len(chat_history) > 0:
|
316 |
+
log_info(f"π Found {len(chat_history)} messages in history", session_id=session_id)
|
317 |
|
318 |
# Get the last assistant message (welcome message)
|
319 |
+
for i, msg in enumerate(reversed(chat_history)):
|
320 |
+
log_debug(f"π Message {i}: role={msg.get('role', 'unknown')}, content_preview={msg.get('content', '')[:50]}...", session_id=session_id)
|
321 |
|
322 |
+
if msg.get('role') == 'assistant':
|
323 |
+
welcome_text = msg.get('content', '')
|
324 |
log_info(f"π’ Found welcome message: {welcome_text[:50]}...", session_id=session_id)
|
325 |
|
326 |
# Send text first
|