mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +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
|
||||
|
||||
+12
-14
@@ -1,6 +1,10 @@
|
||||
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 { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class MRLKAgentChat_Agents implements INode {
|
||||
class MRKLAgentChat_Agents implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -11,12 +15,13 @@ class MRLKAgentChat_Agents implements INode {
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'MRLK Agent for Chat Models'
|
||||
this.name = 'mrlkAgentChat'
|
||||
this.label = 'MRKL Agent for Chat Models'
|
||||
this.name = 'mrklAgentChat'
|
||||
this.type = 'AgentExecutor'
|
||||
this.category = 'Agents'
|
||||
this.icon = 'agent.svg'
|
||||
this.description = 'Agent that uses the ReAct Framework to decide what action to take, optimized to be used with Chat Models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -32,27 +37,20 @@ class MRLKAgentChat_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 model = nodeData.inputs?.model as BaseChatModel
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'chat-zero-shot-react-description', true)
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MRLKAgentChat_Agents }
|
||||
module.exports = { nodeClass: MRKLAgentChat_Agents }
|
||||
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
+13
-15
@@ -1,6 +1,10 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutor, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseLLM } from 'langchain/llms/base'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class MRLKAgentLLM_Agents implements INode {
|
||||
class MRKLAgentLLM_Agents implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
@@ -11,12 +15,13 @@ class MRLKAgentLLM_Agents implements INode {
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'MRLK Agent for LLMs'
|
||||
this.name = 'mrlkAgentLLM'
|
||||
this.label = 'MRKL Agent for LLMs'
|
||||
this.name = 'mrklAgentLLM'
|
||||
this.type = 'AgentExecutor'
|
||||
this.category = 'Agents'
|
||||
this.icon = 'agent.svg'
|
||||
this.description = 'Agent that uses the ReAct Framework to decide what action to take, optimized to be used with LLMs'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
@@ -27,32 +32,25 @@ class MRLKAgentLLM_Agents implements INode {
|
||||
{
|
||||
label: 'LLM Model',
|
||||
name: 'model',
|
||||
type: 'BaseLanguageModel'
|
||||
type: 'BaseLLM'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
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 model = nodeData.inputs?.model as BaseLLM
|
||||
const tools = nodeData.inputs?.tools as Tool[]
|
||||
|
||||
const executor = await initializeAgentExecutor(tools, model, 'zero-shot-react-description', true)
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MRLKAgentLLM_Agents }
|
||||
module.exports = { nodeClass: MRKLAgentLLM_Agents }
|
||||
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
Reference in New Issue
Block a user