Spaces:
CGIAR
/
Sleeping

LIANJie-Jason Claude Opus 4.6 commited on
Commit
ebd834c
·
1 Parent(s): 06249fb

feat: add query understanding layer for better retrieval

Browse files

Pre-retrieval LLM step that reformulates user queries into
search-optimized forms (expanded keywords, resolved pronouns,
domain-aware terms) and optionally asks clarification questions.

- New src/query_engine.py with understand_query() + JSON parsing
- New prompt template in src/prompts.py
- CLI: query understanding + conversation history + clarification flow
- Web UI: query understanding + pending_clarification state
- Config: query_understanding.enabled/max_history/max_clarifications
- 10 new tests (59 total, all passing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

8 files changed +447 -8
Files changed (8)
app_cli.py+65-5
app_web.py+51-3
setup.py+5
src/prompts.py+72
src/query_engine.pyAdded+119
tests/test_prompts.py+21
tests/test_query_engine.pyAdded+110
tests/test_setup.py+4