Sonnet 5.5 as the default AI model, and a model list with prices (1.6.1)
Settings -> AI picks the model from a list (utils/aiModels.js: Sonnet, Haiku, Opus 5.5 with list prices) or takes another model ID; choosing one fills in its prices. Blank prices use the built-in ones, and cache reads are metered at each model's own price. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,7 @@ jest.mock('@anthropic-ai/sdk', () => {
|
||||
const ai = require('../src/utils/ai');
|
||||
|
||||
const install = { id: 'inst_1', licenceId: 'lic_1' };
|
||||
const price = { model: 'claude-haiku-5-5', inUsd: 0.1, outUsd: 0.5, usdZar: 20, markup: 40 };
|
||||
const price = { model: 'claude-haiku-5-5', inUsd: 0.1, outUsd: 0.5, cacheReadUsd: 0.01, usdZar: 20, markup: 40 };
|
||||
const body = { protocolVersion: 1, helper: 'draft_message', system: 'Write a friendly message.', input: 'Bring a sleeping bag.', maxTokens: 1000 };
|
||||
const reply = (usage, extra = {}) => ({ model: 'claude-haiku-5-5', stop_reason: 'end_turn', content: [{ type: 'text', text: 'Hi all!' }], usage, ...extra });
|
||||
|
||||
@@ -67,6 +67,27 @@ describe('pricing', () => {
|
||||
expect(ai.pricing(mockSettings, { aiMarkupPercent: 0 }, true).markup).toBe(0);
|
||||
});
|
||||
|
||||
test('Sonnet 5.5 is the default model, at its list prices', () => {
|
||||
const { DEFAULTS } = jest.requireActual('../src/utils/settings');
|
||||
expect(DEFAULTS).toMatchObject({ ai_model: 'claude-sonnet-5-5', ai_input_usd_per_mtok: '2', ai_output_usd_per_mtok: '10' });
|
||||
});
|
||||
|
||||
test('blank prices use the built-in list; cache reads are priced per model', () => {
|
||||
const sonnet = ai.pricing({ ...mockSettings, ai_model: 'claude-sonnet-5-5', ai_input_usd_per_mtok: '', ai_output_usd_per_mtok: '' }, mockState.licence, true);
|
||||
expect(sonnet).toMatchObject({ inUsd: 2, outUsd: 10, cacheReadUsd: 0.2 });
|
||||
// Opus 5.5 reads its cache at 0.05× the input price.
|
||||
expect(ai.pricing({ ...mockSettings, ai_model: 'claude-opus-5-5', ai_input_usd_per_mtok: '4', ai_output_usd_per_mtok: '20' }, mockState.licence, true).cacheReadUsd).toBe(0.2);
|
||||
});
|
||||
|
||||
test('a model the Hub doesn\'t know needs its prices; cache reads at 0.1× of an edited price', () => {
|
||||
expect(ai.pricing({ ...mockSettings, ai_model: 'claude-new-model', ai_input_usd_per_mtok: '', ai_output_usd_per_mtok: '' }, mockState.licence, true)).toBeNull();
|
||||
const other = ai.pricing({ ...mockSettings, ai_model: 'claude-new-model', ai_input_usd_per_mtok: '3', ai_output_usd_per_mtok: '15' }, mockState.licence, true);
|
||||
expect(other.inUsd).toBe(3);
|
||||
expect(other.cacheReadUsd).toBeCloseTo(0.3);
|
||||
// Sonnet with a changed input price: its listed cache price no longer applies.
|
||||
expect(ai.pricing({ ...mockSettings, ai_model: 'claude-sonnet-5-5', ai_input_usd_per_mtok: '2.5', ai_output_usd_per_mtok: '10' }, mockState.licence, true).cacheReadUsd).toBe(0.25);
|
||||
});
|
||||
|
||||
test('cost in millicents: input, cache writes at 1.25×, reads at 0.1×, output; markup on top', () => {
|
||||
// 1M input tokens at $0.10 × R20 = R2 = 200 000 millicents.
|
||||
expect(ai.costOf({ inputTokens: 1e6 }, price)).toEqual({ real: 200000, charged: 280000 });
|
||||
|
||||
Reference in New Issue
Block a user