mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 15:21:58 +00:00
03c18c4d78
一、文案(前端约 1600 处,后端传到界面的约 880 处) - 术语统一:工作流层面用「运行」(继续运行、重新运行、试运行),节点和工具层面用「执行」,不再用「跑」; 总时长 / 执行时长 / 等待审批;服务端;助手;Agent;token;工作流;固定版本;模型接入;系统提示;批准 / 驳回;受管级别 - 口语改书面:取不到、没取回来、读不懂、连不上、多半、照样、兜底、揉成这类说法改成「无法 / 未能 / 失败 / 请」;去掉拟人写法 - 不再露出实现细节:界面上不写 checkpoint、同一拍、哈希(凭证处除外),不写改版历史(「以前…」「老数据」); 报错、校验、门禁、自动修复里裸写的配置键名和枚举值换成界面上的中文标签,由新的 backend/app/engine/labels.py 统一提供; 发布弹窗里结论句的选项不再是 off / require_citation - 同一件事只留一种说法:生成阶段文案、出具档位说明、画布锁定提示各合成一份 - 去掉界面上的工业场景示例(MES、ERP、「张工」「王工」)和真实产品名,换成通用示例 二、说错的提示(都有测试证明) - 数据库测连接失败时的专用提示以前从不出现(按报错文字全等比较,永远比不上):改为按错误类型判断,不再拼出重复的前缀 - 「设置 → 供应商」改指「设置 → 模型接入」;「在设置里建数据源」改指「数据」页 - 缺少 API Key、模型接入已停用的报错不再夹英文,写明去哪里填 - 两处原因说错(「这种引用在后续版本支持」「这一版还不支持」)改成真实原因 - 节点说明里不准确的说法改正:代码节点在 microVM 或系统沙箱中执行;报告撰写、口径卡的说明不再说过头 - 导出的证据 CSV 里两列同名,第三列改为「片段编号」 三、前后端对齐 - 前端按后端原文识别日志、报错的地方,新旧两种写法都认得(历史运行里存的是旧文字),逐条补了新旧原文的核对 - 后端交回模型的原指令放进单独的 for_model 字段,前端在解析响应时去掉,不会显示到界面上 四、检查 - 检查脚本里按原文匹配的断言改成新文案;改完会变成永远成立的反向断言逐条修正,并做了变异验证 - 新增 check-copy(静态扫描前端界面字符串和后端上界面的文案):再出现「跑」「后端」「多半」「令牌」、 界面上的 Copilot、裸写的配置键名、半角标点等就报错;确需保留的写进 scripts/copy-allow.json 并注明理由
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
"""模型调用失败时说的话。
|
|
|
|
真实случай:供应商的模型列表里列了两个它根本不提供的 id,用户在节点上选了
|
|
其中一个,界面上抛出来的是
|
|
|
|
OpenAIAuthenticationError: Error code: 401 - {'error': {'code':
|
|
'invalid_model', 'message': 'The model does not exist or you do not have
|
|
access to it.', ...}}
|
|
|
|
401 + Authentication 看着像 key 过期,实际上 key 好好的。照着原文去换 key 是
|
|
白费功夫。而且整条轨迹里没有任何地方记着试的是哪个模型——因为 llm.start 只带
|
|
message_count。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app.engine.nodes.llm import explain_model_error
|
|
|
|
|
|
class _FakeAuthError(Exception):
|
|
pass
|
|
|
|
|
|
def test_invalid_model_says_model_not_key() -> None:
|
|
exc = _FakeAuthError(
|
|
"Error code: 401 - {'error': {'code': 'invalid_model', 'message': "
|
|
"'The model does not exist or you do not have access to it.', "
|
|
"'type': 'invalid_request_error'}}"
|
|
)
|
|
msg = explain_model_error(exc, "deepseek-chat")
|
|
|
|
assert "deepseek-chat" in msg, "必须说清是哪个模型,否则没法排查"
|
|
assert "不存在" in msg
|
|
assert "「设置 → 模型接入」" in msg, "要给出下一步去哪儿改:设置页里这一组叫「模型接入」"
|
|
# 别把用户往换 key 的方向带
|
|
assert "401" not in msg
|
|
assert "Authentication" not in msg
|
|
|
|
|
|
def test_quota_is_not_confused_with_missing_model() -> None:
|
|
exc = _FakeAuthError("Error code: 429 - insufficient_quota: balance is 0")
|
|
msg = explain_model_error(exc, "gpt-4o")
|
|
assert "额度" in msg and "gpt-4o" in msg
|
|
assert "不存在" not in msg
|
|
|
|
|
|
def test_unknown_error_keeps_the_original_text() -> None:
|
|
"""不认识的错误照抄原文——猜错了比不猜更糟。"""
|
|
exc = _FakeAuthError("connection reset by peer")
|
|
msg = explain_model_error(exc, "some-model")
|
|
assert "some-model" in msg
|
|
assert "connection reset by peer" in msg
|
|
|
|
|
|
def test_long_errors_are_trimmed() -> None:
|
|
exc = _FakeAuthError("x" * 5000)
|
|
msg = explain_model_error(exc, "m")
|
|
assert len(msg) < 400
|