feat(Anthropic Chat Model Node): Add support for Claude 3.5 Sonnet (#9832)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg 2024-06-21 13:55:37 +02:00 committed by GitHub
parent b5923020d7
commit 2ce97be33e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */ /* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import { import {
NodeConnectionType, NodeConnectionType,
type INodePropertyOptions,
type INodeProperties, type INodeProperties,
type IExecuteFunctions, type IExecuteFunctions,
type INodeType, type INodeType,
@ -23,6 +24,10 @@ const modelField: INodeProperties = {
name: 'Claude 3 Opus(20240229)', name: 'Claude 3 Opus(20240229)',
value: 'claude-3-opus-20240229', value: 'claude-3-opus-20240229',
}, },
{
name: 'Claude 3.5 Sonnet(20240620)',
value: 'claude-3-5-sonnet-20240620',
},
{ {
name: 'Claude 3 Sonnet(20240229)', name: 'Claude 3 Sonnet(20240229)',
value: 'claude-3-sonnet-20240229', value: 'claude-3-sonnet-20240229',
@ -60,7 +65,8 @@ export class LmChatAnthropic implements INodeType {
name: 'lmChatAnthropic', name: 'lmChatAnthropic',
icon: 'file:anthropic.svg', icon: 'file:anthropic.svg',
group: ['transform'], group: ['transform'],
version: [1, 1.1], version: [1, 1.1, 1.2],
defaultVersion: 1.2,
description: 'Language Model Anthropic', description: 'Language Model Anthropic',
defaults: { defaults: {
name: 'Anthropic Chat Model', name: 'Anthropic Chat Model',
@ -104,8 +110,20 @@ export class LmChatAnthropic implements INodeType {
...modelField, ...modelField,
default: 'claude-3-sonnet-20240229', default: 'claude-3-sonnet-20240229',
displayOptions: { displayOptions: {
hide: { show: {
'@version': [1], '@version': [1.1],
},
},
},
{
...modelField,
default: 'claude-3-5-sonnet-20240620',
options: (modelField.options ?? []).filter(
(o): o is INodePropertyOptions => 'name' in o && !o.name.toString().startsWith('LEGACY'),
),
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 1.2 } }],
}, },
}, },
}, },