Преглед изворни кода

feat(docs): update runtime loop outputs (#518)

Louis Young пре 6 месеци
родитељ
комит
a973e37cbe

+ 7 - 0
apps/docs/src/en/guide/runtime/introduction.mdx

@@ -8,6 +8,13 @@ sidebar_position: 2
 
 **⚠️ FlowGram Runtime is currently in early development stage, and only supports nodejs runtime, and only work in free layout.**
 
+<div className="rs-highlight">
+**⚠️ Currently in early development stage**
+
+- Unstable API, API interfaces may change, with no guarantee of backward compatibility
+- Only supports nodejs runtime, and only work in free layout
+</div>
+
 This document introduces the basic concepts, design principles, and core features of FlowGram Runtime to help business integration developers understand and use this reference implementation of a workflow runtime engine.
 
 ## What is FlowGram Runtime

+ 10 - 3
apps/docs/src/en/guide/runtime/node.mdx

@@ -304,7 +304,8 @@ The Loop node is used to perform the same operation on each element in an array,
 
 | Option | Type | Required | Description |
 |------|------|------|------|
-| batchFor | ValueSchema | Yes | The array to iterate over, usually a reference |
+| loopFor | ValueSchema | Yes | The array to iterate over, usually a reference |
+| loopOutputs | `Record<string, ValueSchema>` | Yes | Loop outputs, references to sub-node outputs |
 | blocks | `Array<NodeSchema>` | Yes | Array of nodes within the loop body |
 
 #### Usage Example
@@ -315,9 +316,15 @@ The Loop node is used to perform the same operation on each element in an array,
   "type": "loop",
   "data": {
     "title": "Loop Node",
-    "batchFor": {
+    "loopFor": {
       "type": "ref",
       "content": ["start_0", "items"]
+    },
+    "loopOutputs": {
+      "results": {
+        "type": "ref",
+        "content": ["llm_1", "result"]
+      }
     }
   },
   "blocks": [
@@ -337,7 +344,7 @@ The Loop node is used to perform the same operation on each element in an array,
 }
 ```
 
-In this example, the loop node iterates over the items output of the Start node (assuming it's an array), calling an LLM node for each element. Within the loop body, the current iteration element can be referenced via `loop_0_locals.item`.
+In this example, the loop node iterates over the items output of the Start node (assuming it's an array), calling an LLM node for each element. Within the loop body, the current iteration element can be referenced via `loop_0_locals.item`, and the LLM node's result is referenced as Loop node's output.
 
 ## How to Add Custom Nodes
 

+ 1 - 1
apps/docs/src/zh/guide/runtime/api.mdx

@@ -23,7 +23,7 @@ TaskRun API 接收一个 `TaskRunInput` 对象作为参数:
 | schema | string | 是 | 工作流 schema 的 JSON 字符串,定义了工作流的节点和边 |
 | inputs | object | 否 | 工作流的初始输入参数,可以为空 |
 
-`schema` 参数是一个 JSON 字符串,定义了工作流的结构,包括节点和边的信息。schema 的基本结构如下:
+`schema` 参数是一个 JSON 字符串,定义了工作流的结构,包括节点和边的信息。schema 的基本结构如下:
 
 ```typescript
 interface WorkflowSchema {

+ 10 - 4
apps/docs/src/zh/guide/runtime/introduction.mdx

@@ -6,17 +6,23 @@ sidebar_position: 2
 
 # FlowGram Runtime 介绍
 
-**⚠️ FlowGram Runtime 处于早期开发阶段,目前只支持 nodejs 运行时,且只支持自由布局**
+
+<div className="rs-highlight">
+**⚠️ 目前为早期开发阶段**
+
+- API 接口可能会有变更,不保证向后兼容
+- 目前只支持 nodejs 运行时,且只支持自由布局
+</div>
 
 本文档将介绍 FlowGram Runtime 的基本概念、设计理念和核心功能,帮助业务接入方开发者了解和使用这个工作流运行时引擎的参考实现。
 
 ## 什么是 FlowGram Runtime
 
-FlowGram Runtime 是一个工作流运行时引擎的参考实现,旨在为业务接入方开发者提供运行时参考。它能够解析和执行基于图结构的工作流,支持多种节点类型,包括 Start、End、LLM、Condition、Loop 等。
+FlowGram Runtime 是一个工作流运行时引擎的参考实现,旨在为业务接入方开发者提供运行时参考。能够解析和执行基于图结构的工作流,支持多种节点类型,包括 Start、End、LLM、Condition、Loop 等。
 
 ### 项目定位与目标
 
-FlowGram Runtime **定位为 demo 而非 SDK**,它的主要目标是:
+FlowGram Runtime **定位为 demo 而非 SDK**,主要目标是:
 
 - 提供工作流运行时的设计和实现参考
 - 展示如何构建和扩展工作流引擎
@@ -66,7 +72,7 @@ FlowGram Runtime **定位为 demo 而非 SDK**,它的主要目标是:
 
 ### 执行引擎 (Engine)
 
-执行引擎负责解析工作流定义,按照定义的逻辑顺序执行各个节点,并处理节点间的数据流转。是 FlowGram Runtime 的核心组件,管理整个工作流的生命周期。
+执行引擎负责解析工作流定义,按照定义的逻辑顺序执行各个节点,并处理节点间的数据流转。是 FlowGram Runtime 的核心组件,管理整个工作流的生命周期。
 
 ## 技术架构
 

+ 10 - 3
apps/docs/src/zh/guide/runtime/node.mdx

@@ -304,7 +304,8 @@ Loop节点用于对数组中的每个元素执行相同的操作,实现工作
 
 | 选项 | 类型 | 必填 | 描述 |
 |------|------|------|------|
-| batchFor | ValueSchema | 是 | 要迭代的数组,通常是一个引用 |
+| loopFor | ValueSchema | 是 | 要迭代的数组,通常是一个引用 |
+| loopOutputs | `Record<string, ValueSchema>` | 是 | 循环输出,引用子节点的变量 |
 | blocks | `Array<NodeSchema>` | 是 | 循环体内的节点数组 |
 
 #### 使用示例
@@ -315,9 +316,15 @@ Loop节点用于对数组中的每个元素执行相同的操作,实现工作
   "type": "loop",
   "data": {
     "title": "循环节点",
-    "batchFor": {
+    "loopFor": {
       "type": "ref",
       "content": ["start_0", "items"]
+    },
+    "loopOutputs": {
+      "results": {
+        "type": "ref",
+        "content": ["llm_1", "result"]
+      }
     }
   },
   "blocks": [
@@ -337,7 +344,7 @@ Loop节点用于对数组中的每个元素执行相同的操作,实现工作
 }
 ```
 
-在这个例子中,循环节点对Start节点的items输出(假设是一个数组)进行迭代,对每个元素调用一个LLM节点。在循环体内,可以通过`loop_0_locals.item`引用当前迭代的元素。
+在这个例子中,循环节点对Start节点的items输出(假设是一个数组)进行迭代,对每个元素调用一个LLM节点。在循环体内,可以通过`loop_0_locals.item`引用当前迭代的元素,循环输出可引用LLM节点输出作为循环节点的输出
 
 ## 如何新增自定义节点
 

+ 1 - 1
apps/docs/src/zh/guide/runtime/quick-start.mdx

@@ -10,7 +10,7 @@ sidebar_position: 3
 
 ## 获取代码
 
-由于 FlowGram Runtime 定位为 demo 而非 SDK,不会作为 npm 包发布,您需要通过以下步骤来获取和使用
+由于 FlowGram Runtime 定位为 demo 而非 SDK,不会作为 npm 包发布,您需要通过以下步骤来获取和使用:
 
 ### 方式一:Fork 仓库(推荐)
 

+ 1 - 1
apps/docs/src/zh/guide/runtime/schema.mdx

@@ -5,7 +5,7 @@ description: FlowGram Schema 结构和配置的详细介绍
 
 # Workflow Schema
 
-本文档详细介绍了 Workflow 的 Schema 结构。Workflow Schema 是定义工作流程的核心配置,它描述了节点、边以及它们之间的关系
+本文档详细介绍了 Workflow 的 Schema 结构。Workflow Schema 是定义工作流程的核心配置,描述了节点,以及边的配置
 
 ## 基本结构