ciyidogan commited on
Commit
cd2cafa
Β·
verified Β·
1 Parent(s): e0dea2b

Update websocket_handler.py

Browse files
Files changed (1) hide show
  1. 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
- if session.messages and len(session.messages) > 0:
312
- log_info(f"πŸ“‹ Found {len(session.messages)} messages in history", session_id=session_id)
 
 
 
 
313
 
314
  # Get the last assistant message (welcome message)
315
- for i, msg in enumerate(reversed(session.messages)):
316
- log_debug(f"πŸ“‹ Message {i}: role={msg['role']}, content_preview={msg['content'][:50]}...", session_id=session_id)
317
 
318
- if msg['role'] == 'assistant':
319
- welcome_text = msg['content']
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