Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/app/api/openrouter/[...path]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ describe('POST /api/openrouter/v1/chat/completions rules-engine actions', () =>

expect(response.status).toBe(200);
expect(mockedGetProvider).toHaveBeenCalledTimes(2);
expect(mockedGetProvider.mock.calls[1]?.[0].requestedModel).toBe('stepfun/step-3.7-flash:free');
expect(mockedUpstreamRequest.mock.calls[0]?.[0].body.model).toBe('stepfun/step-3.7-flash');
expect(mockedGetProvider.mock.calls[1]?.[0].requestedModel).toBe('meituan/longcat-2.0-free');
expect(mockedUpstreamRequest.mock.calls[0]?.[0].body.model).toBe('LongCat-2.0');
expect(mockedAccountForMicrodollarUsage.mock.calls[0]?.[1]).toMatchObject({
abuse_delay: 6000,
abuse_downgraded_from: 'openai/gpt-4o',
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/lib/ai-gateway/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('isFreeModel', () => {
expect(autoFreeModels.map(({ model }) => model)).toContain(tencent_hy3_free_model.public_id);
});

test('registers LongCat 2.0 as a free preferred model', async () => {
test('registers LongCat 2.0 as an Auto Free model', async () => {
expect(kiloExclusiveModels).toContain(longcat_2_free_model);
expect(findKiloExclusiveModel(longcat_2_free_model.public_id)).toBe(longcat_2_free_model);
expect(await isFreeModel(longcat_2_free_model.public_id)).toBe(true);
Expand All @@ -98,9 +98,7 @@ describe('isFreeModel', () => {
max_completion_tokens: 131_072,
status: 'public',
});
expect(autoFreeModels.map(({ model }) => model)).not.toContain(
longcat_2_free_model.public_id
);
expect(autoFreeModels.map(({ model }) => model)).toContain(longcat_2_free_model.public_id);
expect(preferredModels).toContain(longcat_2_free_model.public_id);
expect(getAiSdkProvider(longcat_2_free_model.public_id, null)).toBeUndefined();
});
Expand Down Expand Up @@ -196,16 +194,18 @@ describe('isFreeModel', () => {
'stepfun/step-3.7-flash:free': { enabled: true, effort: 'high' },
'tencent/hy3:free': { enabled: true, effort: 'high' },
'poolside/laguna-s-2.1:free': { enabled: true, effort: 'high' },
'meituan/longcat-2.0-free': { enabled: true, effort: 'high' },
});
});

test('weights Auto Free models at 80% StepFun, 10% Hy3, and 10% Laguna', () => {
test('weights Auto Free models at 70% StepFun and 10% each for Hy3, Laguna, and LongCat', () => {
expect(
Object.fromEntries(autoFreeModels.map(({ model, weight }) => [model, weight]))
).toEqual({
'stepfun/step-3.7-flash:free': 8,
'stepfun/step-3.7-flash:free': 7,
'tencent/hy3:free': 1,
'poolside/laguna-s-2.1:free': 1,
'meituan/longcat-2.0-free': 1,
});
});

Expand Down
12 changes: 10 additions & 2 deletions apps/web/src/lib/ai-gateway/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const autoFreeModels: ReadonlyArray<AutoFreeModel> = [
? [
{
model: stepfun_37_flash_free_model.public_id,
weight: 8,
weight: 7,
reasoning: { enabled: true, effort: 'high' },
} satisfies AutoFreeModel,
]
Expand All @@ -66,6 +66,15 @@ export const autoFreeModels: ReadonlyArray<AutoFreeModel> = [
weight: 1,
reasoning: { enabled: true, effort: 'high' },
} satisfies AutoFreeModel,
...(longcat_2_free_model.status === 'public'
? [
{
model: longcat_2_free_model.public_id,
weight: 1,
reasoning: { enabled: true, effort: 'high' },
} satisfies AutoFreeModel,
]
: []),
];

export function selectAutoFreeCandidate(
Expand All @@ -91,7 +100,6 @@ export const preferredModels = [
KILO_AUTO_FREE_MODEL.id,

...autoFreeModels.map(({ model }) => model),
...(longcat_2_free_model.status === 'public' ? [longcat_2_free_model.public_id] : []),

CLAUDE_SONNET_CURRENT_MODEL_ID,
CLAUDE_OPUS_CURRENT_MODEL_ID,
Expand Down