P1: 步骤模板复用 — 内置常见 Pipeline 模式(llm_call / mcp_call / retry_template) #35

Open
opened 2026-06-12 22:38:39 +08:00 by orion · 0 comments
Owner

背景

ext/call.pypipeline_ext 已经实现了 Pipeline 注册和按名引用机制:

register_pipeline("send_notification", { "steps": [...] })
# DSL 中引用
{ "action": "call", "data": "send_notification" }

但框架层面缺少开箱即用的步骤模板库。每次写 Pipeline 都要重复定义常见模式。

需求

提供一组内置的步骤模板,用户可在 DSL 中通过简单声明引用:

模板 说明
llm_call 调用 LLM 并将结果写入 context 指定字段
mcp_call 调用 MCP 工具并将结果写入 context 指定字段
retry_template 重试 + 指数退避的通用模板
validate_then_route 验证结果后路由到不同分支(简化版 judge)
branch_on_field 按 context 字段值分发的并行执行

示例 DSL

{
  "steps": [
    {
      "action": "call",
      "data": "llm_call",
      "input": {
        "messages": "$context.prompt",
        "output_key": "draft"
      }
    },
    {
      "action": "call",
      "data": "mcp_call",
      "input": {
        "tool": "fs_write",
        "arguments": { "path": "...", "content": "$context.draft" },
        "output_key": "write_result"
      }
    }
  ]
}

实现

  1. bixiweave/templates/ 目录,存放内置模板定义
  2. 启动时自动注册到 _pipeline_registry
  3. 模板参数通过 input 字段传入,模板内部用 $input.xxx 引用
  4. 文档同步补齐(当前 pipeline_extext/call.py 都缺文档)

关联

  • #6 模板仓库结构与加载机制
  • bixiweave/ext/call.py — 已有 Pipeline 注册表
  • bixiweave/pipeline_ext.py — 已有扩展注册机制
## 背景 `ext/call.py` 和 `pipeline_ext` 已经实现了 Pipeline 注册和按名引用机制: ```python register_pipeline("send_notification", { "steps": [...] }) # DSL 中引用 { "action": "call", "data": "send_notification" } ``` 但框架层面缺少**开箱即用的步骤模板库**。每次写 Pipeline 都要重复定义常见模式。 ## 需求 提供一组内置的步骤模板,用户可在 DSL 中通过简单声明引用: | 模板 | 说明 | |------|------| | `llm_call` | 调用 LLM 并将结果写入 context 指定字段 | | `mcp_call` | 调用 MCP 工具并将结果写入 context 指定字段 | | `retry_template` | 重试 + 指数退避的通用模板 | | `validate_then_route` | 验证结果后路由到不同分支(简化版 judge) | | `branch_on_field` | 按 context 字段值分发的并行执行 | ## 示例 DSL ```json { "steps": [ { "action": "call", "data": "llm_call", "input": { "messages": "$context.prompt", "output_key": "draft" } }, { "action": "call", "data": "mcp_call", "input": { "tool": "fs_write", "arguments": { "path": "...", "content": "$context.draft" }, "output_key": "write_result" } } ] } ``` ## 实现 1. `bixiweave/templates/` 目录,存放内置模板定义 2. 启动时自动注册到 `_pipeline_registry` 3. 模板参数通过 `input` 字段传入,模板内部用 `$input.xxx` 引用 4. 文档同步补齐(当前 `pipeline_ext` 和 `ext/call.py` 都缺文档) ## 关联 - #6 模板仓库结构与加载机制 - `bixiweave/ext/call.py` — 已有 Pipeline 注册表 - `bixiweave/pipeline_ext.py` — 已有扩展注册机制
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bixiu/bixiweave#35
No description provided.