feat(api): DeepSeek V4 Flash 默认、HTTP 错讯与多供应商分层
- 主链路默认 deepseek-v4-flash,DEEPSEEK_THINKING_ENABLED 对齐旧非思考 chat - 评测台评审装配迁入 adapters/llm(deepseek_eval_judge、zhipu_eval_judge)与 eval_judge_spec - 拆分 llm_http_openai_chat_errors 与 llm_errors(DeepSeek/智谱品牌与文档链),llm_call 支持 http_error_vendor - EvalJudgeService 按 spec.provider 传入 allm_json_call;评测台前端文案改为 V4 Flash - 更新 .env 示例与 staging/production 的 DEEPSEEK_MODEL;补充 openai/供应商错讯测试 Made-with: Cursor
This commit is contained in:
@@ -28,6 +28,8 @@ from app.core.langchain_llm import (
|
||||
bind_json_object_mode,
|
||||
ensure_json_object_prompt_has_json_keyword,
|
||||
)
|
||||
from app.core.llm_errors import LlmHttpErrorVendor, format_llm_http_error_message
|
||||
from app.core.llm_http_openai_chat_errors import should_log_openai_error_as_warning
|
||||
from app.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -100,9 +102,14 @@ _LLM_MSG_CONTENT_FILTER = (
|
||||
)
|
||||
|
||||
|
||||
def _format_llm_invoke_error_message(exc: BaseException) -> str:
|
||||
def _format_llm_invoke_error_message(
|
||||
exc: BaseException, *, http_error_vendor: LlmHttpErrorVendor = "deepseek"
|
||||
) -> str:
|
||||
if _is_content_filter_refusal(exc):
|
||||
return _LLM_MSG_CONTENT_FILTER
|
||||
friendly = format_llm_http_error_message(exc, http_error_vendor)
|
||||
if friendly is not None:
|
||||
return friendly
|
||||
return str(exc)
|
||||
|
||||
|
||||
@@ -116,6 +123,11 @@ def _log_invoke_failure(*, agent: str, exc: BaseException, sync: bool) -> None:
|
||||
)
|
||||
return
|
||||
tag = "llm_json_call" if sync else "allm_json_call"
|
||||
if should_log_openai_error_as_warning(exc):
|
||||
logger.bind(agent=agent).warning(
|
||||
"{} provider http error: {}", tag, str(exc)[:800]
|
||||
)
|
||||
return
|
||||
logger.bind(agent=agent).exception("{} invoke error: {}", tag, exc)
|
||||
|
||||
|
||||
@@ -273,6 +285,7 @@ def llm_json_call(
|
||||
agent: str,
|
||||
fallback_factory: Callable[[], T] | None = None,
|
||||
retry_empty: bool = True,
|
||||
http_error_vendor: LlmHttpErrorVendor = "deepseek",
|
||||
) -> T:
|
||||
"""同步:invoke → 解析 JSON → `schema.model_validate`;失败时 `fallback_factory` 或 `LLMCallError`。"""
|
||||
t0 = time.perf_counter()
|
||||
@@ -353,7 +366,7 @@ def llm_json_call(
|
||||
return fallback_factory()
|
||||
raise LLMCallError(
|
||||
"invoke",
|
||||
_format_llm_invoke_error_message(e),
|
||||
_format_llm_invoke_error_message(e, http_error_vendor=http_error_vendor),
|
||||
raw_content=raw[:4096] if raw else None,
|
||||
) from e
|
||||
|
||||
@@ -367,6 +380,7 @@ async def allm_json_call(
|
||||
agent: str,
|
||||
fallback_factory: Callable[[], T] | None = None,
|
||||
retry_empty: bool = True,
|
||||
http_error_vendor: LlmHttpErrorVendor = "deepseek",
|
||||
) -> T:
|
||||
"""异步版,语义与 `llm_json_call` 一致。"""
|
||||
t0 = time.perf_counter()
|
||||
@@ -447,7 +461,7 @@ async def allm_json_call(
|
||||
return fallback_factory()
|
||||
raise LLMCallError(
|
||||
"invoke",
|
||||
_format_llm_invoke_error_message(e),
|
||||
_format_llm_invoke_error_message(e, http_error_vendor=http_error_vendor),
|
||||
raw_content=raw[:4096] if raw else None,
|
||||
) from e
|
||||
|
||||
@@ -455,6 +469,7 @@ async def allm_json_call(
|
||||
__all__ = [
|
||||
"LLMCallError",
|
||||
"LLMCallMeta",
|
||||
"LlmHttpErrorVendor",
|
||||
"allm_json_call",
|
||||
"llm_json_call",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user