Fix live multi-turn: pass the resolved drug, stop did-you-mean garbage

This commit is contained in:
2026-08-05 16:54:35 +07:00
parent ef08b4929e
commit 1e8cbdb586
29 changed files with 2013 additions and 83 deletions
+21
View File
@@ -26,6 +26,27 @@ class AnswerGenerationUnavailable(RuntimeError):
"""
class RerankUnavailable(RuntimeError):
"""The reranker could not be reached.
Same fail-open contract as the other provider errors, but softer: losing the
reranker only means the candidates keep their original order, so the caller
catches this and proceeds rather than abstaining. Rerank is an ordering
improvement on the fallback, never a precondition for an answer.
"""
class Reranker(Protocol):
"""Reorders candidate texts by joint relevance to the query.
Returns indices into `documents`, most relevant first. A cross-encoder pass
that recovers precision the bi-encoder embedding cannot; applied only to the
similarity/overview fallback, never to the deterministic section route.
"""
def rerank(self, query: str, documents: list[str], top_n: int | None = None) -> list[int]: ...
class AnswerGenerator(Protocol):
"""Rewrites retrieved evidence into prose. Never a source of facts.