mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
Bugfix/Disable default user input if memory is disabled for first node (#4530)
disable default user input if memory is disabled for first node
This commit is contained in:
@@ -756,7 +756,7 @@ class Agent_Agentflow implements INode {
|
|||||||
/*
|
/*
|
||||||
* If this is the first node:
|
* If this is the first node:
|
||||||
* - Add images to messages if exist
|
* - Add images to messages if exist
|
||||||
* - Add user message
|
* - Add user message if it does not exist in the agentMessages array
|
||||||
*/
|
*/
|
||||||
if (options.uploads) {
|
if (options.uploads) {
|
||||||
const imageContents = await getUniqueImageMessages(options, messages, modelConfig)
|
const imageContents = await getUniqueImageMessages(options, messages, modelConfig)
|
||||||
@@ -767,7 +767,7 @@ class Agent_Agentflow implements INode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input && typeof input === 'string') {
|
if (input && typeof input === 'string' && !agentMessages.some((msg) => msg.role === 'user')) {
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: input
|
content: input
|
||||||
@@ -977,7 +977,19 @@ class Agent_Agentflow implements INode {
|
|||||||
inputMessages.push(...runtimeImageMessagesWithFileRef)
|
inputMessages.push(...runtimeImageMessagesWithFileRef)
|
||||||
}
|
}
|
||||||
if (input && typeof input === 'string') {
|
if (input && typeof input === 'string') {
|
||||||
|
if (!enableMemory) {
|
||||||
|
if (!agentMessages.some((msg) => msg.role === 'user')) {
|
||||||
inputMessages.push({ role: 'user', content: input })
|
inputMessages.push({ role: 'user', content: input })
|
||||||
|
} else {
|
||||||
|
agentMessages.map((msg) => {
|
||||||
|
if (msg.role === 'user') {
|
||||||
|
inputMessages.push({ role: 'user', content: msg.content })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputMessages.push({ role: 'user', content: input })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ class LLM_Agentflow implements INode {
|
|||||||
/*
|
/*
|
||||||
* If this is the first node:
|
* If this is the first node:
|
||||||
* - Add images to messages if exist
|
* - Add images to messages if exist
|
||||||
* - Add user message
|
* - Add user message if it does not exist in the llmMessages array
|
||||||
*/
|
*/
|
||||||
if (options.uploads) {
|
if (options.uploads) {
|
||||||
const imageContents = await getUniqueImageMessages(options, messages, modelConfig)
|
const imageContents = await getUniqueImageMessages(options, messages, modelConfig)
|
||||||
@@ -421,7 +421,7 @@ class LLM_Agentflow implements INode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input && typeof input === 'string') {
|
if (input && typeof input === 'string' && !llmMessages.some((msg) => msg.role === 'user')) {
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: input
|
content: input
|
||||||
@@ -545,7 +545,19 @@ class LLM_Agentflow implements INode {
|
|||||||
inputMessages.push(...runtimeImageMessagesWithFileRef)
|
inputMessages.push(...runtimeImageMessagesWithFileRef)
|
||||||
}
|
}
|
||||||
if (input && typeof input === 'string') {
|
if (input && typeof input === 'string') {
|
||||||
|
if (!enableMemory) {
|
||||||
|
if (!llmMessages.some((msg) => msg.role === 'user')) {
|
||||||
inputMessages.push({ role: 'user', content: input })
|
inputMessages.push({ role: 'user', content: input })
|
||||||
|
} else {
|
||||||
|
llmMessages.map((msg) => {
|
||||||
|
if (msg.role === 'user') {
|
||||||
|
inputMessages.push({ role: 'user', content: msg.content })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputMessages.push({ role: 'user', content: input })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user