fix(gateway): troncamento documenti rerank (RERANK_MAX_DOC_CHARS=800) — evita 500 batch-size e costi oltre il ctx

This commit is contained in:
enne2
2026-09-08 12:12:38 +02:00
parent 20766de540
commit 78a93ee771
3 changed files with 19 additions and 0 deletions
+14
View File
@@ -145,6 +145,20 @@ def test_normalize_score():
assert rerank.normalize_score(-10.0) < 0.01
def test_troncamento_documenti(monkeypatch):
_use_chain(monkeypatch)
seen: dict = {}
def handler(request):
seen["docs"] = json.loads(request.content)["documents"]
return httpx.Response(200, json={"results": [{"index": 0, "relevance_score": 1.0}]})
_mock_client(handler)
asyncio.run(rerank.rerank("q", ["x" * 5000, "corto"]))
assert len(seen["docs"][0]) == 800 # default RERANK_MAX_DOC_CHARS
assert seen["docs"][1] == "corto"
# ---------------------------------------------------------------------------
# integrazione endpoint search
# ---------------------------------------------------------------------------