Feature/add max iterations to agents (#2161)

add max iterations to agents
This commit is contained in:
Henry Heng
2024-04-12 00:04:19 +01:00
committed by GitHub
parent e7a58fc700
commit a82dd93c6c
8 changed files with 80 additions and 8 deletions
@@ -86,6 +86,13 @@ class ConversationalAgent_Agents implements INode {
type: 'Moderation',
optional: true,
list: true
},
{
label: 'Max Iterations',
name: 'maxIterations',
type: 'number',
optional: true,
additionalParams: true
}
]
this.sessionId = fields?.sessionId
@@ -176,6 +183,7 @@ const prepareAgent = async (
flowObj: { sessionId?: string; chatId?: string; input?: string }
) => {
const model = nodeData.inputs?.model as BaseChatModel
const maxIterations = nodeData.inputs?.maxIterations as string
let tools = nodeData.inputs?.tools as Tool[]
tools = flatten(tools)
const memory = nodeData.inputs?.memory as FlowiseMemory
@@ -247,7 +255,8 @@ const prepareAgent = async (
sessionId: flowObj?.sessionId,
chatId: flowObj?.chatId,
input: flowObj?.input,
verbose: process.env.DEBUG === 'true'
verbose: process.env.DEBUG === 'true',
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
})
return executor