Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: send message error when chatting with opening statement (#8627)

Hash Brown2d869d68313d
diff --git a/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx b/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx
index 80e7c98a8f0..5faef46d988 100644
--- a/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx
+++ b/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx
@@ -83,11 +83,17 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
},
}
+ const lastAnswer = chatListRef.current.at(-1)
+
const data: any = {
query: message,
inputs,
model_config: configData,
- parent_message_id: last_answer?.id || chatListRef.current.at(-1)?.id || null,
+ parent_message_id: last_answer?.id || (lastAnswer
+ ? lastAnswer.isOpeningStatement
+ ? null
+ : lastAnswer.id
+ : null),
}
if (visionConfig.enabled && files?.length && supportVision)
diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
index 79f6008d136..225bbac7140 100644
--- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
+++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
@@ -67,11 +67,17 @@ const ChatWrapper = () => {
}, [])
const doSend: OnSend = useCallback((message, files, last_answer) => {
+ const lastAnswer = chatListRef.current.at(-1)
+
const data: any = {
query: message,
inputs: currentConversationId ? currentConversationItem?.inputs : newConversationInputs,
conversation_id: currentConversationId,
- parent_message_id: last_answer?.id || chatListRef.current.at(-1)?.id || null,
+ parent_message_id: last_answer?.id || (lastAnswer
+ ? lastAnswer.isOpeningStatement
+ ? null
+ : lastAnswer.id
+ : null),
}
if (appConfig?.file_upload?.image.enabled && files?.length)
diff --git a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
index 8cb546fd52a..ed2f24274dc 100644
--- a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
@@ -69,11 +69,17 @@ const ChatWrapper = () => {
}, [])
const doSend: OnSend = useCallback((message, files, last_answer) => {
+ const lastAnswer = chatListRef.current.at(-1)
+
const data: any = {
query: message,
inputs: currentConversationId ? currentConversationItem?.inputs : newConversationInputs,
conversation_id: currentConversationId,
- parent_message_id: last_answer?.id || chatListRef.current.at(-1)?.id || null,
+ parent_message_id: last_answer?.id || (lastAnswer
+ ? lastAnswer.isOpeningStatement
+ ? null
+ : lastAnswer.id
+ : null),
}
if (appConfig?.file_upload?.image.enabled && files?.length)
diff --git a/web/app/components/workflow/panel/debug-and-preview/chat-wrapper.tsx b/web/app/components/workflow/panel/debug-and-preview/chat-wrapper.tsx
index 107a5dc698f..86519af6035 100644
--- a/web/app/components/workflow/panel/debug-and-preview/chat-wrapper.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/chat-wrapper.tsx
@@ -76,13 +76,19 @@ const ChatWrapper = forwardRef<ChatWrapperRefType, ChatWrapperProps>(({ showConv
)
const doSend = useCallback<OnSend>((query, files, last_answer) => {
+ const lastAnswer = chatListRef.current.at(-1)
+
handleSend(
{
query,
files,
inputs: workflowStore.getState().inputs,
conversation_id: conversationId,
- parent_message_id: last_answer?.id || chatListRef.current.at(-1)?.id || null,
+ parent_message_id: last_answer?.id || (lastAnswer
+ ? lastAnswer.isOpeningStatement
+ ? null
+ : lastAnswer.id
+ : null),
},
{
onGetSuggestedQuestions: (messageId, getAbortController) => fetchSuggestedQuestions(appDetail!.id, messageId, getAbortController),