From a6e75659195306301ccb1064daaec64dac1654c3 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Wed, 14 Jan 2026 14:48:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(web):=20agent=E2=80=98s=20tools=20bugfi?= =?UTF-8?q?x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/i18n/en.ts | 4 ++++ web/src/i18n/zh.ts | 4 ++++ web/src/views/ApplicationConfig/Agent.tsx | 3 +++ web/src/views/ApplicationConfig/components/ToolList.tsx | 2 -- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 27986e76..2d2d96a2 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -1265,6 +1265,7 @@ export const en = { emotionLine: 'Emotion Changes Over Time', interaction: 'Interaction Frequency & Relationship Stages', timelines_memory: 'All', + Chunk: 'Chunk', MemorySummary: 'Long-term Accumulation', Statement: 'Emotional Memory', ExtractedEntity: 'Episodic Memory', @@ -1786,6 +1787,9 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re temperature: 'Temperature', max_tokens: 'Max Tokens', context: 'Context', + memory: 'Memory', + enable_window: 'Memory Window', + inner: 'Built-in', }, start: { variables: 'Input Fields', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index 8fa73fd3..53e71c84 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -1343,6 +1343,7 @@ export const zh = { emotionLine: '情绪随时间变化', interaction: '互动频率 & 关系阶段', timelines_memory: '全部', + Chunk: '工作记忆', MemorySummary: '长期沉淀', Statement: '情绪记忆', ExtractedEntity: '情景记忆', @@ -1883,6 +1884,9 @@ export const zh = { temperature: '温度', max_tokens: '最大令牌数', context: '上下文', + memory: '记忆', + enable_window: '记忆窗口', + inner: '内置', }, start: { variables: '输入字段', diff --git a/web/src/views/ApplicationConfig/Agent.tsx b/web/src/views/ApplicationConfig/Agent.tsx index ce51c622..81f902cb 100644 --- a/web/src/views/ApplicationConfig/Agent.tsx +++ b/web/src/views/ApplicationConfig/Agent.tsx @@ -176,6 +176,9 @@ const Agent = forwardRef((_props, ref) => { if (response?.knowledge_retrieval?.knowledge_bases?.length) { getDefaultKnowledgeList(response) } + if (response?.tools?.length) { + setToolList(response?.tools) + } }).finally(() => { setLoading(false) }) diff --git a/web/src/views/ApplicationConfig/components/ToolList.tsx b/web/src/views/ApplicationConfig/components/ToolList.tsx index 9834b186..fde7286b 100644 --- a/web/src/views/ApplicationConfig/components/ToolList.tsx +++ b/web/src/views/ApplicationConfig/components/ToolList.tsx @@ -79,8 +79,6 @@ const ToolList: FC<{ data: ToolOption[]; onUpdate: (config: ToolOption[]) => voi } }, [data]) - console.log('toolList', toolList) - const handleAddTool = () => { toolModalRef.current?.handleOpen() } From 617ff706bc261f9eb72280e121ae97849926cc93 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Wed, 14 Jan 2026 16:50:20 +0800 Subject: [PATCH 2/2] feat(web): llm node add memory config --- .../components/AddChatVariable/index.tsx | 5 +- .../Properties/HttpRequest/EditableTable.tsx | 2 +- .../Properties/MemoryConfig/index.tsx | 69 +++++++++++++++++++ .../components/Properties/MessageEditor.tsx | 2 +- .../Workflow/components/Properties/index.tsx | 15 ++++ web/src/views/Workflow/constant.ts | 12 ++-- .../views/Workflow/hooks/useWorkflowGraph.ts | 60 +++++++++++----- web/src/views/Workflow/index.tsx | 18 ++--- 8 files changed, 142 insertions(+), 41 deletions(-) create mode 100644 web/src/views/Workflow/components/Properties/MemoryConfig/index.tsx diff --git a/web/src/views/Workflow/components/AddChatVariable/index.tsx b/web/src/views/Workflow/components/AddChatVariable/index.tsx index 7ebce7df..d6741bf9 100644 --- a/web/src/views/Workflow/components/AddChatVariable/index.tsx +++ b/web/src/views/Workflow/components/AddChatVariable/index.tsx @@ -1,6 +1,5 @@ -import React, { useState, useImperativeHandle, forwardRef, useRef } from 'react'; -import { Button, Input, Space, Typography, Tooltip, message, List } from 'antd'; -import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons'; +import { useState, useImperativeHandle, forwardRef, useRef } from 'react'; +import { Button, Space, List } from 'antd'; import { useTranslation } from 'react-i18next'; import type { ChatVariable, AddChatVariableRef } from '../../types'; import type { ChatVariableModalRef } from './types' diff --git a/web/src/views/Workflow/components/Properties/HttpRequest/EditableTable.tsx b/web/src/views/Workflow/components/Properties/HttpRequest/EditableTable.tsx index 251409dd..e0912c0a 100644 --- a/web/src/views/Workflow/components/Properties/HttpRequest/EditableTable.tsx +++ b/web/src/views/Workflow/components/Properties/HttpRequest/EditableTable.tsx @@ -131,7 +131,7 @@ const EditableTable: React.FC = ({ const AddButton = ({ block = false }: { block?: boolean }) => ( diff --git a/web/src/views/Workflow/components/Properties/index.tsx b/web/src/views/Workflow/components/Properties/index.tsx index a555b4fe..8752121e 100644 --- a/web/src/views/Workflow/components/Properties/index.tsx +++ b/web/src/views/Workflow/components/Properties/index.tsx @@ -22,6 +22,7 @@ import ConditionList from './ConditionList' import CycleVarsList from './CycleVarsList' import AssignmentList from './AssignmentList' import ToolConfig from './ToolConfig' +import MemoryConfig from './MemoryConfig' // import { calculateVariableList } from './utils/variableListCalculator' interface PropertiesProps { @@ -1230,6 +1231,20 @@ const Properties: FC = ({ ) } + if (config.type === 'memoryConfig') { + return ( + + + + ) + } return ( boolean | void; parseEvent: () => boolean | void; handleSave: (flag?: boolean) => Promise; + chatVariables: ChatVariable[]; + setChatVariables: React.Dispatch>; } export const edge_color = '#155EEF'; @@ -54,6 +56,7 @@ export const useWorkflowGraph = ({ const [canRedo, setCanRedo] = useState(false); const [isHandMode, setIsHandMode] = useState(false); const [config, setConfig] = useState(null); + const [chatVariables, setChatVariables] = useState([]) useEffect(() => { getConfig() @@ -63,16 +66,15 @@ export const useWorkflowGraph = ({ getWorkflowConfig(id) .then(res => { const { variables, ...rest } = res as WorkflowConfig - setConfig({ - ...rest, - variables: variables.map(v => { - const { default: _, ...cleanV } = v - return { - ...cleanV, - defaultValue: v.default ?? '' - } - }) + const initChatVariables = variables.map(v => { + const { default: _, ...cleanV } = v + return { + ...cleanV, + defaultValue: v.default ?? '' + } }) + setChatVariables(initChatVariables) + setConfig({ ...rest, variables: initChatVariables }) }) } @@ -94,7 +96,17 @@ export const useWorkflowGraph = ({ if (nodeLibraryConfig?.config) { Object.keys(nodeLibraryConfig.config).forEach(key => { - if (key === 'knowledge_retrieval' && nodeLibraryConfig.config && nodeLibraryConfig.config[key]) { + if (key === 'memory' && nodeLibraryConfig.config && nodeLibraryConfig.config[key]) { + const { memory, messages } = config as any; + if (memory?.enable && messages && messages.length > 0) { + const lastMessage = messages[messages.length - 1] + nodeLibraryConfig.config[key].defaultValue = { + ...memory, + messages: lastMessage.content + } + nodeLibraryConfig.config.messages.defaultValue.splice(-1, 1) + } + } else if (key === 'knowledge_retrieval' && nodeLibraryConfig.config && nodeLibraryConfig.config[key]) { const { query, ...rest } = config nodeLibraryConfig.config[key].defaultValue = { ...rest @@ -917,13 +929,13 @@ export const useWorkflowGraph = ({ const params = { ...config, - variables: config.variables.map(v => { - const { defaultValue, ...cleanV } = v - return { - ...cleanV, - default: defaultValue ?? '' - } - }), + variables: chatVariables.map(v => { + const { defaultValue, ...cleanV } = v + return { + ...cleanV, + default: defaultValue ?? '' + } + }), nodes: nodes.map((node: Node) => { const data = node.getData(); const position = node.getPosition(); @@ -931,7 +943,15 @@ export const useWorkflowGraph = ({ if (data.config) { Object.keys(data.config).forEach(key => { - if (data.config[key] && 'defaultValue' in data.config[key] && key === 'group_variables') { + if (key === 'memory' && data.config[key] && 'defaultValue' in data.config[key]) { + const { messages, ...rest } = data.config[key].defaultValue + let memoryMessage = { role: 'USER', content: data.config[key].defaultValue.messages } + itemConfig = { + ...itemConfig, + messages: rest.enable ? [...itemConfig.messages, memoryMessage] : itemConfig.messages, + memory: { ...rest }, + } + } else if (data.config[key] && 'defaultValue' in data.config[key] && key === 'group_variables') { let group_variables = data.config.group.defaultValue ? {} : data.config[key].defaultValue if (data.config.group.defaultValue) { data.config[key].defaultValue.map((vo: any) => { @@ -1077,5 +1097,7 @@ export const useWorkflowGraph = ({ copyEvent, parseEvent, handleSave, + chatVariables, + setChatVariables }; }; diff --git a/web/src/views/Workflow/index.tsx b/web/src/views/Workflow/index.tsx index 70803373..ba17a63a 100644 --- a/web/src/views/Workflow/index.tsx +++ b/web/src/views/Workflow/index.tsx @@ -8,7 +8,7 @@ import PortClickHandler from './components/PortClickHandler'; import { useWorkflowGraph } from './hooks/useWorkflowGraph'; import type { WorkflowRef } from '@/views/ApplicationConfig/types' import Chat from './components/Chat/Chat'; -import type { ChatRef, AddChatVariableRef, ChatVariable } from './types' +import type { ChatRef, AddChatVariableRef } from './types' import arrowIcon from '@/assets/images/workflow/arrow.png' import AddChatVariable from './components/AddChatVariable'; @@ -21,7 +21,6 @@ const Workflow = forwardRef((_props, ref) => { // 使用自定义Hook初始化工作流图 const { config, - setConfig, graphRef, selectedNode, setSelectedNode, @@ -38,6 +37,8 @@ const Workflow = forwardRef((_props, ref) => { copyEvent, parseEvent, handleSave, + chatVariables, + setChatVariables } = useWorkflowGraph({ containerRef, miniMapRef }); const onDragOver = (event: React.DragEvent) => { @@ -52,15 +53,6 @@ const Workflow = forwardRef((_props, ref) => { const addVariable = () => { addChatVariableRef.current?.handleOpen() } - const handleUpdateChatVariable = (variables: ChatVariable[]) => { - setConfig(prev => { - if (!prev) return null - return { - ...prev, - variables - } - }) - } useImperativeHandle(ref, () => ({ handleSave, @@ -125,8 +117,8 @@ const Workflow = forwardRef((_props, ref) => { );