ChAbhishek28 commited on
Commit
15b123d
·
1 Parent(s): f9f45e2

Add 8999999999999999999999

Browse files
Files changed (1) hide show
  1. enhanced_websocket_handler.py +21 -2
enhanced_websocket_handler.py CHANGED
@@ -383,11 +383,30 @@ async def handle_voice_message(websocket: WebSocket, data: dict, session_data: d
383
  enhanced_message, session_data["context"], config, knowledge_base
384
  ):
385
  response_chunks.append(chunk)
 
386
  await websocket.send_json({
387
  "type": "streaming_response",
388
- "message": chunk
 
 
 
 
 
 
 
 
 
389
  })
390
- response_text = "".join(response_chunks)
 
 
 
 
 
 
 
 
 
391
  provider_used = hybrid_llm_service.choose_llm_provider(enhanced_message)
392
  provider_used = provider_used.value if provider_used else "unknown"
393
  else:
 
383
  enhanced_message, session_data["context"], config, knowledge_base
384
  ):
385
  response_chunks.append(chunk)
386
+ # Send each chunk as structured data
387
  await websocket.send_json({
388
  "type": "streaming_response",
389
+ "clause_text": chunk.get("clause_text", ""),
390
+ "summary": chunk.get("summary", ""),
391
+ "role_checklist": chunk.get("role_checklist", []),
392
+ "source_title": chunk.get("source_title", ""),
393
+ "clause_id": chunk.get("clause_id", ""),
394
+ "date": chunk.get("date", ""),
395
+ "url": chunk.get("url", ""),
396
+ "score": chunk.get("score", 1.0),
397
+ "scenario_analysis": chunk.get("scenario_analysis", None),
398
+ "charts": chunk.get("charts", [])
399
  })
400
+
401
+ # Create response text for voice synthesis from the chunks
402
+ response_text_parts = []
403
+ for chunk in response_chunks:
404
+ if chunk.get("clause_text"):
405
+ response_text_parts.append(chunk.get("clause_text", ""))
406
+ if chunk.get("summary"):
407
+ response_text_parts.append(chunk.get("summary", ""))
408
+ response_text = " ".join(response_text_parts) if response_text_parts else "I found relevant information about your query."
409
+
410
  provider_used = hybrid_llm_service.choose_llm_provider(enhanced_message)
411
  provider_used = provider_used.value if provider_used else "unknown"
412
  else: