Remove corpus counts from chat chrome

This commit is contained in:
2026-08-10 17:26:58 +07:00
parent 46469468bb
commit 97cb6d16f4
31 changed files with 2192 additions and 424 deletions
+11 -1
View File
@@ -13,6 +13,7 @@ and the Messages-API path on Bedrock is the Mantle client — not the legacy
from __future__ import annotations
import json
import re
from typing import Any
from rag.ports import AnswerGenerationUnavailable
@@ -123,8 +124,17 @@ class StubAnswerGenerator:
"""
def __init__(self, answer: str, evidence_sufficient: bool = True) -> None:
# `answer` keeps its old free-text-with-[n]-markers shape for this
# constructor's own callers (bootstrap.py's demo string) — wrapped
# into a single structured claim here since 2026-08-10's schema
# change (see rag/prompt.py's ANSWER_SCHEMA).
citations = [int(n) for n in re.findall(r"\[(\d+)\]", answer)]
text = re.sub(r"\s*\[\d+\]", "", answer).strip()
self._payload = json.dumps(
{"answer": answer, "evidence_sufficient": evidence_sufficient},
{
"claims": [{"text": text, "citations": citations}] if text else [],
"evidence_sufficient": evidence_sufficient,
},
ensure_ascii=False,
)
self.calls: list[tuple[str, str]] = []
+11 -13
View File
@@ -9,8 +9,8 @@ One structural difference from the Anthropic path drives the shape of this file:
Converse has **no** server-side response schema (no `output_config.format`), so
the JSON envelope `answer.py` parses cannot be enforced by the API. It is asked
for in the prompt and then isolated here (`_extract_json`) before returning. If
the model still emits something unparseable, `answer.py` falls back to the
verbatim source text — losing the rewrite, never the answer.
the model still emits something unparseable, `answer.py` fails closed with a
diagnosable abstention instead of presenting a raw dump as a generated answer.
"""
from __future__ import annotations
@@ -92,17 +92,15 @@ class BedrockConverseAnswerGenerator:
BEDROCK_RUNTIME_SERVICE,
region_name=self._region,
config=Config(
connect_timeout=10,
read_timeout=60,
# "adaptive" was tried 2026-08-07 and reverted same day: its
# client-side rate limiter remembers "throttled" across
# requests and paces even unrelated, otherwise-healthy calls
# down after a burst — turned a single answerable turn's
# baseline ~9s into 1-5 MINUTES following this session's own
# heavy adversarial test traffic. "standard" retries each
# call independently, no shared state to get stuck in a bad
# regime. max_attempts alone (3->4) is kept.
retries={"max_attempts": 4, "mode": "standard"},
connect_timeout=5,
# The request budget is checked between calls and cannot
# interrupt boto3 while a call is in flight. A 60s read
# timeout with four SDK attempts allowed one turn to run
# for minutes. Allow one bounded retry: production smoke
# tests showed an isolated Qwen read timeout immediately
# followed by a healthy 3s response for the same request.
read_timeout=20,
retries={"total_max_attempts": 2, "mode": "standard"},
),
)
return self._client