🔧 chore: Update Deepseek Pricing, Google Safety Settings (#5409)

* fix: google-thinking model safety settings fix

* chore: update pricing/context for deepseek models

* ci: update Deepseek model token limits to use dynamic mapping
This commit is contained in:
Danny Avila 2025-01-22 07:50:09 -05:00 committed by GitHub
parent 2d3dd9e351
commit 87383fec27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 5 deletions

View file

@ -886,7 +886,8 @@ class GoogleClient extends BaseClient {
} }
getSafetySettings() { getSafetySettings() {
const isGemini2 = this.modelOptions.model.includes('gemini-2.0'); const model = this.modelOptions.model;
const isGemini2 = model.includes('gemini-2.0') && !model.includes('thinking');
const mapThreshold = (value) => { const mapThreshold = (value) => {
if (isGemini2 && value === 'BLOCK_NONE') { if (isGemini2 && value === 'BLOCK_NONE') {
return 'OFF'; return 'OFF';

View file

@ -96,6 +96,8 @@ const tokenValues = Object.assign(
'claude-': { prompt: 0.8, completion: 2.4 }, 'claude-': { prompt: 0.8, completion: 2.4 },
'command-r-plus': { prompt: 3, completion: 15 }, 'command-r-plus': { prompt: 3, completion: 15 },
'command-r': { prompt: 0.5, completion: 1.5 }, 'command-r': { prompt: 0.5, completion: 1.5 },
'deepseek-reasoner': { prompt: 0.14, completion: 0.55 },
deepseek: { prompt: 0.07, completion: 0.28 },
/* cohere doesn't have rates for the older command models, /* cohere doesn't have rates for the older command models,
so this was from https://artificialanalysis.ai/models/command-light/providers */ so this was from https://artificialanalysis.ai/models/command-light/providers */
command: { prompt: 0.38, completion: 0.38 }, command: { prompt: 0.38, completion: 0.38 },

View file

@ -263,6 +263,37 @@ describe('AWS Bedrock Model Tests', () => {
}); });
}); });
describe('Deepseek Model Tests', () => {
const deepseekModels = ['deepseek-chat', 'deepseek-coder', 'deepseek-reasoner'];
it('should return the correct prompt multipliers for all models', () => {
const results = deepseekModels.map((model) => {
const valueKey = getValueKey(model);
const multiplier = getMultiplier({ valueKey, tokenType: 'prompt' });
return tokenValues[valueKey].prompt && multiplier === tokenValues[valueKey].prompt;
});
expect(results.every(Boolean)).toBe(true);
});
it('should return the correct completion multipliers for all models', () => {
const results = deepseekModels.map((model) => {
const valueKey = getValueKey(model);
const multiplier = getMultiplier({ valueKey, tokenType: 'completion' });
return tokenValues[valueKey].completion && multiplier === tokenValues[valueKey].completion;
});
expect(results.every(Boolean)).toBe(true);
});
it('should return the correct prompt multipliers for reasoning model', () => {
const model = 'deepseek-reasoner';
const valueKey = getValueKey(model);
expect(valueKey).toBe(model);
const multiplier = getMultiplier({ valueKey, tokenType: 'prompt' });
const result = tokenValues[valueKey].prompt && multiplier === tokenValues[valueKey].prompt;
expect(result).toBe(true);
});
});
describe('getCacheMultiplier', () => { describe('getCacheMultiplier', () => {
it('should return the correct cache multiplier for a given valueKey and cacheType', () => { it('should return the correct cache multiplier for a given valueKey and cacheType', () => {
expect(getCacheMultiplier({ valueKey: 'claude-3-5-sonnet', cacheType: 'write' })).toBe( expect(getCacheMultiplier({ valueKey: 'claude-3-5-sonnet', cacheType: 'write' })).toBe(

View file

@ -87,7 +87,8 @@ function getLLMConfig(credentials, options = {}) {
maxRetries: 2, maxRetries: 2,
}; };
const isGemini2 = llmConfig.model.includes('gemini-2.0'); /** Used only for Safety Settings */
const isGemini2 = llmConfig.model.includes('gemini-2.0') && !llmConfig.model.includes('thinking');
const isGenerativeModel = llmConfig.model.includes('gemini'); const isGenerativeModel = llmConfig.model.includes('gemini');
const isChatModel = !isGenerativeModel && llmConfig.model.includes('chat'); const isChatModel = !isGenerativeModel && llmConfig.model.includes('chat');
const isTextModel = !isGenerativeModel && !isChatModel && /code|text/.test(llmConfig.model); const isTextModel = !isGenerativeModel && !isChatModel && /code|text/.test(llmConfig.model);

View file

@ -82,7 +82,8 @@ const anthropicModels = {
}; };
const deepseekModels = { const deepseekModels = {
deepseek: 127500, 'deepseek-reasoner': 63000, // -1000 from max (API)
deepseek: 63000, // -1000 from max (API)
}; };
const metaModels = { const metaModels = {

View file

@ -385,8 +385,15 @@ describe('Meta Models Tests', () => {
}); });
test('should match Deepseek model variations', () => { test('should match Deepseek model variations', () => {
expect(getModelMaxTokens('deepseek-chat')).toBe(127500); expect(getModelMaxTokens('deepseek-chat')).toBe(
expect(getModelMaxTokens('deepseek-coder')).toBe(127500); maxTokensMap[EModelEndpoint.openAI]['deepseek'],
);
expect(getModelMaxTokens('deepseek-coder')).toBe(
maxTokensMap[EModelEndpoint.openAI]['deepseek'],
);
expect(getModelMaxTokens('deepseek-reasoner')).toBe(
maxTokensMap[EModelEndpoint.openAI]['deepseek-reasoner'],
);
}); });
}); });