Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async def dispatch(self, request: StarletteRequest, call_next): # type: ignore[
app.add_middleware(_SecurityHeadersMiddleware)

try:
retriever = HybridRetriever()
retriever = HybridRetriever(config_path=str(_BASE_DIR / "config.yaml"))
except IndexNotFoundError as e:
print(f"FATAL: {e.message}", file=sys.stderr)
print("Run: python -m retrieval.indexer", file=sys.stderr)
Expand Down Expand Up @@ -405,7 +405,7 @@ async def query_endpoint(request: Request, req: QueryRequest):
)

try:
check_input(req.query)
check_input(req.query, config_path=str(_BASE_DIR / "config.yaml"))
except PromptInjectionError as e:
# Pass the full query: audit_log() SHA-256-hashes the "query" field, so
# truncating here yields a hash of only the first 50 chars that diverges
Expand Down Expand Up @@ -457,7 +457,8 @@ async def query_endpoint(request: Request, req: QueryRequest):

if needs_confirm and not answer_model:
top_score = result.get("top_score", 0.0)
threshold = cfg.get("retrieval", {}).get("min_score", 0.4)
# validate_retrieval_config() (boot, above) guarantees this key is present.
threshold = cfg["retrieval"]["min_score"]
return QueryResponse(
answer="",
sources=[],
Expand Down
2 changes: 1 addition & 1 deletion graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def retrieve_node(state: GraphState, retriever: HybridRetriever, cfg: dict) -> d

def route_by_score_node(state: GraphState, cfg: dict) -> dict:
"""Node 2: Compare top_score to threshold. Sets routing flag."""
threshold = cfg.get("retrieval", {}).get("min_score", 0.4)
threshold = cfg.get("retrieval", {}).get("min_score", 0.028)
top_score = state.get("top_score", 0.0)

if top_score >= threshold:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edge_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def client(tmp_path):
patch("gate.HybridRetriever") as MockRet, \
patch("gate.LocalLLMClient") as MockLLM, \
patch("gate.build_graph") as MockBuild, \
patch("gate.check_input", side_effect=lambda q: q), \
patch("gate.check_input", side_effect=lambda q, **kw: q), \
patch("gate.check_all", return_value=[]):

retriever = MockRetriever(MOCK_HIGH_SCORE_RESULTS)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def client(tmp_path):
patch("gate.HybridRetriever") as MockRet, \
patch("gate.LocalLLMClient") as MockLLM, \
patch("gate.build_graph") as MockBuild, \
patch("gate.check_input", side_effect=lambda q: q), \
patch("gate.check_input", side_effect=lambda q, **kw: q), \
patch("gate.check_all", return_value=[]):

retriever = MockRetriever(MOCK_HIGH_SCORE_RESULTS)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_runtime_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def gate_client(tmp_path):
patch("gate.HybridRetriever"), \
patch("gate.LocalLLMClient"), \
patch("gate.build_graph", return_value=mock_graph), \
patch("gate.check_input", side_effect=lambda q: q), \
patch("gate.check_input", side_effect=lambda q, **kw: q), \
patch("gate.check_all", return_value=[]):

import gate
Expand Down
Loading