mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 14:29:19 +08:00
feat: 贯通 context_window 配置并按 token 预算裁剪对话历史
This commit is contained in:
@@ -43,7 +43,18 @@ class ServerLlmRuntimeGateway(LlmRuntimeGateway):
|
||||
str(k): str(v)
|
||||
for k, v in (data.get("extraHeaders") or {}).items()
|
||||
},
|
||||
context_window=_optional_positive_int(data.get("contextWindow")),
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("拉取 Server LLM runtime 失败 company_id=%s", company_id)
|
||||
return None
|
||||
|
||||
|
||||
def _optional_positive_int(v) -> int | None:
|
||||
if v is None:
|
||||
return None
|
||||
try:
|
||||
n = int(v)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
return n if n > 0 else None
|
||||
|
||||
Reference in New Issue
Block a user