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
@@ -93,6 +93,13 @@ class XMLAgent_Agents implements INode {
type: 'Moderation',
optional: true,
list: true
},
{
label: 'Max Iterations',
name: 'maxIterations',
type: 'number',
optional: true,
additionalParams: true
}
]
this.sessionId = fields?.sessionId
@@ -179,6 +186,7 @@ class XMLAgent_Agents implements INode {
const prepareAgent = async (nodeData: INodeData, flowObj: { sessionId?: string; chatId?: string; input?: string }) => {
const model = nodeData.inputs?.model as BaseChatModel
const maxIterations = nodeData.inputs?.maxIterations as string
const memory = nodeData.inputs?.memory as FlowiseMemory
const systemMessage = nodeData.inputs?.systemMessage as string
let tools = nodeData.inputs?.tools
@@ -233,7 +241,8 @@ const prepareAgent = async (nodeData: INodeData, flowObj: { sessionId?: string;
chatId: flowObj?.chatId,
input: flowObj?.input,
isXML: true,
verbose: process.env.DEBUG === 'true' ? true : false
verbose: process.env.DEBUG === 'true' ? true : false,
maxIterations: maxIterations ? parseFloat(maxIterations) : undefined
})
return executor