update
This commit is contained in:
parent
01fa68af27
commit
dfc4d1cfa7
@ -225,11 +225,32 @@ class KBESService:
|
||||
auth = (KBConfig.KB_ES_USERNAME, KBConfig.KB_ES_PASSWORD)
|
||||
|
||||
async with httpx.AsyncClient(timeout=5.0, verify=KBConfig.KB_ES_VERIFY_SSL) as client:
|
||||
# 线上排障:打印实际发给 ES 的 request body,确保与手工 curl 完全一致
|
||||
logger.info(f"[KB_ES] request_body={json.dumps(query, ensure_ascii=False)}")
|
||||
resp = await client.post(url, json=query, auth=auth)
|
||||
if resp.status_code >= 300:
|
||||
raise KBESServiceError(f"ES检索失败 HTTP {resp.status_code}: {resp.text}")
|
||||
data = resp.json()
|
||||
|
||||
try:
|
||||
top3 = ((data.get("hits") or {}).get("hits") or [])[:3]
|
||||
logger.info(
|
||||
"[KB_ES] es_top3="
|
||||
+ json.dumps(
|
||||
[
|
||||
{
|
||||
"_id": h.get("_id"),
|
||||
"_score": h.get("_score"),
|
||||
"question": (h.get("_source") or {}).get("question"),
|
||||
}
|
||||
for h in top3
|
||||
],
|
||||
ensure_ascii=False,
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
hits = (data.get("hits") or {}).get("hits") or []
|
||||
chunks: List[Dict[str, Any]] = []
|
||||
scores: List[float] = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user