From 857bc789ed4e5ea54ff6d414978d41916dcfae42 Mon Sep 17 00:00:00 2001 From: lhl Date: Sun, 9 Aug 2026 13:51:21 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20api=20=C2=A77=20=E8=A1=A5=20LLM=5FNETWO?= =?UTF-8?q?RK=5FERROR=20=E8=A1=8C=EF=BC=88=E5=AF=B9=E9=BD=90=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=A0=91=E9=94=99=E8=AF=AF=E7=A0=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _AI_USAGE_LOG.md | 1 + docs/api-design.md | 1 + 2 files changed, 2 insertions(+) diff --git a/_AI_USAGE_LOG.md b/_AI_USAGE_LOG.md index d4633d9..18c17ea 100644 --- a/_AI_USAGE_LOG.md +++ b/_AI_USAGE_LOG.md @@ -55,3 +55,4 @@ | 2026-08-09 11:45 | Agent 实现 | LLM 错误码对齐 Task1:异常树 error_code 类属性(LLMError 基类 None + four 子类 four 码,对齐 api-design §7),沿用现有中文 docstring 未改动。TDD RED(AttributeError: type object 'LLMError' has no attribute 'error_code')→ GREEN(聚焦 4 passed,exceptions.py 100%);聚焦单文件运行触发全库 fail-under=99 coverage exit 1 为基线行为(总覆盖 9.95%),与本次改动无关;加入 _AI_USAGE_LOG.md 提交 | src/genesis/inference/exceptions.py, tests/test_inference_errors.py, _AI_USAGE_LOG.md | deepseek-v4-flash-free | | 2026-08-09 13:42 | Agent 实现 | LLM 错误码对齐 Task2:ChatResult/StructuredResult 增加 error_code 字段(默认 None 向后兼容)。TDD RED(AttributeError: 'ChatResult' object has no attribute 'error_code')→ GREEN(聚焦 8 passed,types.py 100%);pytest 全量 123 passed 覆盖 100.00%(799 stmts/188 br),fail_under=99 达标;提交见 git log | src/genesis/inference/types.py, tests/test_inference_types.py, _AI_USAGE_LOG.md | deepseek-v4-flash-free | | 2026-08-09 14:02 | Agent 实现 | LLM 错误码对齐 Task3:engine 失败/parse_error 路径透传 error_code(与 error 同源取最后一次异常)。chat() 循环记 last_error_code=exc.error_code,失败返回 error_code=last_error_code;chat_structured() 三路径:JSONDecodeError 分支置 last_error_code="LLM_PARSE_ERROR"(解析耗尽→parse_error)、LLMError 分支 early return 带 error_code=exc.error_code、循环后 parse_error 用 last_error_code。TDD RED(5 failed,error_code=None)→ GREEN(聚焦 22 passed);pytest 全量 128 passed 覆盖 100.00%(803 stmts/188 br),fail_under=99 达标;提交见 git log | src/genesis/inference/engine.py, tests/test_inference_engine.py, _AI_USAGE_LOG.md | deepseek-v4-flash-free | +| 2026-08-09 13:51 | Agent 实现 | LLM 错误码对齐 Task4:api-design §7 补 LLM_NETWORK_ERROR 行(对齐异常树 error_code)。在 docs/api-design.md §7 错误码表 LLM_TIMEOUT 行后插入新行 `| LLM_NETWORK_ERROR | 502 | 网络失败/5xx 重试耗尽 | retry / skip / abort | exceptions.LLMNetworkError |`,保留 LLM_NOT_CONFIGURED/LLM_PARSE_ERROR 与 INTERNAL_ERROR 兜底行不动;纯文档改动,全量回归 128 passed 覆盖 100.00%(803 stmts/188 br),fail_under=99 达标 | docs/api-design.md, _AI_USAGE_LOG.md | deepseek-v4-flash-free | diff --git a/docs/api-design.md b/docs/api-design.md index 025ce90..06427ff 100644 --- a/docs/api-design.md +++ b/docs/api-design.md @@ -309,6 +309,7 @@ docker-compose.yml(扩展): | `FILE_TOO_LARGE` | 400 | 超过 100MB 限制 | 压缩/分割 | — | | `STATE_TRANSITION_INVALID` | 409 | 非法状态转移(如 uploading 直接 generate)| 提示正确流程 | — | | `LLM_TIMEOUT` | 502 | LLM 调用超时 | retry / skip / abort | exceptions.LLMTimeoutError | +| `LLM_NETWORK_ERROR` | 502 | 网络失败/5xx 重试耗尽 | retry / skip / abort | exceptions.LLMNetworkError | | `LLM_NOT_CONFIGURED` | 503 | LLM Key 未配置 | 配置 Key | exceptions.LLMNotConfiguredError | | `LLM_PARSE_ERROR` | 502 | 结构化输出解析失败 | retry | exceptions.LLMResponseError | | `EMBEDDING_FAILED` | 503 | Embedding 服务故障(降级为 BM25)| 继续(降级提示)| — |