mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
chore: add token rate support for 11/06 models (#1146)
* chore: update model rates with 11/06 rates * chore: add new models to env.example for OPENAI_MODELS * chore: reference actual maxTokensMap in ci tests
This commit is contained in:
parent
4b63eb5a2c
commit
48c087cc06
5 changed files with 110 additions and 11 deletions
|
|
@ -1,16 +1,16 @@
|
|||
const { getModelMaxTokens, matchModelName } = require('./tokens');
|
||||
const { getModelMaxTokens, matchModelName, maxTokensMap } = require('./tokens');
|
||||
|
||||
describe('getModelMaxTokens', () => {
|
||||
test('should return correct tokens for exact match', () => {
|
||||
expect(getModelMaxTokens('gpt-4-32k-0613')).toBe(32767);
|
||||
expect(getModelMaxTokens('gpt-4-32k-0613')).toBe(maxTokensMap['gpt-4-32k-0613']);
|
||||
});
|
||||
|
||||
test('should return correct tokens for partial match', () => {
|
||||
expect(getModelMaxTokens('gpt-4-32k-unknown')).toBe(32767);
|
||||
expect(getModelMaxTokens('gpt-4-32k-unknown')).toBe(maxTokensMap['gpt-4-32k']);
|
||||
});
|
||||
|
||||
test('should return correct tokens for partial match (OpenRouter)', () => {
|
||||
expect(getModelMaxTokens('openai/gpt-4-32k')).toBe(32767);
|
||||
expect(getModelMaxTokens('openai/gpt-4-32k')).toBe(maxTokensMap['gpt-4-32k']);
|
||||
});
|
||||
|
||||
test('should return undefined for no match', () => {
|
||||
|
|
@ -18,11 +18,13 @@ describe('getModelMaxTokens', () => {
|
|||
});
|
||||
|
||||
test('should return correct tokens for another exact match', () => {
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-16k-0613')).toBe(15999);
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-16k-0613')).toBe(
|
||||
maxTokensMap['gpt-3.5-turbo-16k-0613'],
|
||||
);
|
||||
});
|
||||
|
||||
test('should return correct tokens for another partial match', () => {
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-unknown')).toBe(4095);
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-unknown')).toBe(maxTokensMap['gpt-3.5-turbo']);
|
||||
});
|
||||
|
||||
test('should return undefined for undefined input', () => {
|
||||
|
|
@ -36,6 +38,30 @@ describe('getModelMaxTokens', () => {
|
|||
test('should return undefined for number input', () => {
|
||||
expect(getModelMaxTokens(123)).toBeUndefined();
|
||||
});
|
||||
|
||||
// 11/06 Update
|
||||
test('should return correct tokens for gpt-3.5-turbo-1106 exact match', () => {
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-1106')).toBe(maxTokensMap['gpt-3.5-turbo-1106']);
|
||||
});
|
||||
|
||||
test('should return correct tokens for gpt-4-1106 exact match', () => {
|
||||
expect(getModelMaxTokens('gpt-4-1106')).toBe(maxTokensMap['gpt-4-1106']);
|
||||
});
|
||||
|
||||
test('should return correct tokens for gpt-3.5-turbo-1106 partial match', () => {
|
||||
expect(getModelMaxTokens('something-/gpt-3.5-turbo-1106')).toBe(
|
||||
maxTokensMap['gpt-3.5-turbo-1106'],
|
||||
);
|
||||
expect(getModelMaxTokens('gpt-3.5-turbo-1106/something-/')).toBe(
|
||||
maxTokensMap['gpt-3.5-turbo-1106'],
|
||||
);
|
||||
});
|
||||
|
||||
test('should return correct tokens for gpt-4-1106 partial match', () => {
|
||||
expect(getModelMaxTokens('gpt-4-1106/something')).toBe(maxTokensMap['gpt-4-1106']);
|
||||
expect(getModelMaxTokens('gpt-4-1106-preview')).toBe(maxTokensMap['gpt-4-1106']);
|
||||
expect(getModelMaxTokens('gpt-4-1106-vision-preview')).toBe(maxTokensMap['gpt-4-1106']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchModelName', () => {
|
||||
|
|
@ -57,4 +83,24 @@ describe('matchModelName', () => {
|
|||
expect(matchModelName(123)).toBeUndefined();
|
||||
expect(matchModelName({})).toBeUndefined();
|
||||
});
|
||||
|
||||
// 11/06 Update
|
||||
it('should return the exact model name for gpt-3.5-turbo-1106 if it exists in maxTokensMap', () => {
|
||||
expect(matchModelName('gpt-3.5-turbo-1106')).toBe('gpt-3.5-turbo-1106');
|
||||
});
|
||||
|
||||
it('should return the exact model name for gpt-4-1106 if it exists in maxTokensMap', () => {
|
||||
expect(matchModelName('gpt-4-1106')).toBe('gpt-4-1106');
|
||||
});
|
||||
|
||||
it('should return the closest matching key for gpt-3.5-turbo-1106 partial matches', () => {
|
||||
expect(matchModelName('gpt-3.5-turbo-1106/something')).toBe('gpt-3.5-turbo-1106');
|
||||
expect(matchModelName('something/gpt-3.5-turbo-1106')).toBe('gpt-3.5-turbo-1106');
|
||||
});
|
||||
|
||||
it('should return the closest matching key for gpt-4-1106 partial matches', () => {
|
||||
expect(matchModelName('something/gpt-4-1106')).toBe('gpt-4-1106');
|
||||
expect(matchModelName('gpt-4-1106-preview')).toBe('gpt-4-1106');
|
||||
expect(matchModelName('gpt-4-1106-vision-preview')).toBe('gpt-4-1106');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue