mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
fix(usage): avoid cross-provider pricing fallback
This commit is contained in:
@@ -174,9 +174,11 @@ export function resolveModelsDevPricing(
|
|||||||
const provider = options.provider ?? prefixed.provider;
|
const provider = options.provider ?? prefixed.provider;
|
||||||
const modelId = prefixed.model;
|
const modelId = prefixed.model;
|
||||||
|
|
||||||
return (
|
if (provider) {
|
||||||
resolveProviderModel(registry, provider, modelId) ?? resolveUnambiguousModel(registry, modelId)
|
return resolveProviderModel(registry, provider, modelId);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
return resolveUnambiguousModel(registry, modelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getKnownModelsDevModels(): string[] {
|
export function getKnownModelsDevModels(): string[] {
|
||||||
|
|||||||
@@ -327,6 +327,11 @@ describe('model-pricing', () => {
|
|||||||
name: 'GPT-5.5',
|
name: 'GPT-5.5',
|
||||||
cost: { input: 5, output: 30, cache_read: 0.5 },
|
cost: { input: 5, output: 30, cache_read: 0.5 },
|
||||||
},
|
},
|
||||||
|
'openai-exclusive-model': {
|
||||||
|
id: 'openai-exclusive-model',
|
||||||
|
name: 'OpenAI Exclusive Model',
|
||||||
|
cost: { input: 9, output: 18 },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'github-copilot': {
|
'github-copilot': {
|
||||||
@@ -373,6 +378,18 @@ describe('model-pricing', () => {
|
|||||||
expect(hasCustomPricing('gpt-5.5', { provider: 'openai' })).toBe(true);
|
expect(hasCustomPricing('gpt-5.5', { provider: 'openai' })).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not use another provider pricing when explicit provider lookup misses', () => {
|
||||||
|
const fallback = getModelPricing('unknown-model-xyz');
|
||||||
|
|
||||||
|
expect(getModelPricing('openai-exclusive-model', { provider: 'github-copilot' })).toEqual(
|
||||||
|
fallback
|
||||||
|
);
|
||||||
|
expect(getModelPricing('github-copilot/openai-exclusive-model')).toEqual(fallback);
|
||||||
|
expect(hasCustomPricing('openai-exclusive-model', { provider: 'github-copilot' })).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('calculates cost with provider-aware models.dev pricing', () => {
|
it('calculates cost with provider-aware models.dev pricing', () => {
|
||||||
const usage: TokenUsage = {
|
const usage: TokenUsage = {
|
||||||
inputTokens: 1_000_000,
|
inputTokens: 1_000_000,
|
||||||
|
|||||||
Reference in New Issue
Block a user