Skip to content

Commit 9206942

Browse files
authored
docs(variable): Add biz introduction for variable engine (bytedance#113)
1 parent d32fa9b commit 9206942

File tree

7 files changed

+116
-0
lines changed

7 files changed

+116
-0
lines changed

apps/docs/src/en/guide/advanced/variable.mdx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,62 @@
11
# Use Variables
22

3+
## Business Background
4+
5+
In Workflow orchestration, information needs to be passed between nodes. To achieve this, we use **variables** to store and manage this information.
6+
7+
:::warning A variable consists of three main parts:
8+
9+
1. **Unique Identifier**: The name of the variable, used to distinguish different variables so that they can be accurately referenced and used in the program. For example: `userName` or `totalAmount`.
10+
2. **Value**: The data stored by the variable. The value can be of various types, such as numbers (e.g., `42`), strings (e.g., `"Hello!"`), boolean values (e.g., `true`), etc.
11+
3. **Type**: The kind of data that the variable can store. The type determines what kind of values the variable can accept. For example, a variable can be an integer, float, string, or boolean, etc.
12+
13+
:::
14+
15+
Here is an example of a workflow orchestration: The WebSearch node retrieves knowledge and passes it to the LLM node for analysis through the `natural_language_desc`.
16+
17+
<div style={{display: 'flex', gap: '20px'}}>
18+
<img style={{width: "50%"}} loading="lazy" src="/variable/variable-biz-context-websearch-llm.png" />
19+
<div>
20+
In this example:
21+
<p style={{marginTop: 10}}>1. The WebSearch node stores the information (value) in a variable with the unique identifier `natural_language_desc`.</p>
22+
<p style={{marginTop: 5}}>2. The LLM node retrieves the information (value) from the knowledge base using the unique identifier `natural_language_desc` and passes it to the LLM node for analysis.</p>
23+
<p style={{marginTop: 5}}>3. The type of the `natural_language_desc` variable is a string, representing the content of the information retrieved from the web, such as "DeepSeek has released a new model today."</p>
24+
</div>
25+
</div>
26+
27+
## What is the Variable Engine?
28+
29+
The Variable Engine is an optional built-in feature provided by Flowgram that helps to efficiently implement **variable information orchestration** during workflow design. It can achieve the following functions:
30+
31+
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "25px" }}>
32+
<div style={{ gridColumn: "span 2" }}>
33+
<b>Scope Constraint Control</b>
34+
<p className="rs-tip">With the Variable Engine, you can control the scope of variables, ensuring that variables are available within the appropriate range and avoiding unnecessary conflicts.</p>
35+
<div style={{display: "flex", gap: "25px"}}>
36+
<div>
37+
<img loading="lazy" src="/variable/variable-scope-feature-1.png" />
38+
<p style={{marginTop: '10px'}}>In the image, the query variable of the Start node can be accessed by the subsequent LLM node and End node.</p>
39+
</div>
40+
<div>
41+
<img loading="lazy" src="/variable/variable-scope-feature-2.png" />
42+
<p style={{marginTop: '10px'}}>In the image, the LLM node is within the Condition branch, while the End node is outside the Condition branch; therefore, the variable selector of the End node cannot select the result variable from the LLM node.</p>
43+
</div>
44+
</div>
45+
</div>
46+
<div>
47+
<b>Maintenance of Variable Information Tree</b>
48+
<p className="rs-tip">The Variable Engine can help you build a clear variable information tree, making it easier to view and manage the status and relationships of all variables.</p>
49+
<img loading="lazy" src="/variable/variable-tree-management.gif" />
50+
<p style={{marginTop: '10px'}}>The image shows multiple nodes + global configuration output variables; some variables contain multiple sub-variables, forming a tree structure.</p>
51+
</div>
52+
<div>
53+
<b>Automatic Type Inference of Variables</b>
54+
<p className="rs-tip">The Variable Engine can automatically infer the type of variables based on context, reducing the workload of manually specifying types and improving development efficiency.</p>
55+
<img loading="lazy" src="/variable/variable-batch-auto-infer.gif" />
56+
<p style={{marginTop: '10px'}}>In the image, the Batch node processes the arr variable from the Start node; when the type of the arr variable changes, the type of the item variable output by the Batch node also changes accordingly.</p>
57+
</div>
58+
</div>
59+
360
## Enable Variable Engine
461

562
[> API Detail](https://flowgram.ai/auto-docs/editor/interfaces/VariablePluginOptions.html)
1.65 MB
Loading
111 KB
Loading
135 KB
Loading
120 KB
Loading
772 KB
Loading

apps/docs/src/zh/guide/advanced/variable.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
# 变量的使用
22

3+
## 业务背景
4+
5+
在 Workflow 编排中,节点与节点之间需要传递信息。为了实现这一点,我们使用**变量**来存储和管理这些信息。
6+
7+
:::warning 一个变量由三个主要部分组成:
8+
9+
1. **唯一标识符**:变量的名字,用于区分不同的变量,以便在程序中可以准确地引用和使用它。如:`userName``totalAmount`
10+
2. ****:变量存储的数据。值可以是多种类型,比如数字(如 `42`)、字符串(如 `"Hello!"`)、布尔值(如 `true`)等。
11+
3. **类型**:变量可以存储的数据种类。类型决定了变量可以接受什么样的值。例如,一个变量可以是整数、浮点数、字符串或布尔值等。
12+
13+
:::
14+
15+
下面是一个流程编排的例子:WebSearch 节点获取到知识,通过 natural_language_desc 传递到 LLM 节点进行分析
16+
17+
<div style={{display: 'flex', gap: '20px'}}>
18+
<img style={{width: "50%"}} loading="lazy" src="/variable/variable-biz-context-websearch-llm.png" />
19+
<div>
20+
在该例子中:
21+
<p style={{marginTop: 10}}>1. WebSearch 节点将信息(值)存在 natural_language_desc 为唯一标识符的变量内</p>
22+
<p style={{marginTop: 5}}>2. LLM 节点通过 natural_language_desc 唯一标识符获取到知识库检索的信息(值),并传入 LLM 节点进行分析</p>
23+
<p style={{marginTop: 5}}>3. natural_language_desc 变量的类型为字符串,代表在网络中检索到的信息内容,例如 "DeepSeek 今日有新模型发布"</p>
24+
</div>
25+
</div>
26+
27+
28+
## 什么是变量引擎?
29+
30+
变量引擎是 Flowgram 提供的一个可选内置功能,可以帮助 Workflow 设计时更高效地实现**变量信息编排**。它可以实现以下功能:
31+
32+
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "25px" }}>
33+
<div style={{ gridColumn: "span 2" }}>
34+
<b>作用域约束控制</b>
35+
<p className="rs-tip">通过变量引擎,你可以控制变量的作用域,确保变量在合适的范围内可用,避免不必要的冲突。</p>
36+
<div style={{display: "flex", gap: "25px"}}>
37+
<div>
38+
<img loading="lazy" src="/variable/variable-scope-feature-1.png" />
39+
<p style={{marginTop: '10px'}}>图中 Start 节点的 query 变量,可被后续的 LLM 节点和 End 节点访问</p>
40+
</div>
41+
<div>
42+
<img loading="lazy" src="/variable/variable-scope-feature-2.png" />
43+
<p style={{marginTop: '10px'}}>图中 LLM 节点在 Condition 分支内,End 节点在 Condition 分支外;因此 End 节点的变量选择器无法选择到 LLM 节点上的 result 变量</p>
44+
</div>
45+
</div>
46+
</div>
47+
<div>
48+
<b>变量信息树的维护</b>
49+
<p className="rs-tip">变量引擎可以帮助你构建一个清晰的变量信息树,方便你查看和管理所有变量的状态和关系。</p>
50+
<img loading="lazy" src="/variable/variable-tree-management.gif" />
51+
<p style={{marginTop: '10px'}}>图中展示了多个节点 + 全局配置的输出变量;其中部分变量包含了多个子变量,形成了一棵树的结构</p>
52+
</div>
53+
<div>
54+
<b>变量类型自动联动推导</b>
55+
<p className="rs-tip">变量引擎能够根据上下文自动推导变量的类型,减少手动指定类型的工作量,提高开发效率。</p>
56+
<img loading="lazy" src="/variable/variable-batch-auto-infer.gif" />
57+
<p style={{marginTop: '10px'}}>图中的 Batch 节点对 Start 节点的 arr 变量进行了批处理,当 arr 变量的类型变动时,Batch 节点批处理输出的 item 变量类型也随之变动</p>
58+
</div>
59+
</div>
60+
61+
362
## 开启变量引擎
463

564
[> API Detail](https://flowgram.ai/auto-docs/editor/interfaces/VariablePluginOptions.html)

0 commit comments

Comments
 (0)