mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
add additional params
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/agents'
|
||||
import { initializeAgentExecutorWithOptions, AgentExecutor, InitializeAgentExecutorOptions } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { BaseChatMemory } from 'langchain/memory'
|
||||
@@ -39,6 +39,22 @@ class ConversationalAgent_Agents implements INode {
|
||||
label: 'Memory',
|
||||
name: 'memory',
|
||||
type: 'BaseChatMemory'
|
||||
},
|
||||
{
|
||||
label: 'System Message',
|
||||
name: 'systemMessage',
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Human Message',
|
||||
name: 'humanMessage',
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -47,11 +63,25 @@ class ConversationalAgent_Agents implements INode {
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||
const humanMessage = nodeData.inputs?.humanMessage as string
|
||||
const systemMessage = nodeData.inputs?.systemMessage as string
|
||||
|
||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||
const obj: InitializeAgentExecutorOptions = {
|
||||
agentType: 'chat-conversational-react-description',
|
||||
verbose: true
|
||||
})
|
||||
}
|
||||
|
||||
const agentArgs: any = {}
|
||||
if (humanMessage) {
|
||||
agentArgs.humanMessage = humanMessage
|
||||
}
|
||||
if (systemMessage) {
|
||||
agentArgs.systemMessage = systemMessage
|
||||
}
|
||||
|
||||
if (Object.keys(agentArgs).length) obj.agentArgs = agentArgs
|
||||
|
||||
const executor = await initializeAgentExecutorWithOptions(tools, model, obj)
|
||||
executor.memory = memory
|
||||
return executor
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface INodeParams {
|
||||
acceptVariable?: boolean
|
||||
placeholder?: string
|
||||
fileType?: string
|
||||
additionalParams?: boolean
|
||||
}
|
||||
|
||||
export interface INodeExecutionData {
|
||||
|
||||
Reference in New Issue
Block a user