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
|
|
@ -10,6 +10,8 @@ const tokenValues = {
|
|||
'32k': { prompt: 60, completion: 120 },
|
||||
'4k': { prompt: 1.5, completion: 2 },
|
||||
'16k': { prompt: 3, completion: 4 },
|
||||
'gpt-3.5-turbo-1106': { prompt: 1, completion: 2 },
|
||||
'gpt-4-1106': { prompt: 10, completion: 30 },
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -26,8 +28,12 @@ const getValueKey = (model) => {
|
|||
|
||||
if (modelName.includes('gpt-3.5-turbo-16k')) {
|
||||
return '16k';
|
||||
} else if (modelName.includes('gpt-3.5-turbo-1106')) {
|
||||
return 'gpt-3.5-turbo-1106';
|
||||
} else if (modelName.includes('gpt-3.5')) {
|
||||
return '4k';
|
||||
} else if (modelName.includes('gpt-4-1106')) {
|
||||
return 'gpt-4-1106';
|
||||
} else if (modelName.includes('gpt-4-32k')) {
|
||||
return '32k';
|
||||
} else if (modelName.includes('gpt-4')) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { getValueKey, getMultiplier, defaultRate } = require('./tx');
|
||||
const { getValueKey, getMultiplier, defaultRate, tokenValues } = require('./tx');
|
||||
|
||||
describe('getValueKey', () => {
|
||||
it('should return "16k" for model name containing "gpt-3.5-turbo-16k"', () => {
|
||||
|
|
@ -20,12 +20,28 @@ describe('getValueKey', () => {
|
|||
it('should return undefined for model names that do not match any known patterns', () => {
|
||||
expect(getValueKey('gpt-5-some-other-info')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return "gpt-3.5-turbo-1106" for model name containing "gpt-3.5-turbo-1106"', () => {
|
||||
expect(getValueKey('gpt-3.5-turbo-1106-some-other-info')).toBe('gpt-3.5-turbo-1106');
|
||||
expect(getValueKey('openai/gpt-3.5-turbo-1106')).toBe('gpt-3.5-turbo-1106');
|
||||
expect(getValueKey('gpt-3.5-turbo-1106/openai')).toBe('gpt-3.5-turbo-1106');
|
||||
});
|
||||
|
||||
it('should return "gpt-4-1106" for model name containing "gpt-4-1106"', () => {
|
||||
expect(getValueKey('gpt-4-1106-some-other-info')).toBe('gpt-4-1106');
|
||||
expect(getValueKey('gpt-4-1106-vision-preview')).toBe('gpt-4-1106');
|
||||
expect(getValueKey('gpt-4-1106-preview')).toBe('gpt-4-1106');
|
||||
expect(getValueKey('openai/gpt-4-1106')).toBe('gpt-4-1106');
|
||||
expect(getValueKey('gpt-4-1106/openai/')).toBe('gpt-4-1106');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getMultiplier', () => {
|
||||
it('should return the correct multiplier for a given valueKey and tokenType', () => {
|
||||
expect(getMultiplier({ valueKey: '8k', tokenType: 'prompt' })).toBe(30);
|
||||
expect(getMultiplier({ valueKey: '8k', tokenType: 'completion' })).toBe(60);
|
||||
expect(getMultiplier({ valueKey: '8k', tokenType: 'prompt' })).toBe(tokenValues['8k'].prompt);
|
||||
expect(getMultiplier({ valueKey: '8k', tokenType: 'completion' })).toBe(
|
||||
tokenValues['8k'].completion,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return defaultRate if tokenType is provided but not found in tokenValues', () => {
|
||||
|
|
@ -33,7 +49,9 @@ describe('getMultiplier', () => {
|
|||
});
|
||||
|
||||
it('should derive the valueKey from the model if not provided', () => {
|
||||
expect(getMultiplier({ tokenType: 'prompt', model: 'gpt-4-some-other-info' })).toBe(30);
|
||||
expect(getMultiplier({ tokenType: 'prompt', model: 'gpt-4-some-other-info' })).toBe(
|
||||
tokenValues['8k'].prompt,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return 1 if only model or tokenType is missing', () => {
|
||||
|
|
@ -41,6 +59,33 @@ describe('getMultiplier', () => {
|
|||
expect(getMultiplier({ model: 'gpt-4-some-other-info' })).toBe(1);
|
||||
});
|
||||
|
||||
it('should return the correct multiplier for gpt-3.5-turbo-1106', () => {
|
||||
expect(getMultiplier({ valueKey: 'gpt-3.5-turbo-1106', tokenType: 'prompt' })).toBe(
|
||||
tokenValues['gpt-3.5-turbo-1106'].prompt,
|
||||
);
|
||||
expect(getMultiplier({ valueKey: 'gpt-3.5-turbo-1106', tokenType: 'completion' })).toBe(
|
||||
tokenValues['gpt-3.5-turbo-1106'].completion,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return the correct multiplier for gpt-4-1106', () => {
|
||||
expect(getMultiplier({ valueKey: 'gpt-4-1106', tokenType: 'prompt' })).toBe(
|
||||
tokenValues['gpt-4-1106'].prompt,
|
||||
);
|
||||
expect(getMultiplier({ valueKey: 'gpt-4-1106', tokenType: 'completion' })).toBe(
|
||||
tokenValues['gpt-4-1106'].completion,
|
||||
);
|
||||
});
|
||||
|
||||
it('should derive the valueKey from the model if not provided for new models', () => {
|
||||
expect(
|
||||
getMultiplier({ tokenType: 'prompt', model: 'gpt-3.5-turbo-1106-some-other-info' }),
|
||||
).toBe(tokenValues['gpt-3.5-turbo-1106'].prompt);
|
||||
expect(getMultiplier({ tokenType: 'completion', model: 'gpt-4-1106-vision-preview' })).toBe(
|
||||
tokenValues['gpt-4-1106'].completion,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return defaultRate if derived valueKey does not match any known patterns', () => {
|
||||
expect(getMultiplier({ tokenType: 'prompt', model: 'gpt-5-some-other-info' })).toBe(
|
||||
defaultRate,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue