mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
- update LangchainJS version
- add types & interfaces - small ui bug fix - update marketplace files
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { BaseChatMemory } from 'langchain/memory'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class ConversationalAgent_Agents implements INode {
|
||||
label: string
|
||||
@@ -17,6 +22,7 @@ class ConversationalAgent_Agents implements INode {
|
||||
this.category = 'Agents'
|
||||
this.icon = 'agent.svg'
|
||||
this.description = 'Conversational agent for a chat model. It will utilize chat specific prompts'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -37,16 +43,10 @@ class ConversationalAgent_Agents implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async getBaseClasses(): Promise<string[]> {
|
||||
return ['AgentExecutor']
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const { initializeAgentExecutor } = await import('langchain/agents')
|
||||
|
||||
const model = nodeData.inputs?.model
|
||||
const tools = nodeData.inputs?.tools
|
||||
const memory = nodeData.inputs?.memory
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'chat-conversational-react-description', true)
|
||||
executor.memory = memory
|
||||
@@ -54,7 +54,7 @@ class ConversationalAgent_Agents implements INode {
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string): Promise<string> {
|
||||
const executor = nodeData.instance
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const result = await executor.call({ input })
|
||||
|
||||
return result?.output
|
||||
|
||||
Reference in New Issue
Block a user