Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🤖 feat: Add support for `claude-3-5-sonnet-20241022` (#4510)
Danny Avila4da35b9cf506
diff --git a/.env.example b/.env.exampleindex 3e4f4e8845..dd99dce756 100644--- a/.env.example+++ b/.env.example@@ -82,7 +82,7 @@ PROXY=#============#ANTHROPIC_API_KEY=user_provided-# ANTHROPIC_MODELS=claude-3-5-sonnet-20240620,claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307,claude-2.1,claude-2,claude-1.2,claude-1,claude-1-100k,claude-instant-1,claude-instant-1-100k+# ANTHROPIC_MODELS=claude-3-5-sonnet-20241022,claude-3-5-sonnet-latest,claude-3-5-sonnet-20240620,claude-3-opus-20240229,claude-3-sonnet-20240229,claude-3-haiku-20240307,claude-2.1,claude-2,claude-1.2,claude-1,claude-1-100k,claude-instant-1,claude-instant-1-100k# ANTHROPIC_REVERSE_PROXY=#============#diff --git a/api/app/clients/AnthropicClient.js b/api/app/clients/AnthropicClient.jsindex 486af95c3f..ff0dc4de5b 100644--- a/api/app/clients/AnthropicClient.js+++ b/api/app/clients/AnthropicClient.js@@ -682,6 +682,9 @@ class AnthropicClient extends BaseClient {*/checkPromptCacheSupport(modelName) {const modelMatch = matchModelName(modelName, EModelEndpoint.anthropic);+ if (modelMatch.includes('claude-3-5-sonnet-latest')) {+ return false;+ }if (modelMatch === 'claude-3-5-sonnet' ||modelMatch === 'claude-3-haiku' ||diff --git a/api/app/clients/specs/AnthropicClient.test.js b/api/app/clients/specs/AnthropicClient.test.jsindex 29267de462..eef6bb6748 100644--- a/api/app/clients/specs/AnthropicClient.test.js+++ b/api/app/clients/specs/AnthropicClient.test.js@@ -201,10 +201,10 @@ describe('AnthropicClient', () => {);});- it('should add beta header for claude-3-5-sonnet model', () => {+ it('should add "max-tokens" & "prompt-caching" beta header for claude-3-5-sonnet model', () => {const client = new AnthropicClient('test-api-key');const modelOptions = {- model: 'claude-3-5-sonnet-20240307',+ model: 'claude-3-5-sonnet-20241022',};client.setOptions({ modelOptions, promptCache: true });const anthropicClient = client.getClient(modelOptions);@@ -215,7 +215,7 @@ describe('AnthropicClient', () => {);});- it('should add beta header for claude-3-haiku model', () => {+ it('should add "prompt-caching" beta header for claude-3-haiku model', () => {const client = new AnthropicClient('test-api-key');const modelOptions = {model: 'claude-3-haiku-2028',@@ -229,6 +229,30 @@ describe('AnthropicClient', () => {);});+ it('should add "prompt-caching" beta header for claude-3-opus model', () => {+ const client = new AnthropicClient('test-api-key');+ const modelOptions = {+ model: 'claude-3-opus-2028',+ };+ client.setOptions({ modelOptions, promptCache: true });+ const anthropicClient = client.getClient(modelOptions);+ expect(anthropicClient._options.defaultHeaders).toBeDefined();+ expect(anthropicClient._options.defaultHeaders).toHaveProperty('anthropic-beta');+ expect(anthropicClient._options.defaultHeaders['anthropic-beta']).toBe(+ 'prompt-caching-2024-07-31',+ );+ });++ it('should not add beta header for claude-3-5-sonnet-latest model', () => {+ const client = new AnthropicClient('test-api-key');+ const modelOptions = {+ model: 'anthropic/claude-3-5-sonnet-latest',+ };+ client.setOptions({ modelOptions, promptCache: true });+ const anthropicClient = client.getClient(modelOptions);+ expect(anthropicClient.defaultHeaders).not.toHaveProperty('anthropic-beta');+ });+it('should not add beta header for other models', () => {const client = new AnthropicClient('test-api-key');client.setOptions({diff --git a/api/utils/tokens.js b/api/utils/tokens.jsindex 6e5a131611..362b2fc670 100644--- a/api/utils/tokens.js+++ b/api/utils/tokens.js@@ -72,6 +72,8 @@ const anthropicModels = {'claude-3-opus': 200000,'claude-3-5-sonnet': 200000,'claude-3.5-sonnet': 200000,+ 'claude-3-5-sonnet-latest': 200000,+ 'claude-3.5-sonnet-latest': 200000,};const metaModels = {diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.tsindex 6ff6a46926..b57f50c16e 100644--- a/packages/data-provider/src/config.ts+++ b/packages/data-provider/src/config.ts@@ -607,7 +607,9 @@ const sharedOpenAIModels = [];const sharedAnthropicModels = [+ 'claude-3-5-sonnet-20241022','claude-3-5-sonnet-20240620',+ 'claude-3-5-sonnet-latest','claude-3-opus-20240229','claude-3-sonnet-20240229','claude-3-haiku-20240307',diff --git a/packages/data-provider/src/schemas.ts b/packages/data-provider/src/schemas.tsindex 3cca428e83..81fdf28a74 100644--- a/packages/data-provider/src/schemas.ts+++ b/packages/data-provider/src/schemas.ts@@ -241,7 +241,7 @@ const ANTHROPIC_MAX_OUTPUT = 8192;const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;export const anthropicSettings = {model: {- default: 'claude-3-5-sonnet-20240620',+ default: 'claude-3-5-sonnet-20241022',},temperature: {min: 0,