mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🧪 feat: Claude Sonnet 4 - 1M Context Window (Beta Header) (#9093)
* adding beta header context-1m-2025-08-07 to claude sonnet 4 to increase contact window to 1M tokens * adding context-1m beta header to test cases * ci: Update Anthropic `getLLMConfig` tests and headers for model variations - Refactored test cases to ensure proper handling of model variations for 'claude-sonnet-4'. - Cleaned up unused mock implementations in tests for better clarity and performance. * refactor: regex in header retrieval for 'claude-sonnet-4' models * refactor: default tokens for 'claude-sonnet-4' to `1,000,000` * refactor: add token value retrieval and pattern matching to model tests --------- Co-authored-by: Dirk Petersen <no-reply@nowhere.com>
This commit is contained in:
parent
a6d7ebf22e
commit
ad1503abdc
5 changed files with 105 additions and 104 deletions
|
|
@ -108,7 +108,7 @@ const anthropicModels = {
|
|||
'claude-3.7-sonnet': 200000,
|
||||
'claude-3-5-sonnet-latest': 200000,
|
||||
'claude-3.5-sonnet-latest': 200000,
|
||||
'claude-sonnet-4': 200000,
|
||||
'claude-sonnet-4': 1000000,
|
||||
'claude-opus-4': 200000,
|
||||
'claude-4': 200000,
|
||||
};
|
||||
|
|
@ -487,5 +487,7 @@ module.exports = {
|
|||
matchModelName,
|
||||
processModelData,
|
||||
getModelMaxTokens,
|
||||
getModelTokenValue,
|
||||
findMatchingPattern,
|
||||
getModelMaxOutputTokens,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const { EModelEndpoint } = require('librechat-data-provider');
|
||||
const {
|
||||
maxOutputTokensMap,
|
||||
findMatchingPattern,
|
||||
getModelMaxTokens,
|
||||
processModelData,
|
||||
matchModelName,
|
||||
|
|
@ -749,8 +750,12 @@ describe('Grok Model Tests - Tokens', () => {
|
|||
|
||||
describe('Claude Model Tests', () => {
|
||||
it('should return correct context length for Claude 4 models', () => {
|
||||
expect(getModelMaxTokens('claude-sonnet-4')).toBe(200000);
|
||||
expect(getModelMaxTokens('claude-opus-4')).toBe(200000);
|
||||
expect(getModelMaxTokens('claude-sonnet-4')).toBe(
|
||||
maxTokensMap[EModelEndpoint.anthropic]['claude-sonnet-4'],
|
||||
);
|
||||
expect(getModelMaxTokens('claude-opus-4')).toBe(
|
||||
maxTokensMap[EModelEndpoint.anthropic]['claude-opus-4'],
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle Claude 4 model name variations with different prefixes and suffixes', () => {
|
||||
|
|
@ -772,7 +777,8 @@ describe('Claude Model Tests', () => {
|
|||
];
|
||||
|
||||
modelVariations.forEach((model) => {
|
||||
expect(getModelMaxTokens(model)).toBe(200000);
|
||||
const modelKey = findMatchingPattern(model, maxTokensMap[EModelEndpoint.anthropic]);
|
||||
expect(getModelMaxTokens(model)).toBe(maxTokensMap[EModelEndpoint.anthropic][modelKey]);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue