Преглед на файлове

fix: add message caused problem after simple chat convert to workflow (#3511)

Joel преди 1 година
родител
ревизия
443fee8537
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      web/app/components/workflow/nodes/llm/components/config-prompt.tsx

+ 5 - 0
web/app/components/workflow/nodes/llm/components/config-prompt.tsx

@@ -67,6 +67,11 @@ const ConfigPrompt: FC<Props> = ({
 
   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: '' })
     })