mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +00:00
fix: Update BaseChatModel import checks for MistralAI compatibility (#8527)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -6,24 +6,21 @@ import {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { initializeAgentExecutorWithOptions } from 'langchain/agents';
|
||||
import { BaseChatModel } from 'langchain/chat_models/base';
|
||||
import type { Tool } from 'langchain/tools';
|
||||
import type { BaseChatMemory } from 'langchain/memory';
|
||||
import type { BaseOutputParser } from 'langchain/schema/output_parser';
|
||||
import { PromptTemplate } from 'langchain/prompts';
|
||||
import { CombiningOutputParser } from 'langchain/output_parsers';
|
||||
import { isChatInstance } from '../../../../../utils/helpers';
|
||||
|
||||
export async function conversationalAgentExecute(
|
||||
this: IExecuteFunctions,
|
||||
): Promise<INodeExecutionData[][]> {
|
||||
this.logger.verbose('Executing Conversational Agent');
|
||||
|
||||
const model = (await this.getInputConnectionData(
|
||||
NodeConnectionType.AiLanguageModel,
|
||||
0,
|
||||
)) as BaseChatModel;
|
||||
const model = await this.getInputConnectionData(NodeConnectionType.AiLanguageModel, 0);
|
||||
|
||||
if (!(model instanceof BaseChatModel)) {
|
||||
if (!isChatInstance(model)) {
|
||||
throw new NodeOperationError(this.getNode(), 'Conversational Agent requires Chat Model');
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ import type { Tool } from 'langchain/tools';
|
||||
import type { BaseOutputParser } from 'langchain/schema/output_parser';
|
||||
import { PromptTemplate } from 'langchain/prompts';
|
||||
import { CombiningOutputParser } from 'langchain/output_parsers';
|
||||
import { BaseChatModel } from 'langchain/chat_models/base';
|
||||
import type { BaseChatModel } from 'langchain/chat_models/base';
|
||||
import { isChatInstance } from '../../../../../utils/helpers';
|
||||
|
||||
export async function reActAgentAgentExecute(
|
||||
this: IExecuteFunctions,
|
||||
@@ -38,7 +39,7 @@ export async function reActAgentAgentExecute(
|
||||
};
|
||||
let agent: ChatAgent | ZeroShotAgent;
|
||||
|
||||
if (model instanceof BaseChatModel) {
|
||||
if (isChatInstance(model)) {
|
||||
agent = ChatAgent.fromLLMAndTools(model, tools, {
|
||||
prefix: options.prefix,
|
||||
suffix: options.suffixChat,
|
||||
|
||||
Reference in New Issue
Block a user