mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix: Update BaseChatModel import checks for MistralAI compatibility (#8527)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import type { IExecuteFunctions } from 'n8n-workflow';
|
||||
import { BaseChatModel } from 'langchain/chat_models/base';
|
||||
import { BaseChatModel as BaseChatModelCore } from '@langchain/core/language_models/chat_models';
|
||||
|
||||
export function getMetadataFiltersValues(
|
||||
ctx: IExecuteFunctions,
|
||||
@@ -14,3 +16,8 @@ export function getMetadataFiltersValues(
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// TODO: Remove this function once langchain package is updated to 0.1.x
|
||||
export function isChatInstance(model: any): model is BaseChatModel | BaseChatModelCore {
|
||||
return model instanceof BaseChatModel || model instanceof BaseChatModelCore;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import { BaseOutputParser } from 'langchain/schema/output_parser';
|
||||
import { isObject } from 'lodash';
|
||||
import { N8nJsonLoader } from './N8nJsonLoader';
|
||||
import { N8nBinaryLoader } from './N8nBinaryLoader';
|
||||
import { isChatInstance } from './helpers';
|
||||
|
||||
const errorsMap: { [key: string]: { message: string; description: string } } = {
|
||||
'You exceeded your current quota, please check your plan and billing details.': {
|
||||
@@ -225,7 +226,7 @@ export function logWrapper(
|
||||
}
|
||||
|
||||
// ========== BaseChatModel ==========
|
||||
if (originalInstance instanceof BaseLLM || originalInstance instanceof BaseChatModel) {
|
||||
if (originalInstance instanceof BaseLLM || isChatInstance(originalInstance)) {
|
||||
if (prop === '_generate' && '_generate' in target) {
|
||||
return async (
|
||||
messages: BaseMessage[] & string[],
|
||||
|
||||
Reference in New Issue
Block a user