### 输出组件

从 FlowContext 获取数据，将数据转换后，输出到目标

| 组件 | 描述 | 备注 | 可输入 |
| -------- | -------- | -------- | -------- |
| VarOutput           | 变量输出组件         | 推到 FlowContext     | `Publisher<ChatResponse>`, <br/>`ChatResponse`,  <br/>`GenerateResponse`, <br/>...     |
| ConsoleOutput     | 控制台输出组件     | 打印到控制台     | 同上    |
| WebOutput          | Web 输出组件       | 写入 Web 响应流     | 同上    |

ConsoleOutput 扩展自 VarOutput，也会同时输出到 FlowContext。

### 1、VarOutput 组件属性

VarOutput 组件，会接收输入数据，并转换为字符串数据（新数据），再把新数据推入流上下文

| 属性          | 默认值 | 描述 |
| -------- | -------- | -------- |
|   `input`   |    `message`     |   输入变量名（从这里获取数据）    |
|   `output`   |    `message`   |   输出变量名（下个节点，可通过此变量名获取输入值）    |


示例：

```yaml
- task: @VarOutput
```

效果相当于：

```yaml
- task: |
    context.put("messsage", VarOutputCom.getInputAsString(message));
```


### 2、ConsoleOutput 组件属性


ConsoleOutput 组件，扩展自 VarOutput 组件：

* 会接收输入数据，并转换为字符串数据（新数据）
* 在控制台打印新数据
* 新数据推入流上下文

| 属性          | 默认值 | 描述 |
| -------- | -------- | -------- |
|   `input`   |    `message`     |   输入变量名（从这里获取数据）    |
|   `output`   |    `message`   |   输出变量名（下个节点，可通过此变量名获取输入值）    |
|   `format`   |       |   打印格式化（例：`小明：#{message}`）    |


示例：

```yaml
- task: @ConsoleOutput
  meta:
    format: "阿飞：#{message}"  #支持 SnEL 模板表达式
```

效果相当于：

```yaml
- task: |
    context.put("messsage", VarOutputCom.getInputAsString(message));
    
    String format = node.getMeta(META_FORMAT);
    if (Utils.isEmpty(format)) {
        System.out.println(data);
    } else {
        String formatted = SnEL.evalTmpl(format, context.model());
        System.out.println(formatted);
    }
```


### 3、WebOutput 组件属性



WebOutput 组件，会接收输入数据，会有两种处理：

* 如果有 format 配置，会以 sse 方式按 chat-message 格式输出到 web 响应流
* 如果无 format 配置，会转换为字符串数据（新数据），然后按普通 text 输出到 web 响应流


| 属性          | 默认值 | 描述 |
| -------- | -------- | -------- |
|   `input`   |    `message`     |   输入变量名（从这里获取数据）    |
|   `output`   |    `message`   |   输出变量名（下个节点，可通过此变量名获取输入值）    |
|   `format`   |       |   输出格式化（例：`小明：#{message}`）    |


示例：

```yaml
- task: @WebOutput
  meta:
    format: "阿飞：#{message}"  #支持 SnEL 模板表达式
```

效果相当于：

```yaml
- task: |
    Context web = Context.current();
    
    String format = node.getMeta(META_FORMAT);
    if (Utils.isEmpty(format)) {
        //...比较复杂（要看源码）
    } else {
        context.put("messsage", VarOutputCom.getInputAsString(message));
        
        String formatted = SnEL.evalTmpl(format, context.model());
        web.render(formatted);
        web.output("\n");
        web.flush();
    }
```