Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/application/workflow/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ContentType(Enum):
TEXT = "TEXT"
HTML = "HTML"
FILE = "FILE"
ECHARTS = "ECHARTS"
REASONING = "REASONING"
FAILURE = "FAILURE"
TOOL = "TOOL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
from typing import Dict, Type, Optional

from application.workflow.message.aggregator.content_aggregator import ContentAggregator
from application.workflow.message.aggregator.impl import FileAggregator, FormAggregator, HtmlAggregator
from application.workflow.message.aggregator.impl import (
EchartsAggregator,
FileAggregator,
FormAggregator,
HtmlAggregator,
)
from application.workflow.message.aggregator.impl.reasoning_aggregator import ReasoningAggregator
from application.workflow.message.aggregator.impl.text_aggregator import TextAggregator
from application.workflow.message.aggregator.impl.tool_aggregator import ToolAggregator
from application.workflow.message.struct.content import Content
from application.workflow.message.struct.echarts_content import EchartsContent
from application.workflow.message.struct.file_content import FileContent
from application.workflow.message.struct.form_content import FormContent
from application.workflow.message.struct.html_content import HtmlContent
Expand All @@ -35,6 +41,7 @@ class AggregatorFactory:
FormContent: FormAggregator(),
HtmlContent: HtmlAggregator(),
FileContent: FileAggregator(),
EchartsContent: EchartsAggregator(),
}

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions apps/application/workflow/message/aggregator/impl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from application.workflow.message.aggregator.impl.form_aggregator import FormAggregator
from application.workflow.message.aggregator.impl.html_aggregator import HtmlAggregator
from application.workflow.message.aggregator.impl.file_aggregator import FileAggregator
from application.workflow.message.aggregator.impl.echarts_aggregator import EchartsAggregator

