fix(Anthropic Chat Model Node): Fix detection of chat models in docker build & add support Claude Haiku (#8953)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
oleg 2024-03-22 12:03:54 +01:00 committed by GitHub
parent 666867a236
commit 76041b8587
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View file

@ -26,6 +26,10 @@ const modelField: INodeProperties = {
name: 'Claude 3 Sonnet(20240229)',
value: 'claude-3-sonnet-20240229',
},
{
name: 'Claude 3 Haiku(20240307)',
value: 'claude-3-haiku-20240307',
},
{
name: 'LEGACY: Claude 2',
value: 'claude-2',

View file

@ -1,9 +1,10 @@
import { NodeConnectionType, NodeOperationError, jsonStringify } from 'n8n-workflow';
import type { EventNamesAiNodesType, IDataObject, IExecuteFunctions } from 'n8n-workflow';
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
import type { BaseOutputParser } from '@langchain/core/output_parsers';
import type { BaseMessage } from '@langchain/core/messages';
import { DynamicTool, type Tool } from '@langchain/core/tools';
import type { BaseLLM } from '@langchain/core/language_models/llms';
export function getMetadataFiltersValues(
ctx: IExecuteFunctions,
@ -20,10 +21,10 @@ export function getMetadataFiltersValues(
return undefined;
}
// TODO: Remove this function once langchain package is updated to 0.1.x
// eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
export function isChatInstance(model: any): model is BaseChatModel {
return model instanceof BaseChatModel;
export function isChatInstance(model: unknown): model is BaseChatModel {
const namespace = (model as BaseLLM | BaseChatModel).lc_namespace;
return namespace.includes('chat_models');
}
export async function getOptionalOutputParsers(