Skip to content

需求翻译 ​

把用户的一句话变成一组可执行的结构化子任务。这是整个编排链路的起点,也是"用户不需要知道有哪些 Agent"的前提。


职责 ​

负责不负责
自然语言 → 子任务列表选择具体 Agent(agent-matching)
识别领域与子领域构建 DAG(workflow)
提取输入实体执行任务(task)
LLM 拆解 + 规则兜底验证输出(verification)
平台内部 Agent 的种子计费

数据模型 ​

集合:translated_demands

json
{
  "demandId": "d_...",
  "query": "我要把智能手表卖到德国",
  "subTasks": [
    {
      "skillId": "ce-certification-review-v1",
      "subDomain": "ce_certification",
      "input": { "product": "智能手表", "market": "DE" },
      "confidence": 0.93
    }
  ],
  "source": "llm | rule",
  "createdAt": "..."
}

接口 ​

方法路径说明
POST/api/demands翻译需求并(可选)构建工作流
GET/api/demands/:id查询翻译结果

Chat UI 主链路已切换到 POST /api/chat/prepare,由 chat-execute 调用本模块。/api/demands 保留用于直接调用。


处理流程 ​

translate(queryText)
  ├─ 加载 Skill Catalog(可用的 subDomain 清单)
  ├─ LLM 拆解
  │    ├─ 成功且置信度足够 → 使用结果
  │    └─ 失败 / 低置信度 → 关键词规则兜底
  ├─ 归一化
  │    ├─ skillId 对齐到 Catalog
  │    ├─ subDomain 校验
  │    └─ 去除重复与空项
  └─ 持久化 translated_demands

规则兜底 ​

当 LLM 不可用或返回不可解析时,按关键词映射:

关键词subDomain
CE / 认证ce_certification
FDA / 标签fda_label
VAT / 税vat
HS / 归类hs_code
商标 / 侵权ip_infringement
合同contract_review

规则兜底是确定性保障,不追求覆盖全部语义。


平台内部 Agent ​

PlatformAgentSeedService 在启动时种入:

agentId作用
platform-demand-translation需求翻译
platform-result-synthesis结果综合

这两者是 domain=platform 的 AgentProfile,不计费。


输入识别 ​

翻译时会尽量提取:

类别示例
产品智能手表、蓝牙音箱
市场德国、美国、日本
价格199 欧元
材料已有检测报告、说明书
目标上架、清关、注册、审查

缺失的关键字段会在子任务中留空,由 Agent 追问或用户补充。


边界与限制 ​

限制说明
依赖 LLM 质量复杂需求可能拆错
规则覆盖有限只覆盖常见关键词
不做澄清低置信度由前端提示,不由模块自动追问
一次翻译不维护多轮翻译状态
领域硬编码新领域需要新增 Skill 与关键词

源码位置 ​

libs/modules/src/demand-translation/
├── demand-translation.controller.ts
├── services/demand-translation.service.ts
├── services/platform-agent-seed.service.ts
└── schemas/translated-demand.schema.ts

相关页面 ​

Released under the MIT License.