From 443fee853731f3b3ff964d6b9ce0cadddc243145 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 16 Apr 2024 12:11:34 +0800 Subject: [PATCH] fix: add message caused problem after simple chat convert to workflow (#3511) --- .../workflow/nodes/llm/components/config-prompt.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/app/components/workflow/nodes/llm/components/config-prompt.tsx b/web/app/components/workflow/nodes/llm/components/config-prompt.tsx index 87671e6db5..d08fa000f3 100644 --- a/web/app/components/workflow/nodes/llm/components/config-prompt.tsx +++ b/web/app/components/workflow/nodes/llm/components/config-prompt.tsx @@ -67,6 +67,11 @@ const ConfigPrompt: FC = ({ const handleAddPrompt = useCallback(() => { const newPrompt = produce(payload as PromptItem[], (draft) => { + if (draft.length === 0) { + draft.push({ role: PromptRole.system, text: '' }) + + return + } const isLastItemUser = draft[draft.length - 1].role === PromptRole.user draft.push({ role: isLastItemUser ? PromptRole.assistant : PromptRole.user, text: '' }) })