Spaces:
Sleeping
Sleeping
Commit
·
8098d9b
1
Parent(s):
19ee5be
🎯 Default to document search for ALL voice queries
Browse files- Changed default behavior: ALL non-greeting queries now search 23K documents
- Fixes: When ASR mishears 'pension rules' → 'challenge loans', still searches DB
- Previous: Only searched if query contained keywords like 'pension', 'rules'
- Now: Assumes ALL questions need document search (it's a gov rule assistant)
- Only skips search for clear greetings: hi, hello, thank you, bye
- Improves robustness when voice transcription is imperfect
- groq_websocket_handler.py +10 -8
groq_websocket_handler.py
CHANGED
|
@@ -498,20 +498,22 @@ class GroqWebSocketHandler:
|
|
| 498 |
"reason": f"Contains government/policy keywords: {', '.join(matched_keywords)}"
|
| 499 |
}
|
| 500 |
|
| 501 |
-
# Default:
|
| 502 |
-
|
|
|
|
| 503 |
return {
|
| 504 |
"requires_documents": True,
|
| 505 |
"query_type": "information_request",
|
| 506 |
-
"confidence": 0.
|
| 507 |
-
"reason": "Multi-word query
|
| 508 |
}
|
| 509 |
|
|
|
|
| 510 |
return {
|
| 511 |
-
"requires_documents":
|
| 512 |
-
"query_type": "
|
| 513 |
-
"confidence": 0.
|
| 514 |
-
"reason": "
|
| 515 |
}
|
| 516 |
|
| 517 |
async def _generate_audio_response(self, websocket: WebSocket, session_id: str, text: str):
|
|
|
|
| 498 |
"reason": f"Contains government/policy keywords: {', '.join(matched_keywords)}"
|
| 499 |
}
|
| 500 |
|
| 501 |
+
# Default: ALWAYS search documents for non-casual queries
|
| 502 |
+
# This is a pension/government assistant, so most queries should search documents
|
| 503 |
+
if len(query.split()) >= 2: # Multi-word queries likely need document search
|
| 504 |
return {
|
| 505 |
"requires_documents": True,
|
| 506 |
"query_type": "information_request",
|
| 507 |
+
"confidence": 0.7,
|
| 508 |
+
"reason": "Multi-word query - defaulting to document search for better accuracy"
|
| 509 |
}
|
| 510 |
|
| 511 |
+
# Even single-word queries should search documents (unless they're greetings)
|
| 512 |
return {
|
| 513 |
+
"requires_documents": True,
|
| 514 |
+
"query_type": "general_info",
|
| 515 |
+
"confidence": 0.6,
|
| 516 |
+
"reason": "Defaulting to document search - this is a government rule assistant"
|
| 517 |
}
|
| 518 |
|
| 519 |
async def _generate_audio_response(self, websocket: WebSocket, session_id: str, text: str):
|