// File: frontend/app/workflow/components/ChatOutputNode.tsx (新建) // Description: 自定义 ChatOutput 节点 import React, { memo, useCallback, ChangeEvent } from 'react'; import { Handle, Position, useReactFlow, Node } from 'reactflow'; import { MessageCircleReply } from 'lucide-react'; // 使用合适的图标 import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; // 使用 Input 或 Textarea 根据需要 import type { ChatOutputNodeData, CustomNodeProps } from './types'; const ChatOutputNodeComponent = ({ id, data, isConnectable }: CustomNodeProps) => { const { setNodes } = useReactFlow(); // 处理文本变化 (如果需要可编辑) const handleTextChange = useCallback((event: ChangeEvent) => { const newText = event.target.value; setNodes((nds: Node[]) => nds.map((node) => { if (node.id === id) { return { ...node, data: { ...node.data, displayText: newText } }; } return node; }) ); }, [id, setNodes]); return (
{/* 输入 Handle */} {/* 节点头部 */}
Chat Output

在 Playground 显示聊天消息。

{/* 节点内容 */}
{/* 根据截图,这里像是一个 Input,可能用于显示模板或结果 */} {/* 或者只是一个简单的文本显示区域 */} {/*

{data.displayText || '等待输入...'}

*/}
{/* 输出 Handle (可选,根据是否需要继续传递) */} {/*
*/}
); }; ChatOutputNodeComponent.displayName = 'ChatOutputNode'; export const ChatOutputNode = memo(ChatOutputNodeComponent);