__all__ = [
"TextAggregator",
Expand All @@ -20,4 +21,5 @@
"FormAggregator",
"HtmlAggregator",
"FileAggregator",
"EchartsAggregator",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# coding=utf-8
"""
@project: MaxKB
@file: echarts_aggregator.py
@date:2026/12/4
@desc: EchartsContent 聚合器
"""

from application.workflow.message.aggregator.content_aggregator import ContentAggregator
from application.workflow.message.struct.echarts_content import EchartsContent


class EchartsAggregator(ContentAggregator[EchartsContent]):
"""
图表内容聚合器
与 <echarts_rander> 标签内容一致,按顺序拼接内容块
"""

def aggregate(self, prev: EchartsContent, chunk: EchartsContent) -> EchartsContent:
if prev is None:
return chunk
return EchartsContent(
chunk.id or prev.id,
(prev.content or "") + (chunk.content or ""),
chunk.status or prev.status,
chunk.node_info or prev.node_info,
chunk.position or prev.position,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: EchartsAggregator

Potential Issues

1. chunk.id or prev.id — ID overwrite semantics

The aggregation picks chunk.id whenever it's truthy, which means the last chunk's id wins. If ContentAggregator downstream logic relies on stable identity (e.g., deduplication, keying), this may cause instability across chunks. If id should remain constant for the whole aggregated message, use prev.id or chunk.id. Confirm intent.

Suggestion: Make the precedence explicit and document it:

return EchartsContent(
    id=prev.id or chunk.id,          # keep original identity if id is meant to be stable
    content=(prev.content or "") + (chunk.content or ""),
    ...
)

2. Positional constructor arguments are fragile

EchartsContent(...) is called positionally, relying on field order of a dataclass/namedtuple. Any future reordering of fields silently breaks aggregation. Use keyword arguments.

3. Fields are dropped / not handled

Only id, content, status, node_info, position are aggregated. If EchartsContent has other fields (timestamps, metadata, error info, done/is_end flags), they are silently discarded from chunk. Verify all relevant fields are carried over.

4. prev is None branch returns chunk by reference

Returning the incoming chunk directly means the caller receives an object aliased with the input. If either side mutates later, state can leak. If EchartsContent is immutable (frozen dataclass / namedtuple) this is fine; otherwise consider copying.

5. status or prev.status precedence

Like id, later status wins. That's usually correct for streaming, but make sure a partial status ("running") doesn't override a terminal one ("success"). Consider explicit status-merge logic if status is an enum with severity/terminal states (e.g., never downgrade DONE → RUNNING).

6. String concatenation in a loop — O(n²) risk

If aggregate is invoked once per chunk in a stream, (prev.content or "") + (chunk.content or "") rebuilds the full buffer each time → quadratic behavior on large outputs. For typical chat payloads it's fine, but for large charts/long streams, accumulate into a list/buffer and join at the end.

Optimization: store chunks in a list and join lazily, or use ''.join in a finalizer step.

7. Docstring mentions <echarts_rander> — typo

"rander" is likely "render". Also the docstring claims "按顺序拼接内容块" (concatenate content blocks in order), which matches content handling — good, but ensure tags/separators are not required between chunks (e.g., a chunk split mid-</echarts_render> fully qualified tag boundary). Mid-tag splits just work with plain concatenation only if the tag stream itself is being reassembled here — confirm the renderer tolerates arbitrary split points.

8. Missing type hints robustness

prev: EchartsContent yet the code checks prev is None. The signature should be prev: EchartsContent | None = None (or Optional) to match reality, unless the ABC contract forbids None.

9. No regressions tests visible

No unit tests in the diff. Add coverage for: first-chunk (prev=None), empty content, mixed None status/node_info, and multi-chunk concatenation.

10. Encoding/coding declaration

# coding=utf-8 is redundant in Python 3 (UTF-8 is the default). Harmless, but could be removed for consistency with PEP 3120.

Minor / Style

  • Import ordering: application.workflow.message.aggregator... before struct... is fine, but check project isort config.
  • File header @file: uses a full-width colon (:); cosmetic inconsistency with @project: / @date:.

Summary of Recommended Changes

def aggregate(self, prev: Optional[EchartsContent], chunk: EchartsContent) -> EchartsContent:
    if prev is None:
        return chunk
    return EchartsContent(
        id=chunk.id or prev.id,
        content=(prev.content or "") + (chunk.content or ""),
        status=chunk.status or prev.status,
        node_info=chunk.node_info or prev.node_info,
        position=chunk.position or prev.position,
    )

Plus: confirm field completeness, add tests, and consider buffered concatenation for large streams.

22 changes: 22 additions & 0 deletions apps/application/workflow/message/struct/echarts_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# coding=utf-8
"""
@project: MaxKB
@file: echarts_content.py
@date:2026/12/4
@desc: ECharts 图表内容,content 即 <echarts_rander> 标签内的内容,前端用 ECharts 渲染
"""

from application.workflow.content_type import ContentType
from application.workflow.message.struct.content import Content, NodeInfo, Position
from application.workflow.status import Status


class EchartsContent(Content):
def __init__(self, _id, content: str, status: Status, node_info: NodeInfo, position: Position, **kwargs):
self.content = content
super().__init__(_id, status, ContentType.ECHARTS, node_info, position, **kwargs)

def to_dict(self):
result = super().to_dict()
result["content"] = self.content
return result

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my review:

Potential Issues

  1. Inconsistent state handling: self.content is set before super().__init__(). If the parent constructor raises an exception, self.content is still partially initialized. More importantly, if the base class's to_dict() or other logic relies on a content attribute, ordering matters. Consider calling super().__init__() first, then assigning.

  2. content not validated/typed strictly: The type hint says str, but there's no validation. If callers pass None or a dict (some ECharts payloads are objects), it silently propagates. Consider validating or documenting expected format (JSON string vs. dict).

  3. Mutating shared state in to_dict: Assuming super().to_dict() returns a fresh dict this is fine, but if it ever returns a cached/shared reference, you'd be mutating it. Worth confirming the parent contract.

  4. Missing Optional/defaults: No defaults for status, node_info, position — callers must always supply them. Fine if intentional, but consider keyword-only args for readability given the positional _id, content.

  5. No __slots__ (minor): If many instances exist and the base supports it, adding __slots__ = ('content',) reduces memory.

  6. No repr/equality: Minor; depends on base class behavior.

Style/Optimization Suggestions

  • Move super().__init__() before self.content = content for safer initialization ordering.
  • Add a docstring to __init__ and to_dict explaining the content field's expected format (raw JSON string of ECharts option).
  • Consider making content a property or validating it's valid JSON if the frontend requires it.
  • The file header date/naming with full-width colon (@file:) is inconsistent — use ASCII :.
  • Add unit tests verifying to_dict() output contains both parent keys and content.

Summary: The main actionable items are the init-order concern and the lack of validation/documentation around content. Everything else is minor.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# coding=utf-8
"""
@project: MaxKB
@Author:虎虎
@file: echarts_reply.py
@date:2026/12/4
@desc: ECharts 图表回复,与 <echarts_rander> 标签渲染一致:内容即标签内的内容,前端用 ECharts 渲染
"""

import json
from typing import List

import uuid_utils.compat as uuid

from application.workflow.message.struct.content import Content, NodeInfo, Position
from application.workflow.message.struct.echarts_content import EchartsContent
from application.workflow.nodes.reply_node.handle.reply_base_handle import ReplyBaseHandle, to_text
from application.workflow.status import Status


class EchartsReply(ReplyBaseHandle):
def support(self, content_type: str) -> bool:
return content_type == "ECHARTS"

def get_answer(self, node, value):
# 文本原样输出;引用的对象变量序列化为 JSON,与标签内容格式一致
if isinstance(value, (dict, list)):
return json.dumps(value, ensure_ascii=False)
return to_text(value)

def to_content_list(self, answer, node_info: NodeInfo, position: Position) -> List[Content]:
return [EchartsContent(str(uuid.uuid7()), answer, Status.SUCCESS, node_info, position)]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of echarts_reply.py

Potential Issues

  1. uuid_utils.compat as uuid is unusual for a standard library

    • uuid.uuid7() — confirm that the uuid_utils.compat shim actually exposes uuid7(). The stdlib uuid module (even in Python 3.12+) does not have uuid7(). If the compat layer doesn't provide it, this will fail at runtime with AttributeError.
    • Consider whether uuid_utils is a declared dependency in pyproject.toml/requirements.txt.
  2. json.dumps may raise on non-serializable values

    • If value is a dict/list containing datetime, Decimal, sets, custom objects, etc., json.dumps will throw TypeError. Given this is chart data coming from workflow variables, types like datetime are plausible.
    • Suggest a default= fallback (e.g., default=str) or wrap in try/except and fall back to to_text(value).
  3. No type annotations on method signatures

    • support(self, content_type: str) -> bool is annotated, but get_answer(self, node, value) and to_content_list(...) have untyped node, value, answer.
    • answer: str and node: Node return type List[Content] would improve readability and static checking, consistent with support.
  4. Unused import concern / coupling

    • Verify NodeInfo, Position, Status, EchartsContent, to_text are all actually needed (they appear to be). No dead imports obvious, but json is imported unconditionally even though the textual path doesn't need it (minor).
  5. Header comment inconsistency

    • Docstring says @date:2026/12/4 while the diff header shows 2026/12/4 — fine, but mixed full-width colon (:) and ASCII : in the docstring tags (@Author: vs @file:). Cosmetic consistency suggestion.
  6. Magic string "ECHARTS"

    • Repeated verbatim; if other handlers use the same pattern this is acceptable, but consider an enum/shared constant to avoid typos across handlers.
  7. to_content_list always reports Status.SUCCESS

    • Confirm this is intentional. EchartsReply producing SUCCESS regardless of input seems acceptable since rendering is client-side, but worth double-checking no error propagation is expected here.
  8. on the springboard: str(uuid.uuid7()) twice? No — called once per invocation, fine.

Optimization Suggestions

  • Add a serialization guard:
    def get_answer(self, node, value):
        if isinstance(value, (dict, list)):
            try:
                return json.dumps(value, ensure_ascii=False, default=str)
            except TypeError:
                return to_text(value)
        return to_text(value)
  • Add type hints to get_answer (value: Any -> str, node: Node), to_content_list (answer: str) to match the style used in support.
  • Optionally make the JSON serializer configurable (separators, indent) if humans may inspect raw output.
  • Consider moving the ECharts content-type literal to a shared constant.
  • Ensure uuid_utils is pinned in dependencies; alternatively use from uuid import uuid4 for broad compatibility if v7 semantics aren't required.

Overall the file is small and clean; the main risks are uuid7 availability and JSON-serialization exceptions for non-JSON-native workflow variables.

10 changes: 6 additions & 4 deletions apps/application/workflow/nodes/reply_node/reply_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from application.workflow.content_type import ContentType
from application.workflow.i_node import INode
from application.workflow.message.struct.content import Content, NodeInfo, Position
from application.workflow.nodes.reply_node.handle.impl.echarts_reply import EchartsReply
from application.workflow.nodes.reply_node.handle.impl.file_reply import FileReply
from application.workflow.nodes.reply_node.handle.impl.html_reply import HtmlReply
from application.workflow.nodes.reply_node.handle.impl.text_reply import TextReply
Expand All @@ -24,7 +25,7 @@
from application.workflow.status import Status

# 回复格式处理器,未匹配时按文本回复
reply_handles: List[ReplyBaseHandle] = [TextReply(), HtmlReply(), ToolReply(), FileReply()]
reply_handles: List[ReplyBaseHandle] = [TextReply(), HtmlReply(), ToolReply(), FileReply(), EchartsReply()]
default_reply_handle = reply_handles[0]


Expand All @@ -34,9 +35,9 @@ def get_reply_handle(content_type: str) -> ReplyBaseHandle:

class ReplyNodeSerializer(serializers.Serializer):
reply_type = serializers.CharField(required=True, label=_("Response Type"))
# 输出内容类型:TEXT 文本(默认) / HTML / TOOL 工具调用 / FILE 文件
# 输出内容类型:TEXT 文本(默认) / HTML / TOOL 工具调用 / FILE 文件 / ECHARTS 图表
content_type = serializers.ChoiceField(
required=False, default="TEXT", choices=["TEXT", "HTML", "TOOL", "FILE"], label=_("Content Type")
required=False, default="TEXT", choices=["TEXT", "HTML", "TOOL", "FILE", "ECHARTS"], label=_("Content Type")
)
fields = serializers.ListField(required=False, label=_("Reference Field"))
content = serializers.CharField(required=False, allow_blank=True, allow_null=True, label=_("Direct answer content"))
Expand All @@ -49,12 +50,13 @@ class ReplyNode(INode):
type = "reply-node"

def write(self, message: Content):
"""is_result 关闭时不向用户输出回复内容(文本/HTML/工具/文件)"""
"""is_result 关闭时不向用户输出回复内容(文本/HTML/工具/文件/图表)"""
if message.type in (
ContentType.TEXT,
ContentType.HTML,
ContentType.TOOL,
ContentType.FILE,
ContentType.ECHARTS,
) and not self.get_parameters().get("is_result", False):
return
super().write(message)
Expand Down
11 changes: 11 additions & 0 deletions ui/src/conversation-panel/core/aggregators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ const HTML = (prev: Partial<ChatContent> = {}, chunk: Partial<ChatContent>) => {
extra: chunk.extra ?? prev.extra,
}
}
// 图表与 <echarts_rander> 标签内容一致,按顺序拼接
const ECHARTS = (prev: Partial<ChatContent> = {}, chunk: Partial<ChatContent>) => {
return {
type: 'ECHARTS',
id: chunk.id ?? prev.id,
content: (prev.content || '') + (chunk.content || ''),
workflowRunId: chunk.workflowRunId ?? prev.workflowRunId,
extra: chunk.extra ?? prev.extra,
}
}
// 文件按 file_id(无则 url)去重,后到的覆盖先到的,其余按顺序追加
const mergeFiles = (files: ChatFile[] = [], chunkFiles: ChatFile[] = []): ChatFile[] => {
const mergedFiles = [...files]
Expand Down Expand Up @@ -143,4 +153,5 @@ export const aggregators = {
GROUP,
HTML,
FILE,
ECHARTS,
} as Record<string, ContentAggregator>
3 changes: 2 additions & 1 deletion ui/src/locales/en-US/workflow/nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
"toolDescription": "Reply content must be a JSON object or array with the fields id, name, arguments, and content",
"toolExampleContent": "Sunny",
"file": "File",
"fileDescription": "Reply content must be file IDs, file URLs, or file objects containing file_id (arrays supported); only accessible files can be replied"
"fileDescription": "Reply content must be file IDs, file URLs, or file objects containing file_id (arrays supported); only accessible files can be replied",
"chart": "Chart"
},
"content": {
"label": "Reply content",
Expand Down
3 changes: 2 additions & 1 deletion ui/src/locales/zh-CN/workflow/nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
"toolDescription": "回复内容为 JSON 对象或数组,元素字段为 id、name、arguments、content",
"toolExampleContent": "晴",
"file": "文件",
"fileDescription": "回复内容为文件 file_id、文件地址或含 file_id 的文件对象,支持数组;仅可回复有权限访问的文件"
"fileDescription": "回复内容为文件 file_id、文件地址或含 file_id 的文件对象,支持数组;仅可回复有权限访问的文件",
"chart": "图表"
},
"content": {
"label": "回复内容",
Expand Down
3 changes: 2 additions & 1 deletion ui/src/locales/zh-Hant/workflow/nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
"toolDescription": "回復內容為 JSON 對象或數組,元素字段為 id、name、arguments、content",
"toolExampleContent": "晴",
"file": "文件",
"fileDescription": "回復內容為文件 file_id、文件地址或含 file_id 的文件對象,支持數組;僅可回復有權限訪問的文件"
"fileDescription": "回復內容為文件 file_id、文件地址或含 file_id 的文件對象,支持數組;僅可回復有權限訪問的文件",
"chart": "圖表"
},
"content": {
"label": "回復內容",
Expand Down
13 changes: 7 additions & 6 deletions ui/src/workflow-canvas/nodes/reply-node/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const config: JsonObjectSchema = {
reply_type: { type: 'string', enum: ['content', 'referencing'], description: 'content 输出文本,referencing 直接输出入参 value' },
content_type: {
type: 'string',
enum: ['TEXT', 'HTML', 'TOOL', 'FILE'],
enum: ['TEXT', 'HTML', 'TOOL', 'FILE', 'ECHARTS'],
description:
'回复内容格式:TEXT 文本,HTML 富文本,TOOL 工具调用列表(把入参 value 当 [{ id, name, arguments, content }] 输出成工具卡片),' +
'FILE 文件(引用上游的文件变量,如 image_list / audio_list / document_list,按 file_id 鉴权后输出文件卡片)',
'FILE 文件(引用上游的文件变量,如 image_list / audio_list / document_list,按 file_id 鉴权后输出文件卡片),' +
'ECHARTS 图表(内容与 <echarts_rander> 标签内一致:ECharts option JSON,或 { option, style },或 { actionType: "EVAL", option: 脚本 })',
},
content: { type: 'string', description: 'reply_type=content 时的回复文本,可内嵌入参 materials 的 {{节点名称.字段}}' },
is_result: { type: 'boolean', description: '是否输出给用户,默认 true' },
Expand All @@ -46,21 +47,21 @@ const config: JsonObjectSchema = {
const returns: JsonObjectSchema = {
type: 'object',
properties: {
answer: { type: 'any', description: '输出的内容:文本(TEXT/HTML)、工具调用列表(TOOL)或文件列表 [{ file_id, name, url, size }](FILE)' },
answer: { type: 'any', description: '输出的内容:文本(TEXT/HTML/ECHARTS)、工具调用列表(TOOL)或文件列表 [{ file_id, name, url, size }](FILE)' },
},
additionalProperties: false,
}

function useAgent(context: NodeAgentContext) {
return useNodeAgent(context, {
prompt: [
'reply-node(指定回复):不调用模型,把固定文本(content)或上游变量(referencing)直接输出给用户;内容类型可选文本 / 富文本 / 工具卡片(TOOL,引用工具调用列表 [{ id, name, arguments, content }] 输出工具卡片)/ 文件(FILE,引用上游文件变量输出文件卡片)。',
'reply-node(指定回复):不调用模型,把固定文本(content)或上游变量(referencing)直接输出给用户;内容类型可选文本 / 富文本 / 工具卡片(TOOL,引用工具调用列表 [{ id, name, arguments, content }] 输出工具卡片)/ 文件(FILE,引用上游文件变量输出文件卡片)/ 图表(ECHARTS,内容同 <echarts_rander> 标签内容)。',
].join('\n'),
tools: [
{
name: 'update',
description:
'配置当前指定回复节点:直接输出文本(content)或上游变量(referencing)、回复内容格式(TEXT/HTML/TOOL/FILE),以及是否输出给用户。只传要设置的字段,其余保持不变。' +
'配置当前指定回复节点:直接输出文本(content)或上游变量(referencing)、回复内容格式(TEXT/HTML/TOOL/FILE/ECHARTS),以及是否输出给用户。只传要设置的字段,其余保持不变。' +
'写入后自动校验,通过即配置完成并交付本节点的输出字段;不通过返回 error 继续修。',
parameters: config,
apply: async (args) => {
Expand All @@ -76,7 +77,7 @@ function useAgent(context: NodeAgentContext) {
if (error) return new ErrorResult(error)
}
const nodeData = readNodeData<Record<string, unknown>>(node)
const content_type = ['HTML', 'TOOL', 'FILE'].includes(String(args.content_type)) ? args.content_type : (nodeData.content_type ?? 'TEXT')
const content_type = ['HTML', 'TOOL', 'FILE', 'ECHARTS'].includes(String(args.content_type)) ? args.content_type : (nodeData.content_type ?? 'TEXT')
writeNodeProperties(node, {
node_data: {
...nodeData,
Expand Down
1 change: 1 addition & 0 deletions ui/src/workflow-canvas/nodes/reply-node/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export const REPLY_CONTENT_TYPE_LABELS: Readonly<Record<string, string>> = react
HTML: 'HTML',
TOOL: computed(() => t('workflow.reply.format.tool')),
FILE: computed(() => t('workflow.reply.format.file')),
ECHARTS: computed(() => t('workflow.reply.format.chart')),
})
2 changes: 2 additions & 0 deletions ui/src/workflow-canvas/nodes/reply-node/details/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DOMPurify from 'dompurify'
import { useI18n } from 'vue-i18n'
import type { ChatFile } from '@/api/types'
import type { ExecutionNodeDetail } from '@/workflow-canvas/execution-details/types'
import EchartsItem from '@/conversation-panel/components/content/items/echarts.vue'
import FileItem from '@/conversation-panel/components/content/items/file.vue'
import BaseHeader from '@/workflow-canvas/execution-details/BaseHeader.vue'
import DetailContainer from '@/workflow-canvas/execution-details/DetailContainer.vue'
Expand Down Expand Up @@ -41,6 +42,7 @@ const toolAnswer = computed(() => (contentType.value === 'TOOL' ? JSON.stringify
<template v-if="!data.answer || ((contentType === 'TOOL' || contentType === 'FILE') && !data.answer.length)">-</template>
<!-- eslint-disable-next-line vue/no-v-html -- 内容已经 DOMPurify 净化 -->
<div v-else-if="contentType === 'HTML'" v-html="sanitizedHtml" />
<EchartsItem v-else-if="contentType === 'ECHARTS'" :content="{ content: String(data.answer) }" />
<FileItem v-else-if="contentType === 'FILE'" :content="{ file_list: fileList }" />
<div v-else-if="contentType === 'TOOL'" class="whitespace-pre-wrap break-all">{{ toolAnswer }}</div>
<MdPreview v-else :model-value="data.answer" noImgZoomIn />
Expand Down
6 changes: 5 additions & 1 deletion ui/src/workflow-canvas/nodes/reply-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const anchorGuard = createAnchorGuard(model)
onBeforeUnmount(() => anchorGuard.reset())
interface ReplyNodeForm {
content: string
content_type: 'TEXT' | 'HTML' | 'TOOL' | 'FILE'
content_type: 'TEXT' | 'HTML' | 'TOOL' | 'FILE' | 'ECHARTS'
fields: string[]
is_result: boolean
reply_type: 'content' | 'referencing'
Expand Down Expand Up @@ -55,6 +55,9 @@ const contentPlaceholder = computed(() => {
if (formData.value.content_type === 'FILE') {
return t('workflow.reply.content.filePlaceholder', { reference: START_NODE_REFERENCES.question })
}
if (formData.value.content_type === 'ECHARTS') {
return JSON.stringify({ xAxis: { type: 'category', data: ['A', 'B'] }, yAxis: { type: 'value' }, series: [{ type: 'bar', data: [1, 2] }] })
}
if (formData.value.content_type === 'HTML') {
return `<p>${t('workflow.reply.content.htmlPlaceholder', { reference: START_NODE_REFERENCES.question })}</p>`
}
Expand Down Expand Up @@ -110,6 +113,7 @@ onMounted(() => {
</MkTooltip>
</div>
</el-option>
<el-option :label="REPLY_CONTENT_TYPE_LABELS.ECHARTS" value="ECHARTS" />
</el-select>
</el-form-item>

Expand Down
Loading