diff --git a/packages/components/nodes/agents/MistralAIFunctionAgent/MistralAI.svg b/packages/components/nodes/agents/MistralAIToolAgent/MistralAI.svg similarity index 100% rename from packages/components/nodes/agents/MistralAIFunctionAgent/MistralAI.svg rename to packages/components/nodes/agents/MistralAIToolAgent/MistralAI.svg diff --git a/packages/components/nodes/agents/MistralAIFunctionAgent/MistralAIFunctionAgent.ts b/packages/components/nodes/agents/MistralAIToolAgent/MistralAIToolAgent.ts similarity index 95% rename from packages/components/nodes/agents/MistralAIFunctionAgent/MistralAIFunctionAgent.ts rename to packages/components/nodes/agents/MistralAIToolAgent/MistralAIToolAgent.ts index 3bc36ed390..f4a33a3883 100644 --- a/packages/components/nodes/agents/MistralAIFunctionAgent/MistralAIFunctionAgent.ts +++ b/packages/components/nodes/agents/MistralAIToolAgent/MistralAIToolAgent.ts @@ -14,7 +14,7 @@ import { AgentExecutor, formatAgentSteps } from '../../../src/agents' import { Moderation, checkInputs, streamResponse } from '../../moderation/Moderation' import { formatResponse } from '../../outputparsers/OutputParserHelpers' -class MistralAIFunctionAgent_Agents implements INode { +class MistralAIToolAgent_Agents implements INode { label: string name: string version: number @@ -28,14 +28,14 @@ class MistralAIFunctionAgent_Agents implements INode { badge?: string constructor(fields?: { sessionId?: string }) { - this.label = 'MistralAI Function Agent' - this.name = 'mistralAIFunctionAgent' + this.label = 'MistralAI Tool Agent' + this.name = 'mistralAIToolAgent' this.version = 1.0 this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'MistralAI.svg' this.badge = 'NEW' - this.description = `An agent that uses MistralAI Function Calling to pick the tool and args to call` + this.description = `Agent that uses MistralAI Function Calling to pick the tools and args to call` this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] this.inputs = [ { @@ -204,4 +204,4 @@ const prepareAgent = ( return executor } -module.exports = { nodeClass: MistralAIFunctionAgent_Agents } +module.exports = { nodeClass: MistralAIToolAgent_Agents } diff --git a/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts b/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts index aa40fc45a8..7d7cb13007 100644 --- a/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts +++ b/packages/components/nodes/agents/OpenAIFunctionAgent/OpenAIFunctionAgent.ts @@ -23,6 +23,7 @@ class OpenAIFunctionAgent_Agents implements INode { category: string baseClasses: string[] inputs: INodeParams[] + badge?: string sessionId?: string constructor(fields?: { sessionId?: string }) { @@ -32,8 +33,9 @@ class OpenAIFunctionAgent_Agents implements INode { this.type = 'AgentExecutor' this.category = 'Agents' this.icon = 'function.svg' - this.description = `An agent that uses Function Calling to pick the tool and args to call` + this.description = `An agent that uses OpenAI Function Calling to pick the tool and args to call` this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] + this.badge = 'DEPRECATING' this.inputs = [ { label: 'Allowed Tools', diff --git a/packages/components/nodes/agents/OpenAIToolAgent/OpenAIToolAgent.ts b/packages/components/nodes/agents/OpenAIToolAgent/OpenAIToolAgent.ts new file mode 100644 index 0000000000..acafb0c586 --- /dev/null +++ b/packages/components/nodes/agents/OpenAIToolAgent/OpenAIToolAgent.ts @@ -0,0 +1,205 @@ +import { flatten } from 'lodash' +import { BaseMessage } from '@langchain/core/messages' +import { ChainValues } from '@langchain/core/utils/types' +import { RunnableSequence } from '@langchain/core/runnables' +import { ChatOpenAI } from '@langchain/openai' +import { ChatPromptTemplate, MessagesPlaceholder } from '@langchain/core/prompts' +import { convertToOpenAITool } from '@langchain/core/utils/function_calling' +import { formatToOpenAIToolMessages } from 'langchain/agents/format_scratchpad/openai_tools' +import { OpenAIToolsAgentOutputParser, type ToolsAgentStep } from 'langchain/agents/openai/output_parser' +import { getBaseClasses } from '../../../src/utils' +import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, IUsedTool } from '../../../src/Interface' +import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler' +import { AgentExecutor } from '../../../src/agents' +import { Moderation, checkInputs } from '../../moderation/Moderation' +import { formatResponse } from '../../outputparsers/OutputParserHelpers' + +class OpenAIToolAgent_Agents implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + inputs: INodeParams[] + sessionId?: string + badge?: string + + constructor(fields?: { sessionId?: string }) { + this.label = 'OpenAI Tool Agent' + this.name = 'openAIToolAgent' + this.version = 1.0 + this.type = 'AgentExecutor' + this.category = 'Agents' + this.icon = 'function.svg' + this.description = `Agent that uses OpenAI Function Calling to pick the tools and args to call` + this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)] + this.badge = 'NEW' + this.inputs = [ + { + label: 'Tools', + name: 'tools', + type: 'Tool', + list: true + }, + { + label: 'Memory', + name: 'memory', + type: 'BaseChatMemory' + }, + { + label: 'OpenAI/Azure Chat Model', + name: 'model', + type: 'BaseChatModel' + }, + { + label: 'System Message', + name: 'systemMessage', + type: 'string', + rows: 4, + optional: true, + additionalParams: true + }, + { + label: 'Input Moderation', + description: 'Detect text that could generate harmful output and prevent it from being sent to the language model', + name: 'inputModeration', + type: 'Moderation', + optional: true, + list: true + } + ] + this.sessionId = fields?.sessionId + } + + async init(nodeData: INodeData, input: string, options: ICommonObject): Promise { + return prepareAgent(nodeData, { sessionId: this.sessionId, chatId: options.chatId, input }, options.chatHistory) + } + + async run(nodeData: INodeData, input: string, options: ICommonObject): Promise { + const memory = nodeData.inputs?.memory as FlowiseMemory + const moderations = nodeData.inputs?.inputModeration as Moderation[] + + if (moderations && moderations.length > 0) { + try { + // Use the output of the moderation chain as input for the OpenAI Function Agent + input = await checkInputs(moderations, input) + } catch (e) { + await new Promise((resolve) => setTimeout(resolve, 500)) + //streamResponse(options.socketIO && options.socketIOClientId, e.message, options.socketIO, options.socketIOClientId) + return formatResponse(e.message) + } + } + + const executor = prepareAgent(nodeData, { sessionId: this.sessionId, chatId: options.chatId, input }, options.chatHistory) + + const loggerHandler = new ConsoleCallbackHandler(options.logger) + const callbacks = await additionalCallbacks(nodeData, options) + + let res: ChainValues = {} + let sourceDocuments: ICommonObject[] = [] + let usedTools: IUsedTool[] = [] + + if (options.socketIO && options.socketIOClientId) { + const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId) + res = await executor.invoke({ input }, { callbacks: [loggerHandler, handler, ...callbacks] }) + if (res.sourceDocuments) { + options.socketIO.to(options.socketIOClientId).emit('sourceDocuments', flatten(res.sourceDocuments)) + sourceDocuments = res.sourceDocuments + } + if (res.usedTools) { + options.socketIO.to(options.socketIOClientId).emit('usedTools', res.usedTools) + usedTools = res.usedTools + } + } else { + res = await executor.invoke({ input }, { callbacks: [loggerHandler, ...callbacks] }) + if (res.sourceDocuments) { + sourceDocuments = res.sourceDocuments + } + if (res.usedTools) { + usedTools = res.usedTools + } + } + + await memory.addChatMessages( + [ + { + text: input, + type: 'userMessage' + }, + { + text: res?.output, + type: 'apiMessage' + } + ], + this.sessionId + ) + + let finalRes = res?.output + + if (sourceDocuments.length || usedTools.length) { + finalRes = { text: res?.output } + if (sourceDocuments.length) { + finalRes.sourceDocuments = flatten(sourceDocuments) + } + if (usedTools.length) { + finalRes.usedTools = usedTools + } + return finalRes + } + + return finalRes + } +} + +const prepareAgent = ( + nodeData: INodeData, + flowObj: { sessionId?: string; chatId?: string; input?: string }, + chatHistory: IMessage[] = [] +) => { + const model = nodeData.inputs?.model as ChatOpenAI + const memory = nodeData.inputs?.memory as FlowiseMemory + const systemMessage = nodeData.inputs?.systemMessage as string + let tools = nodeData.inputs?.tools + tools = flatten(tools) + const memoryKey = memory.memoryKey ? memory.memoryKey : 'chat_history' + const inputKey = memory.inputKey ? memory.inputKey : 'input' + + const prompt = ChatPromptTemplate.fromMessages([ + ['system', systemMessage ? systemMessage : `You are a helpful AI assistant.`], + new MessagesPlaceholder(memoryKey), + ['human', `{${inputKey}}`], + new MessagesPlaceholder('agent_scratchpad') + ]) + + const modelWithTools = model.bind({ tools: tools.map(convertToOpenAITool) }) + + const runnableAgent = RunnableSequence.from([ + { + [inputKey]: (i: { input: string; steps: ToolsAgentStep[] }) => i.input, + agent_scratchpad: (i: { input: string; steps: ToolsAgentStep[] }) => formatToOpenAIToolMessages(i.steps), + [memoryKey]: async (_: { input: string; steps: ToolsAgentStep[] }) => { + const messages = (await memory.getChatMessages(flowObj?.sessionId, true, chatHistory)) as BaseMessage[] + return messages ?? [] + } + }, + prompt, + modelWithTools, + new OpenAIToolsAgentOutputParser() + ]) + + const executor = AgentExecutor.fromAgentAndTools({ + agent: runnableAgent, + tools, + sessionId: flowObj?.sessionId, + chatId: flowObj?.chatId, + input: flowObj?.input, + verbose: process.env.DEBUG === 'true' ? true : false + }) + + return executor +} + +module.exports = { nodeClass: OpenAIToolAgent_Agents } diff --git a/packages/components/nodes/agents/OpenAIToolAgent/function.svg b/packages/components/nodes/agents/OpenAIToolAgent/function.svg new file mode 100644 index 0000000000..9e283b91ff --- /dev/null +++ b/packages/components/nodes/agents/OpenAIToolAgent/function.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/packages/server/marketplaces/chatflows/API Agent OpenAI.json b/packages/server/marketplaces/chatflows/API Agent OpenAI.json index a0c380b4ad..33d66bb2e3 100644 --- a/packages/server/marketplaces/chatflows/API Agent OpenAI.json +++ b/packages/server/marketplaces/chatflows/API Agent OpenAI.json @@ -1,11 +1,11 @@ { - "description": "Use OpenAI Function Agent and Chain to automatically decide which API to call, generating url and body request from conversation", - "categories": "Buffer Memory,ChainTool,API Chain,ChatOpenAI,OpenAI Function Agent,Langchain", + "description": "Use OpenAI Tool Agent and Chain to automatically decide which API to call, generating url and body request from conversation", + "categories": "Buffer Memory,ChainTool,API Chain,ChatOpenAI,OpenAI Tool Agent,Langchain", "framework": "Langchain", "nodes": [ { "width": 300, - "height": 491, + "height": 540, "id": "openApiChain_1", "position": { "x": 1203.1825726424859, @@ -90,7 +90,7 @@ }, { "width": 300, - "height": 574, + "height": 670, "id": "chatOpenAI_1", "position": { "x": 792.3201947594027, @@ -324,7 +324,7 @@ }, { "width": 300, - "height": 602, + "height": 601, "id": "chainTool_0", "position": { "x": 1635.3466862861876, @@ -375,7 +375,7 @@ "inputs": { "name": "comic-qa", "description": "useful for when you need to ask question about comic", - "returnDirect": "", + "returnDirect": false, "baseChain": "{{openApiChain_1.data.instance}}" }, "outputAnchors": [ @@ -398,91 +398,7 @@ }, { "width": 300, - "height": 383, - "id": "openAIFunctionAgent_0", - "position": { - "x": 2076.1829525256576, - "y": 706.1299276365058 - }, - "type": "customNode", - "data": { - "id": "openAIFunctionAgent_0", - "label": "OpenAI Function Agent", - "name": "openAIFunctionAgent", - "version": 4, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain"], - "category": "Agents", - "description": "An agent that uses OpenAI's Function Calling functionality to pick the tool and args to call", - "inputParams": [ - { - "label": "System Message", - "name": "systemMessage", - "type": "string", - "rows": 4, - "optional": true, - "additionalParams": true, - "id": "openAIFunctionAgent_0-input-systemMessage-string" - } - ], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "openAIFunctionAgent_0-input-tools-Tool" - }, - { - "label": "Memory", - "name": "memory", - "type": "BaseChatMemory", - "id": "openAIFunctionAgent_0-input-memory-BaseChatMemory" - }, - { - "label": "OpenAI/Azure Chat Model", - "name": "model", - "type": "BaseChatModel", - "id": "openAIFunctionAgent_0-input-model-BaseChatModel" - }, - { - "label": "Input Moderation", - "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", - "name": "inputModeration", - "type": "Moderation", - "optional": true, - "list": true, - "id": "openAIFunctionAgent_0-input-inputModeration-Moderation" - } - ], - "inputs": { - "inputModeration": "", - "tools": ["{{chainTool_0.data.instance}}"], - "memory": "{{bufferMemory_0.data.instance}}", - "model": "{{chatOpenAI_2.data.instance}}", - "systemMessage": "" - }, - "outputAnchors": [ - { - "id": "openAIFunctionAgent_0-output-openAIFunctionAgent-AgentExecutor|BaseChain", - "name": "openAIFunctionAgent", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 2076.1829525256576, - "y": 706.1299276365058 - }, - "dragging": false - }, - { - "width": 300, - "height": 574, + "height": 670, "id": "chatOpenAI_2", "position": { "x": 1645.450699499575, @@ -769,6 +685,91 @@ "y": 967.8215757228843 }, "selected": false + }, + { + "id": "openAIToolAgent_0", + "position": { + "x": 2083.8842813850474, + "y": 749.3536850926545 + }, + "type": "customNode", + "data": { + "id": "openAIToolAgent_0", + "label": "OpenAI Tool Agent", + "version": 1, + "name": "openAIToolAgent", + "type": "AgentExecutor", + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], + "category": "Agents", + "description": "Agent that uses OpenAI Function Calling to pick the tools and args to call", + "inputParams": [ + { + "label": "System Message", + "name": "systemMessage", + "type": "string", + "rows": 4, + "optional": true, + "additionalParams": true, + "id": "openAIToolAgent_0-input-systemMessage-string" + } + ], + "inputAnchors": [ + { + "label": "Tools", + "name": "tools", + "type": "Tool", + "list": true, + "id": "openAIToolAgent_0-input-tools-Tool" + }, + { + "label": "Memory", + "name": "memory", + "type": "BaseChatMemory", + "id": "openAIToolAgent_0-input-memory-BaseChatMemory" + }, + { + "label": "OpenAI/Azure Chat Model", + "name": "model", + "type": "BaseChatModel", + "id": "openAIToolAgent_0-input-model-BaseChatModel" + }, + { + "label": "Input Moderation", + "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", + "name": "inputModeration", + "type": "Moderation", + "optional": true, + "list": true, + "id": "openAIToolAgent_0-input-inputModeration-Moderation" + } + ], + "inputs": { + "tools": ["{{chainTool_0.data.instance}}"], + "memory": "{{bufferMemory_0.data.instance}}", + "model": "{{chatOpenAI_2.data.instance}}", + "systemMessage": "", + "inputModeration": "" + }, + "outputAnchors": [ + { + "id": "openAIToolAgent_0-output-openAIToolAgent-AgentExecutor|BaseChain|Runnable", + "name": "openAIToolAgent", + "label": "AgentExecutor", + "description": "Agent that uses OpenAI Function Calling to pick the tools and args to call", + "type": "AgentExecutor | BaseChain | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 433, + "selected": false, + "positionAbsolute": { + "x": 2083.8842813850474, + "y": 749.3536850926545 + }, + "dragging": false } ], "edges": [ @@ -797,35 +798,26 @@ { "source": "chainTool_0", "sourceHandle": "chainTool_0-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-tools-Tool", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-tools-Tool", "type": "buttonedge", - "id": "chainTool_0-chainTool_0-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool-openAIFunctionAgent_0-openAIFunctionAgent_0-input-tools-Tool", - "data": { - "label": "" - } + "id": "chainTool_0-chainTool_0-output-chainTool-ChainTool|DynamicTool|Tool|StructuredTool-openAIToolAgent_0-openAIToolAgent_0-input-tools-Tool" }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-memory-BaseChatMemory", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-memory-BaseChatMemory", "type": "buttonedge", - "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-openAIFunctionAgent_0-openAIFunctionAgent_0-input-memory-BaseChatMemory", - "data": { - "label": "" - } + "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-openAIToolAgent_0-openAIToolAgent_0-input-memory-BaseChatMemory" }, { "source": "chatOpenAI_2", "sourceHandle": "chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-model-BaseChatModel", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-model-BaseChatModel", "type": "buttonedge", - "id": "chatOpenAI_2-chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-BaseChatModel", - "data": { - "label": "" - } + "id": "chatOpenAI_2-chatOpenAI_2-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIToolAgent_0-openAIToolAgent_0-input-model-BaseChatModel" } ] } diff --git a/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json b/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json deleted file mode 100644 index dbcca23662..0000000000 --- a/packages/server/marketplaces/chatflows/Conversational Retrieval Agent.json +++ /dev/null @@ -1,789 +0,0 @@ -{ - "description": "Agent optimized for vector retrieval during conversation and answering questions based on previous dialogue.", - "categories": "Retriever Tool,Buffer Memory,ChatOpenAI,Conversational Retrieval Agent, Pinecone,Langchain", - "badge": "POPULAR", - "framework": "Langchain", - "nodes": [ - { - "width": 300, - "height": 329, - "id": "openAIEmbeddings_0", - "position": { - "x": 954.0674802999345, - "y": -196.7034956445692 - }, - "type": "customNode", - "data": { - "id": "openAIEmbeddings_0", - "label": "OpenAI Embeddings", - "version": 2, - "name": "openAIEmbeddings", - "type": "OpenAIEmbeddings", - "baseClasses": ["OpenAIEmbeddings", "Embeddings"], - "category": "Embeddings", - "description": "OpenAI API to generate embeddings for a given text", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "openAIEmbeddings_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "text-embedding-3-large", - "name": "text-embedding-3-large" - }, - { - "label": "text-embedding-3-small", - "name": "text-embedding-3-small" - }, - { - "label": "text-embedding-ada-002", - "name": "text-embedding-ada-002" - } - ], - "default": "text-embedding-ada-002", - "optional": true, - "id": "openAIEmbeddings_0-input-modelName-options" - }, - { - "label": "Strip New Lines", - "name": "stripNewLines", - "type": "boolean", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-stripNewLines-boolean" - }, - { - "label": "Batch Size", - "name": "batchSize", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-batchSize-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "openAIEmbeddings_0-input-basepath-string" - } - ], - "inputAnchors": [], - "inputs": { - "stripNewLines": "", - "batchSize": "", - "timeout": "", - "basepath": "", - "modelName": "text-embedding-ada-002" - }, - "outputAnchors": [ - { - "id": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "name": "openAIEmbeddings", - "label": "OpenAIEmbeddings", - "type": "OpenAIEmbeddings | Embeddings" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 954.0674802999345, - "y": -196.7034956445692 - }, - "dragging": false - }, - { - "width": 300, - "height": 383, - "id": "conversationalRetrievalAgent_0", - "position": { - "x": 2345.912948267881, - "y": 357.97363342258217 - }, - "type": "customNode", - "data": { - "id": "conversationalRetrievalAgent_0", - "label": "Conversational Retrieval Agent", - "version": 4, - "name": "conversationalRetrievalAgent", - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], - "category": "Agents", - "description": "An agent optimized for retrieval during conversation, answering questions based on past dialogue, all using OpenAI's Function Calling", - "inputParams": [ - { - "label": "System Message", - "name": "systemMessage", - "type": "string", - "rows": 4, - "optional": true, - "additionalParams": true, - "id": "conversationalRetrievalAgent_0-input-systemMessage-string" - } - ], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "conversationalRetrievalAgent_0-input-tools-Tool" - }, - { - "label": "Memory", - "name": "memory", - "type": "BaseChatMemory", - "id": "conversationalRetrievalAgent_0-input-memory-BaseChatMemory" - }, - { - "label": "OpenAI/Azure Chat Model", - "name": "model", - "type": "BaseChatModel", - "id": "conversationalRetrievalAgent_0-input-model-BaseChatModel" - }, - { - "label": "Input Moderation", - "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", - "name": "inputModeration", - "type": "Moderation", - "optional": true, - "list": true, - "id": "conversationalRetrievalAgent_0-input-inputModeration-Moderation" - } - ], - "inputs": { - "inputModeration": "", - "tools": ["{{retrieverTool_0.data.instance}}"], - "memory": "{{bufferMemory_0.data.instance}}", - "model": "{{chatOpenAI_0.data.instance}}", - "systemMessage": "" - }, - "outputAnchors": [ - { - "id": "conversationalRetrievalAgent_0-output-conversationalRetrievalAgent-AgentExecutor|BaseChain|Runnable", - "name": "conversationalRetrievalAgent", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain | Runnable" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 2345.912948267881, - "y": 357.97363342258217 - }, - "dragging": false - }, - { - "width": 300, - "height": 505, - "id": "retrieverTool_0", - "position": { - "x": 1770.1485365275375, - "y": -321.14473253480946 - }, - "type": "customNode", - "data": { - "id": "retrieverTool_0", - "label": "Retriever Tool", - "version": 1, - "name": "retrieverTool", - "type": "RetrieverTool", - "baseClasses": ["RetrieverTool", "DynamicTool", "Tool", "StructuredTool", "Runnable"], - "category": "Tools", - "description": "Use a retriever as allowed tool for agent", - "inputParams": [ - { - "label": "Retriever Name", - "name": "name", - "type": "string", - "placeholder": "search_state_of_union", - "id": "retrieverTool_0-input-name-string" - }, - { - "label": "Retriever Description", - "name": "description", - "type": "string", - "description": "When should agent uses to retrieve documents", - "rows": 3, - "placeholder": "Searches and returns documents regarding the state-of-the-union.", - "id": "retrieverTool_0-input-description-string" - }, - { - "label": "Return Source Documents", - "name": "returnSourceDocuments", - "type": "boolean", - "optional": true, - "id": "retrieverTool_0-input-returnSourceDocuments-boolean" - } - ], - "inputAnchors": [ - { - "label": "Retriever", - "name": "retriever", - "type": "BaseRetriever", - "id": "retrieverTool_0-input-retriever-BaseRetriever" - } - ], - "inputs": { - "name": "search_website", - "description": "Searches and return documents regarding Jane - a culinary institution that offers top quality coffee, pastries, breakfast, lunch, and a variety of baked goods. They have multiple locations, including Jane on Fillmore, Jane on Larkin, Jane the Bakery, Toy Boat By Jane, and Little Jane on Grant. They emphasize healthy eating with a focus on flavor and quality ingredients. They bake everything in-house and work with local suppliers to source ingredients directly from farmers. They also offer catering services and delivery options.", - "retriever": "{{pinecone_0.data.instance}}", - "returnSourceDocuments": true - }, - "outputAnchors": [ - { - "id": "retrieverTool_0-output-retrieverTool-RetrieverTool|DynamicTool|Tool|StructuredTool|Runnable", - "name": "retrieverTool", - "label": "RetrieverTool", - "type": "RetrieverTool | DynamicTool | Tool | StructuredTool | Runnable" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "dragging": false, - "positionAbsolute": { - "x": 1770.1485365275375, - "y": -321.14473253480946 - } - }, - { - "width": 300, - "height": 376, - "id": "bufferMemory_0", - "position": { - "x": 1771.396291209036, - "y": 216.94151328212496 - }, - "type": "customNode", - "data": { - "id": "bufferMemory_0", - "label": "Buffer Memory", - "version": 1, - "name": "bufferMemory", - "type": "BufferMemory", - "baseClasses": ["BufferMemory", "BaseChatMemory", "BaseMemory"], - "category": "Memory", - "description": "Remembers previous conversational back and forths directly", - "inputParams": [ - { - "label": "Memory Key", - "name": "memoryKey", - "type": "string", - "default": "chat_history", - "id": "bufferMemory_0-input-memoryKey-string" - }, - { - "label": "Input Key", - "name": "inputKey", - "type": "string", - "default": "input", - "id": "bufferMemory_0-input-inputKey-string" - } - ], - "inputAnchors": [], - "inputs": { - "memoryKey": "chat_history", - "inputKey": "input" - }, - "outputAnchors": [ - { - "id": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", - "name": "bufferMemory", - "label": "BufferMemory", - "type": "BufferMemory | BaseChatMemory | BaseMemory" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1771.396291209036, - "y": 216.94151328212496 - }, - "dragging": false - }, - { - "width": 300, - "height": 555, - "id": "pinecone_0", - "position": { - "x": 1376.1277183738853, - "y": -366.1202264629863 - }, - "type": "customNode", - "data": { - "id": "pinecone_0", - "label": "Pinecone", - "version": 2, - "name": "pinecone", - "type": "Pinecone", - "baseClasses": ["Pinecone", "VectorStoreRetriever", "BaseRetriever"], - "category": "Vector Stores", - "description": "Upsert embedded data and perform similarity or mmr search using Pinecone, a leading fully managed hosted vector database", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["pineconeApi"], - "id": "pinecone_0-input-credential-credential" - }, - { - "label": "Pinecone Index", - "name": "pineconeIndex", - "type": "string", - "id": "pinecone_0-input-pineconeIndex-string" - }, - { - "label": "Pinecone Namespace", - "name": "pineconeNamespace", - "type": "string", - "placeholder": "my-first-namespace", - "additionalParams": true, - "optional": true, - "id": "pinecone_0-input-pineconeNamespace-string" - }, - { - "label": "Pinecone Metadata Filter", - "name": "pineconeMetadataFilter", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "pinecone_0-input-pineconeMetadataFilter-json" - }, - { - "label": "Top K", - "name": "topK", - "description": "Number of top results to fetch. Default to 4", - "placeholder": "4", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pinecone_0-input-topK-number" - }, - { - "label": "Search Type", - "name": "searchType", - "type": "options", - "default": "similarity", - "options": [ - { - "label": "Similarity", - "name": "similarity" - }, - { - "label": "Max Marginal Relevance", - "name": "mmr" - } - ], - "additionalParams": true, - "optional": true, - "id": "pinecone_0-input-searchType-options" - }, - { - "label": "Fetch K (for MMR Search)", - "name": "fetchK", - "description": "Number of initial documents to fetch for MMR reranking. Default to 20. Used only when the search type is MMR", - "placeholder": "20", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pinecone_0-input-fetchK-number" - }, - { - "label": "Lambda (for MMR Search)", - "name": "lambda", - "description": "Number between 0 and 1 that determines the degree of diversity among the results, where 0 corresponds to maximum diversity and 1 to minimum diversity. Used only when the search type is MMR", - "placeholder": "0.5", - "type": "number", - "additionalParams": true, - "optional": true, - "id": "pinecone_0-input-lambda-number" - } - ], - "inputAnchors": [ - { - "label": "Document", - "name": "document", - "type": "Document", - "list": true, - "optional": true, - "id": "pinecone_0-input-document-Document" - }, - { - "label": "Embeddings", - "name": "embeddings", - "type": "Embeddings", - "id": "pinecone_0-input-embeddings-Embeddings" - } - ], - "inputs": { - "document": "", - "embeddings": "{{openAIEmbeddings_0.data.instance}}", - "pineconeIndex": "", - "pineconeNamespace": "", - "pineconeMetadataFilter": "", - "topK": "", - "searchType": "similarity", - "fetchK": "", - "lambda": "" - }, - "outputAnchors": [ - { - "name": "output", - "label": "Output", - "type": "options", - "options": [ - { - "id": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "name": "retriever", - "label": "Pinecone Retriever", - "type": "Pinecone | VectorStoreRetriever | BaseRetriever" - }, - { - "id": "pinecone_0-output-vectorStore-Pinecone|VectorStore", - "name": "vectorStore", - "label": "Pinecone Vector Store", - "type": "Pinecone | VectorStore" - } - ], - "default": "retriever" - } - ], - "outputs": { - "output": "retriever" - }, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1376.1277183738853, - "y": -366.1202264629863 - }, - "dragging": false - }, - { - "width": 300, - "height": 574, - "id": "chatOpenAI_0", - "position": { - "x": 1379.1468417698134, - "y": 220.8323181063672 - }, - "type": "customNode", - "data": { - "id": "chatOpenAI_0", - "label": "ChatOpenAI", - "version": 5, - "name": "chatOpenAI", - "type": "ChatOpenAI", - "baseClasses": ["ChatOpenAI", "BaseChatModel", "BaseLanguageModel", "Runnable"], - "category": "Chat Models", - "description": "Wrapper around OpenAI large language models that use the Chat endpoint", - "inputParams": [ - { - "label": "Connect Credential", - "name": "credential", - "type": "credential", - "credentialNames": ["openAIApi"], - "id": "chatOpenAI_0-input-credential-credential" - }, - { - "label": "Model Name", - "name": "modelName", - "type": "options", - "options": [ - { - "label": "gpt-4", - "name": "gpt-4" - }, - { - "label": "gpt-4-turbo-preview", - "name": "gpt-4-turbo-preview" - }, - { - "label": "gpt-4-0125-preview", - "name": "gpt-4-0125-preview" - }, - { - "label": "gpt-4-1106-preview", - "name": "gpt-4-1106-preview" - }, - { - "label": "gpt-4-1106-vision-preview", - "name": "gpt-4-1106-vision-preview" - }, - { - "label": "gpt-4-vision-preview", - "name": "gpt-4-vision-preview" - }, - { - "label": "gpt-4-0613", - "name": "gpt-4-0613" - }, - { - "label": "gpt-4-32k", - "name": "gpt-4-32k" - }, - { - "label": "gpt-4-32k-0613", - "name": "gpt-4-32k-0613" - }, - { - "label": "gpt-3.5-turbo", - "name": "gpt-3.5-turbo" - }, - { - "label": "gpt-3.5-turbo-0125", - "name": "gpt-3.5-turbo-0125" - }, - { - "label": "gpt-3.5-turbo-1106", - "name": "gpt-3.5-turbo-1106" - }, - { - "label": "gpt-3.5-turbo-0613", - "name": "gpt-3.5-turbo-0613" - }, - { - "label": "gpt-3.5-turbo-16k", - "name": "gpt-3.5-turbo-16k" - }, - { - "label": "gpt-3.5-turbo-16k-0613", - "name": "gpt-3.5-turbo-16k-0613" - } - ], - "default": "gpt-3.5-turbo", - "optional": true, - "id": "chatOpenAI_0-input-modelName-options" - }, - { - "label": "Temperature", - "name": "temperature", - "type": "number", - "step": 0.1, - "default": 0.9, - "optional": true, - "id": "chatOpenAI_0-input-temperature-number" - }, - { - "label": "Max Tokens", - "name": "maxTokens", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-maxTokens-number" - }, - { - "label": "Top Probability", - "name": "topP", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-topP-number" - }, - { - "label": "Frequency Penalty", - "name": "frequencyPenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-frequencyPenalty-number" - }, - { - "label": "Presence Penalty", - "name": "presencePenalty", - "type": "number", - "step": 0.1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-presencePenalty-number" - }, - { - "label": "Timeout", - "name": "timeout", - "type": "number", - "step": 1, - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-timeout-number" - }, - { - "label": "BasePath", - "name": "basepath", - "type": "string", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-basepath-string" - }, - { - "label": "BaseOptions", - "name": "baseOptions", - "type": "json", - "optional": true, - "additionalParams": true, - "id": "chatOpenAI_0-input-baseOptions-json" - }, - { - "label": "Allow Image Uploads", - "name": "allowImageUploads", - "type": "boolean", - "description": "Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works with LLMChain, Conversation Chain, ReAct Agent, and Conversational Agent", - "default": false, - "optional": true, - "id": "chatOpenAI_0-input-allowImageUploads-boolean" - }, - { - "label": "Image Resolution", - "description": "This parameter controls the resolution in which the model views the image.", - "name": "imageResolution", - "type": "options", - "options": [ - { - "label": "Low", - "name": "low" - }, - { - "label": "High", - "name": "high" - }, - { - "label": "Auto", - "name": "auto" - } - ], - "default": "low", - "optional": false, - "additionalParams": true, - "id": "chatOpenAI_0-input-imageResolution-options" - } - ], - "inputAnchors": [ - { - "label": "Cache", - "name": "cache", - "type": "BaseCache", - "optional": true, - "id": "chatOpenAI_0-input-cache-BaseCache" - } - ], - "inputs": { - "cache": "", - "modelName": "gpt-3.5-turbo-16k", - "temperature": 0.9, - "maxTokens": "", - "topP": "", - "frequencyPenalty": "", - "presencePenalty": "", - "timeout": "", - "basepath": "", - "baseOptions": "", - "allowImageUploads": true, - "imageResolution": "low" - }, - "outputAnchors": [ - { - "id": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", - "name": "chatOpenAI", - "label": "ChatOpenAI", - "type": "ChatOpenAI | BaseChatModel | BaseLanguageModel | Runnable" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1379.1468417698134, - "y": 220.8323181063672 - }, - "dragging": false - } - ], - "edges": [ - { - "source": "retrieverTool_0", - "sourceHandle": "retrieverTool_0-output-retrieverTool-RetrieverTool|DynamicTool|Tool|StructuredTool|Runnable", - "target": "conversationalRetrievalAgent_0", - "targetHandle": "conversationalRetrievalAgent_0-input-tools-Tool", - "type": "buttonedge", - "id": "retrieverTool_0-retrieverTool_0-output-retrieverTool-RetrieverTool|DynamicTool|Tool|StructuredTool|Runnable-conversationalRetrievalAgent_0-conversationalRetrievalAgent_0-input-tools-Tool", - "data": { - "label": "" - } - }, - { - "source": "bufferMemory_0", - "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", - "target": "conversationalRetrievalAgent_0", - "targetHandle": "conversationalRetrievalAgent_0-input-memory-BaseChatMemory", - "type": "buttonedge", - "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-conversationalRetrievalAgent_0-conversationalRetrievalAgent_0-input-memory-BaseChatMemory", - "data": { - "label": "" - } - }, - { - "source": "openAIEmbeddings_0", - "sourceHandle": "openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings", - "target": "pinecone_0", - "targetHandle": "pinecone_0-input-embeddings-Embeddings", - "type": "buttonedge", - "id": "openAIEmbeddings_0-openAIEmbeddings_0-output-openAIEmbeddings-OpenAIEmbeddings|Embeddings-pinecone_0-pinecone_0-input-embeddings-Embeddings", - "data": { - "label": "" - } - }, - { - "source": "pinecone_0", - "sourceHandle": "pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever", - "target": "retrieverTool_0", - "targetHandle": "retrieverTool_0-input-retriever-BaseRetriever", - "type": "buttonedge", - "id": "pinecone_0-pinecone_0-output-retriever-Pinecone|VectorStoreRetriever|BaseRetriever-retrieverTool_0-retrieverTool_0-input-retriever-BaseRetriever", - "data": { - "label": "" - } - }, - { - "source": "chatOpenAI_0", - "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable", - "target": "conversationalRetrievalAgent_0", - "targetHandle": "conversationalRetrievalAgent_0-input-model-BaseChatModel", - "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel|Runnable-conversationalRetrievalAgent_0-conversationalRetrievalAgent_0-input-model-BaseChatModel", - "data": { - "label": "" - } - } - ] -} diff --git a/packages/server/marketplaces/chatflows/OpenAI Agent.json b/packages/server/marketplaces/chatflows/OpenAI Agent.json index 065b0b4d3a..1d6498f47a 100644 --- a/packages/server/marketplaces/chatflows/OpenAI Agent.json +++ b/packages/server/marketplaces/chatflows/OpenAI Agent.json @@ -1,11 +1,11 @@ { "description": "An agent that uses OpenAI's Function Calling functionality to pick the tool and args to call", - "categories": "Buffer Memory,Custom Tool, SerpAPI,OpenAI Function,Calculator Tool,ChatOpenAI,Langchain", + "categories": "Buffer Memory,Custom Tool, SerpAPI,OpenAI Tool Agent,Calculator Tool,ChatOpenAI,Langchain", "framework": "Langchain", "nodes": [ { "width": 300, - "height": 143, + "height": 142, "id": "calculator_0", "position": { "x": 288.06681362611545, @@ -101,7 +101,7 @@ }, { "width": 300, - "height": 277, + "height": 276, "id": "customTool_0", "position": { "x": 883.9529939431576, @@ -150,7 +150,7 @@ }, { "width": 300, - "height": 277, + "height": 276, "id": "serper_0", "position": { "x": 504.3508341937219, @@ -197,91 +197,7 @@ }, { "width": 300, - "height": 383, - "id": "openAIFunctionAgent_0", - "position": { - "x": 1241.9739093293213, - "y": 359.3158950327101 - }, - "type": "customNode", - "data": { - "id": "openAIFunctionAgent_0", - "label": "OpenAI Function Agent", - "name": "openAIFunctionAgent", - "version": 4, - "type": "AgentExecutor", - "baseClasses": ["AgentExecutor", "BaseChain"], - "category": "Agents", - "description": "An agent that uses OpenAI's Function Calling functionality to pick the tool and args to call", - "inputParams": [ - { - "label": "System Message", - "name": "systemMessage", - "type": "string", - "rows": 4, - "optional": true, - "additionalParams": true, - "id": "openAIFunctionAgent_0-input-systemMessage-string" - } - ], - "inputAnchors": [ - { - "label": "Allowed Tools", - "name": "tools", - "type": "Tool", - "list": true, - "id": "openAIFunctionAgent_0-input-tools-Tool" - }, - { - "label": "Memory", - "name": "memory", - "type": "BaseChatMemory", - "id": "openAIFunctionAgent_0-input-memory-BaseChatMemory" - }, - { - "label": "OpenAI/Azure Chat Model", - "name": "model", - "type": "BaseChatModel", - "id": "openAIFunctionAgent_0-input-model-BaseChatModel" - }, - { - "label": "Input Moderation", - "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", - "name": "inputModeration", - "type": "Moderation", - "optional": true, - "list": true, - "id": "openAIFunctionAgent_0-input-inputModeration-Moderation" - } - ], - "inputs": { - "inputModeration": "", - "tools": ["{{calculator_0.data.instance}}", "{{serper_0.data.instance}}", "{{customTool_0.data.instance}}"], - "memory": "{{bufferMemory_0.data.instance}}", - "model": "{{chatOpenAI_0.data.instance}}", - "systemMessage": "" - }, - "outputAnchors": [ - { - "id": "openAIFunctionAgent_0-output-openAIFunctionAgent-AgentExecutor|BaseChain", - "name": "openAIFunctionAgent", - "label": "AgentExecutor", - "type": "AgentExecutor | BaseChain" - } - ], - "outputs": {}, - "selected": false - }, - "selected": false, - "positionAbsolute": { - "x": 1241.9739093293213, - "y": 359.3158950327101 - }, - "dragging": false - }, - { - "width": 300, - "height": 574, + "height": 670, "id": "chatOpenAI_0", "position": { "x": 817.8210275868742, @@ -512,63 +428,133 @@ "y": 627.7677030233751 }, "dragging": false + }, + { + "id": "openAIToolAgent_0", + "position": { + "x": 1248.5254972140808, + "y": 343.77259824664554 + }, + "type": "customNode", + "data": { + "id": "openAIToolAgent_0", + "label": "OpenAI Tool Agent", + "version": 1, + "name": "openAIToolAgent", + "type": "AgentExecutor", + "baseClasses": ["AgentExecutor", "BaseChain", "Runnable"], + "category": "Agents", + "description": "Agent that uses OpenAI Function Calling to pick the tools and args to call", + "inputParams": [ + { + "label": "System Message", + "name": "systemMessage", + "type": "string", + "rows": 4, + "optional": true, + "additionalParams": true, + "id": "openAIToolAgent_0-input-systemMessage-string" + } + ], + "inputAnchors": [ + { + "label": "Tools", + "name": "tools", + "type": "Tool", + "list": true, + "id": "openAIToolAgent_0-input-tools-Tool" + }, + { + "label": "Memory", + "name": "memory", + "type": "BaseChatMemory", + "id": "openAIToolAgent_0-input-memory-BaseChatMemory" + }, + { + "label": "OpenAI/Azure Chat Model", + "name": "model", + "type": "BaseChatModel", + "id": "openAIToolAgent_0-input-model-BaseChatModel" + }, + { + "label": "Input Moderation", + "description": "Detect text that could generate harmful output and prevent it from being sent to the language model", + "name": "inputModeration", + "type": "Moderation", + "optional": true, + "list": true, + "id": "openAIToolAgent_0-input-inputModeration-Moderation" + } + ], + "inputs": { + "tools": ["{{customTool_0.data.instance}}", "{{serper_0.data.instance}}", "{{calculator_0.data.instance}}"], + "memory": "{{bufferMemory_0.data.instance}}", + "model": "{{chatOpenAI_0.data.instance}}", + "systemMessage": "", + "inputModeration": "" + }, + "outputAnchors": [ + { + "id": "openAIToolAgent_0-output-openAIToolAgent-AgentExecutor|BaseChain|Runnable", + "name": "openAIToolAgent", + "label": "AgentExecutor", + "description": "Agent that uses OpenAI Function Calling to pick the tools and args to call", + "type": "AgentExecutor | BaseChain | Runnable" + } + ], + "outputs": {}, + "selected": false + }, + "width": 300, + "height": 433, + "selected": false, + "positionAbsolute": { + "x": 1248.5254972140808, + "y": 343.77259824664554 + }, + "dragging": false } ], "edges": [ { - "source": "calculator_0", - "sourceHandle": "calculator_0-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain|Serializable", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-tools-Tool", + "source": "customTool_0", + "sourceHandle": "customTool_0-output-customTool-CustomTool|Tool|StructuredTool", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-tools-Tool", "type": "buttonedge", - "id": "calculator_0-calculator_0-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain|Serializable-openAIFunctionAgent_0-openAIFunctionAgent_0-input-tools-Tool", - "data": { - "label": "" - } + "id": "customTool_0-customTool_0-output-customTool-CustomTool|Tool|StructuredTool-openAIToolAgent_0-openAIToolAgent_0-input-tools-Tool" }, { "source": "serper_0", "sourceHandle": "serper_0-output-serper-Serper|Tool|StructuredTool", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-tools-Tool", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-tools-Tool", "type": "buttonedge", - "id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool-openAIFunctionAgent_0-openAIFunctionAgent_0-input-tools-Tool", - "data": { - "label": "" - } + "id": "serper_0-serper_0-output-serper-Serper|Tool|StructuredTool-openAIToolAgent_0-openAIToolAgent_0-input-tools-Tool" }, { - "source": "customTool_0", - "sourceHandle": "customTool_0-output-customTool-CustomTool|Tool|StructuredTool", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-tools-Tool", + "source": "calculator_0", + "sourceHandle": "calculator_0-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain|Serializable", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-tools-Tool", "type": "buttonedge", - "id": "customTool_0-customTool_0-output-customTool-CustomTool|Tool|StructuredTool-openAIFunctionAgent_0-openAIFunctionAgent_0-input-tools-Tool", - "data": { - "label": "" - } + "id": "calculator_0-calculator_0-output-calculator-Calculator|Tool|StructuredTool|BaseLangChain|Serializable-openAIToolAgent_0-openAIToolAgent_0-input-tools-Tool" }, { "source": "bufferMemory_0", "sourceHandle": "bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-memory-BaseChatMemory", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-memory-BaseChatMemory", "type": "buttonedge", - "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-openAIFunctionAgent_0-openAIFunctionAgent_0-input-memory-BaseChatMemory", - "data": { - "label": "" - } + "id": "bufferMemory_0-bufferMemory_0-output-bufferMemory-BufferMemory|BaseChatMemory|BaseMemory-openAIToolAgent_0-openAIToolAgent_0-input-memory-BaseChatMemory" }, { "source": "chatOpenAI_0", "sourceHandle": "chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel", - "target": "openAIFunctionAgent_0", - "targetHandle": "openAIFunctionAgent_0-input-model-BaseChatModel", + "target": "openAIToolAgent_0", + "targetHandle": "openAIToolAgent_0-input-model-BaseChatModel", "type": "buttonedge", - "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIFunctionAgent_0-openAIFunctionAgent_0-input-model-BaseChatModel", - "data": { - "label": "" - } + "id": "chatOpenAI_0-chatOpenAI_0-output-chatOpenAI-ChatOpenAI|BaseChatModel|BaseLanguageModel-openAIToolAgent_0-openAIToolAgent_0-input-model-BaseChatModel" } ] } diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index 87b75cfaf4..9cff366ea0 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -907,10 +907,11 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod // Agent that are available to stream const whitelistAgents = [ 'openAIFunctionAgent', - 'mistralAIFunctionAgent', + 'mistralAIToolAgent', 'csvAgent', 'airtableAgent', - 'conversationalRetrievalAgent' + 'conversationalRetrievalAgent', + 'openAIToolAgent' ] isValidChainOrAgent = whitelistAgents.includes(endingNodeData.name) } else if (endingNodeData.category === 'Engine') {