mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 00:54:06 -08:00
c8b8379015
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
24 lines
859 B
TypeScript
24 lines
859 B
TypeScript
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,
|
|
itemIndex: number,
|
|
): Record<string, never> | undefined {
|
|
const metadata = ctx.getNodeParameter('options.metadata.metadataValues', itemIndex, []) as Array<{
|
|
name: string;
|
|
value: string;
|
|
}>;
|
|
if (metadata.length > 0) {
|
|
return metadata.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});
|
|
}
|
|
|
|
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;
|
|
}
|