diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index a08407a6..8f33f43c 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -324,7 +324,8 @@ export const en = { loginApiCannotRefreshToken: 'Login API cannot refresh token', logoutApiCannotRefreshToken: 'Logout API cannot refresh token', publicApiCannotRefreshToken: 'Public API cannot refresh token', - refreshTokenNotExist: 'Refresh token does not exist' + refreshTokenNotExist: 'Refresh token does not exist', + reset: 'Reset', }, model: { searchPlaceholder: 'search model…', diff --git a/web/src/views/Workflow/components/Chat/Chat.tsx b/web/src/views/Workflow/components/Chat/Chat.tsx index 340f4f31..b81f5fae 100644 --- a/web/src/views/Workflow/components/Chat/Chat.tsx +++ b/web/src/views/Workflow/components/Chat/Chat.tsx @@ -13,14 +13,14 @@ import ChatContent from '@/components/Chat/ChatContent' import type { ChatItem } from '@/components/Chat/types' import ChatSendIcon from '@/assets/images/application/chatSend.svg' import dayjs from 'dayjs' -import type { ChatRef, VariableEditModalRef, StartVariableItem, GraphRef } from '../../types' +import type { ChatRef, VariableConfigModalRef, StartVariableItem, GraphRef } from '../../types' import { type SSEMessage } from '@/utils/stream' const Chat = forwardRef(({ appId, graphRef }, ref) => { const { t } = useTranslation() const { message: messageApi } = App.useApp() const [form] = Form.useForm<{ message: string }>() - const variableConfigModalRef = useRef(null) + const variableConfigModalRef = useRef(null) const [open, setOpen] = useState(false) const [loading, setLoading] = useState(false) const [chatList, setChatList] = useState([]) @@ -38,15 +38,16 @@ const Chat = forwardRef(({ appId if (startNodes.length) { const curVariables = startNodes[0].config.variables?.defaultValue - const initialValue: Record = {} - curVariables.forEach((vo: StartVariableItem) => { if (vo.default) { - initialValue[vo.name] = vo.default + vo.value = vo.default + } + const lastVo = variables.find(item => item.name === vo.name) + if (lastVo?.value) { + vo.value = lastVo.value } }) setVariables(curVariables) - form.setFieldsValue(initialValue) } } const handleClose = () => { @@ -114,6 +115,15 @@ const Chat = forwardRef(({ appId }) break case 'workflow_end': + setChatList(prev => { + const lastChat = { ...prev[prev.length - 1] } + lastChat.content = lastChat.content === '' ? null : lastChat.content + + return [ + ...prev.slice(0, prev.length - 1), + lastChat + ] + }) setStreamLoading(false); break; } diff --git a/web/src/views/Workflow/components/Chat/VariableConfigModal.tsx b/web/src/views/Workflow/components/Chat/VariableConfigModal.tsx index fd422b42..d262048e 100644 --- a/web/src/views/Workflow/components/Chat/VariableConfigModal.tsx +++ b/web/src/views/Workflow/components/Chat/VariableConfigModal.tsx @@ -2,7 +2,7 @@ import { forwardRef, useImperativeHandle, useState } from 'react'; import { Form, Input, InputNumber, Checkbox } from 'antd'; import { useTranslation } from 'react-i18next'; -import type { StartVariableItem, VariableEditModalRef } from '../../types' +import type { StartVariableItem, VariableConfigModalRef } from '../../types' import RbModal from '@/components/RbModal' interface VariableEditModalProps { @@ -10,7 +10,7 @@ interface VariableEditModalProps { variables: StartVariableItem[] } -const VariableConfigModal = forwardRef(({ +const VariableConfigModal = forwardRef(({ refresh, }, ref) => { const { t } = useTranslation(); diff --git a/web/src/views/Workflow/components/Nodes/NormalNode.tsx b/web/src/views/Workflow/components/Nodes/NormalNode.tsx index 80eae888..17c55494 100644 --- a/web/src/views/Workflow/components/Nodes/NormalNode.tsx +++ b/web/src/views/Workflow/components/Nodes/NormalNode.tsx @@ -19,7 +19,10 @@ const NormalNode: ReactShapeConfig['component'] = ({ node }) => {
{}} + onClick={(e) => { + e.stopPropagation() + node.remove() + }} >
diff --git a/web/src/views/Workflow/components/Properties/VariableEditModal.tsx b/web/src/views/Workflow/components/Properties/VariableEditModal.tsx index 92c31140..61490fcd 100644 --- a/web/src/views/Workflow/components/Properties/VariableEditModal.tsx +++ b/web/src/views/Workflow/components/Properties/VariableEditModal.tsx @@ -26,6 +26,10 @@ const variableType = { // array: 'array', // object: 'object', } +const initialValues = { + max_length: 48, + required: true +} const VariableEditModal = forwardRef(({ refresh @@ -71,17 +75,12 @@ const VariableEditModal = forwardRef { - if (value) { - form.setFieldsValue({ - type: value, - name: undefined, - description: undefined, - max_length: undefined, - default: undefined - }) - } + const nameChange = (e: React.ChangeEvent) => { + if (values.description && values.description !== '') return + const { value } = e.target + form.setFieldsValue({ + description: value, + }) } return ( @@ -96,6 +95,7 @@ const VariableEditModal = forwardRef {/* 变量类型 */} @@ -110,7 +110,6 @@ const VariableEditModal = forwardRef
{props.label} {variableType[props.value as keyof typeof variableType]}
} optionRender={(props) =>
{props.label} {variableType[props.value as keyof typeof variableType]}
} /> @@ -124,7 +123,7 @@ const VariableEditModal = forwardRef - + {/* 显示名称 */} diff --git a/web/src/views/Workflow/components/Properties/index.tsx b/web/src/views/Workflow/components/Properties/index.tsx index bc9a7113..717df355 100644 --- a/web/src/views/Workflow/components/Properties/index.tsx +++ b/web/src/views/Workflow/components/Properties/index.tsx @@ -63,7 +63,7 @@ const Properties: FC = ({ const { id, ...rest } = values Object.keys(values).forEach(key => { - if (selectedNode.data.config[key]) { + if (selectedNode.data?.config[key]) { selectedNode.data.config[key].defaultValue = values[key] } }) @@ -132,7 +132,7 @@ const Properties: FC = ({ {configs && Object.keys(configs).length > 0 && Object.keys(configs).map((key) => { const config = configs[key] || {} - if (selectedNode.data.type === 'start' && key === 'variables' && config.type === 'define') { + if (selectedNode.data?.type === 'start' && key === 'variables' && config.type === 'define') { return (
@@ -177,7 +177,7 @@ const Properties: FC = ({ ) } - if (selectedNode.data.type === 'llm' && key === 'messages' && config.type === 'define') { + if (selectedNode.data?.type === 'llm' && key === 'messages' && config.type === 'define') { return ( diff --git a/web/src/views/Workflow/hooks/useWorkflowGraph.ts b/web/src/views/Workflow/hooks/useWorkflowGraph.ts index 564d75c8..1e652a7b 100644 --- a/web/src/views/Workflow/hooks/useWorkflowGraph.ts +++ b/web/src/views/Workflow/hooks/useWorkflowGraph.ts @@ -83,8 +83,8 @@ export const useWorkflowGraph = ({ if (nodeLibraryConfig?.config) { Object.keys(nodeLibraryConfig.config).forEach(key => { - if (nodeLibraryConfig.config && nodeLibraryConfig.config[key]) { - nodeLibraryConfig.config[key].defaultValue = config[key] || {} + if (nodeLibraryConfig.config && nodeLibraryConfig.config[key] && config[key]) { + nodeLibraryConfig.config[key].defaultValue = config[key] } }) } diff --git a/web/src/views/Workflow/types.ts b/web/src/views/Workflow/types.ts index 6debcad6..fb7a05a4 100644 --- a/web/src/views/Workflow/types.ts +++ b/web/src/views/Workflow/types.ts @@ -75,7 +75,7 @@ export interface WorkflowConfig { } export interface VariableEditModalRef { - handleOpen: (values: StartVariableItem[]) => void; + handleOpen: (values?: StartVariableItem) => void; } export interface StartVariableItem { name: string; @@ -92,4 +92,7 @@ export interface StartVariableItem { export interface ChatRef { handleOpen: () => void; } -export type GraphRef = React.MutableRefObject \ No newline at end of file +export type GraphRef = React.MutableRefObject +export interface VariableConfigModalRef { + handleOpen: (values: StartVariableItem[]) => void; +} \ No newline at end of file