mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🤖 feat: Add support for claude-3-5-sonnet-20241022 (#4510)
This commit is contained in:
parent
ebe3e7f796
commit
4da35b9cf5
6 changed files with 36 additions and 5 deletions
|
|
@ -82,7 +82,7 @@ PROXY=
|
||||||
#============#
|
#============#
|
||||||
|
|
||||||
ANTHROPIC_API_KEY=user_provided
|
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=
|
# ANTHROPIC_REVERSE_PROXY=
|
||||||
|
|
||||||
#============#
|
#============#
|
||||||
|
|
|
||||||
|
|
@ -682,6 +682,9 @@ class AnthropicClient extends BaseClient {
|
||||||
*/
|
*/
|
||||||
checkPromptCacheSupport(modelName) {
|
checkPromptCacheSupport(modelName) {
|
||||||
const modelMatch = matchModelName(modelName, EModelEndpoint.anthropic);
|
const modelMatch = matchModelName(modelName, EModelEndpoint.anthropic);
|
||||||
|
if (modelMatch.includes('claude-3-5-sonnet-latest')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
modelMatch === 'claude-3-5-sonnet' ||
|
modelMatch === 'claude-3-5-sonnet' ||
|
||||||
modelMatch === 'claude-3-haiku' ||
|
modelMatch === 'claude-3-haiku' ||
|
||||||
|
|
|
||||||
|
|
@ -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 client = new AnthropicClient('test-api-key');
|
||||||
const modelOptions = {
|
const modelOptions = {
|
||||||
model: 'claude-3-5-sonnet-20240307',
|
model: 'claude-3-5-sonnet-20241022',
|
||||||
};
|
};
|
||||||
client.setOptions({ modelOptions, promptCache: true });
|
client.setOptions({ modelOptions, promptCache: true });
|
||||||
const anthropicClient = client.getClient(modelOptions);
|
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 client = new AnthropicClient('test-api-key');
|
||||||
const modelOptions = {
|
const modelOptions = {
|
||||||
model: 'claude-3-haiku-2028',
|
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', () => {
|
it('should not add beta header for other models', () => {
|
||||||
const client = new AnthropicClient('test-api-key');
|
const client = new AnthropicClient('test-api-key');
|
||||||
client.setOptions({
|
client.setOptions({
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ const anthropicModels = {
|
||||||
'claude-3-opus': 200000,
|
'claude-3-opus': 200000,
|
||||||
'claude-3-5-sonnet': 200000,
|
'claude-3-5-sonnet': 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 = {
|
const metaModels = {
|
||||||
|
|
|
||||||
|
|
@ -607,7 +607,9 @@ const sharedOpenAIModels = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const sharedAnthropicModels = [
|
const sharedAnthropicModels = [
|
||||||
|
'claude-3-5-sonnet-20241022',
|
||||||
'claude-3-5-sonnet-20240620',
|
'claude-3-5-sonnet-20240620',
|
||||||
|
'claude-3-5-sonnet-latest',
|
||||||
'claude-3-opus-20240229',
|
'claude-3-opus-20240229',
|
||||||
'claude-3-sonnet-20240229',
|
'claude-3-sonnet-20240229',
|
||||||
'claude-3-haiku-20240307',
|
'claude-3-haiku-20240307',
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ const ANTHROPIC_MAX_OUTPUT = 8192;
|
||||||
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
|
const LEGACY_ANTHROPIC_MAX_OUTPUT = 4096;
|
||||||
export const anthropicSettings = {
|
export const anthropicSettings = {
|
||||||
model: {
|
model: {
|
||||||
default: 'claude-3-5-sonnet-20240620',
|
default: 'claude-3-5-sonnet-20241022',
|
||||||
},
|
},
|
||||||
temperature: {
|
temperature: {
|
||||||
min: 0,
|
min: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue