Skip to content

Commit

Permalink
fix(Anthropic Chat Model Node): Fix detection of chat models in docke…
Browse files Browse the repository at this point in the history
…r build & add support Claude Haiku (#8953)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
  • Loading branch information
2 people authored and krynble committed Mar 25, 2024
1 parent da59410 commit becc804
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 6 additions & 5 deletions packages/@n8n/nodes-langchain/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit becc804

Please sign in to comment.