mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
feat(navi): semantic query router for intelligent tool selection - Phase H2b
Add centroid-based query classifier that routes Aurora queries to the appropriate handler (nav_route, nav_reverse_geocode, direct_answer, rag_search) before the RAG pipeline runs. Uses TEI embeddings against pre-computed route centroids from 38 example queries. - query_router.py: standalone module with lazy centroid init - query_router_test.py: 7-query test suite (all passing) - Corresponding recon_rag_tool.py v4.2.0 deployed to Open WebUI DB Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9841c38011
commit
3243f2f252
2 changed files with 210 additions and 0 deletions
49
lib/query_router_test.py
Normal file
49
lib/query_router_test.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Test suite for the semantic query router."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from lib.query_router import classify
|
||||
|
||||
TEST_QUERIES = [
|
||||
("how do I get from Buhl to Boise", "nav_route"),
|
||||
("what does the survival manual say about water", "rag_search"),
|
||||
("what town is at 42.5, -114.7", "nav_reverse_geocode"),
|
||||
("hey aurora", "direct_answer"),
|
||||
("what's the fastest way to Sun Valley", "nav_route"),
|
||||
("how to purify water in the field", "rag_search"),
|
||||
("good morning", "direct_answer"),
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
print("Query Router Test Suite")
|
||||
print("=" * 70)
|
||||
|
||||
passed = 0
|
||||
failed = 0
|
||||
|
||||
for query, expected in TEST_QUERIES:
|
||||
route, confidence = classify(query)
|
||||
status = "PASS" if route == expected else "FAIL"
|
||||
if status == "PASS":
|
||||
passed += 1
|
||||
else:
|
||||
failed += 1
|
||||
print(f" [{status}] {query!r}")
|
||||
print(f" → {route} ({confidence:.3f}) expected={expected}")
|
||||
|
||||
print("=" * 70)
|
||||
print(f"Results: {passed}/{passed + failed} passed")
|
||||
if failed:
|
||||
print(f" {failed} FAILED")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(" All tests passed!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue