1 parent
a8f689e39c
commit
c340aec110
59 files changed
+1108
-1590
No files matched your search
@@ -47,22 +47,20 @@ test('the real adapter advertises the route under its display name', async () =>
|
||||
|
||||
test('resolved metadata carries context, modalities, and the vendor efforts', async () => {
|
||||
const { adapter } = route()
|
||||
const claude = await adapter.resolveModel(PROVIDER, 'claude-opus-5-5')
|
||||
assert.equal(claude.context.contextWindow, 1_000_000)
|
||||
assert.deepEqual([...claude.inputModalities], ['text', 'image'])
|
||||
assert.deepEqual(claude.reasoning.efforts.map(effort => effort.id), ['low', 'medium', 'high', 'xhigh', 'max'])
|
||||
assert.equal(claude.reasoning.defaultEffort, DEFAULT_REASONING_LEVEL)
|
||||
assert.equal(claude.defaultMaxTokens, undefined)
|
||||
const gpt = await adapter.resolveModel(PROVIDER, 'gpt-6.1-sol')
|
||||
assert.equal(gpt.context.contextWindow, 1_050_000)
|
||||
assert.deepEqual([...gpt.inputModalities], ['text', 'image'])
|
||||
assert.deepEqual(gpt.reasoning.efforts.map(effort => effort.id), ['low', 'medium', 'high', 'xhigh', 'max'])
|
||||
assert.equal(gpt.reasoning.defaultEffort, DEFAULT_REASONING_LEVEL)
|
||||
|
||||
const deepseek = await adapter.resolveModel(PROVIDER, 'deepseek-v4.1-flash')
|
||||
assert.deepEqual(deepseek.reasoning.efforts.map(effort => effort.id), ['off', 'low', 'high', 'max'])
|
||||
assert.deepEqual([...deepseek.inputModalities], ['text', 'image'])
|
||||
|
||||
// A model without a reasoning control still resolves, offering no effort
|
||||
// the upstream would reject.
|
||||
const gemini = await adapter.resolveModel(PROVIDER, 'gemini-3.8-flash')
|
||||
assert.equal(gemini.reasoning?.defaultEffort, undefined)
|
||||
assert.ok(!(gemini.reasoning?.efforts ?? []).some(effort => effort.id === DEFAULT_REASONING_LEVEL))
|
||||
const gpt62 = await adapter.resolveModel(PROVIDER, 'gpt-6.2-astra')
|
||||
assert.equal(gpt62.context.contextWindow, 1_050_000)
|
||||
assert.deepEqual(gpt62.reasoning.efforts.map(effort => effort.id), ['low', 'medium', 'high', 'xhigh', 'max'])
|
||||
assert.equal(gpt62.reasoning.defaultEffort, DEFAULT_REASONING_LEVEL)
|
||||
})
|
||||
|
||||
test('preparing a call returns the model and a stream, without opening one', async () => {
|
||||
@@ -121,28 +119,6 @@ async function runTurn(adapter, model, extra = {}) {
|
||||
return chunks.at(-1)
|
||||
}
|
||||
|
||||
test('a model without reasoning is asked for `off`, so the route default effort cannot fail it', async t => {
|
||||
const { createHostPool } = await import('../src/hosts.js')
|
||||
const { stubHostPool } = await import('./helpers.mjs')
|
||||
const requests = []
|
||||
t.mock.method(globalThis, 'fetch', async (input, init) => {
|
||||
const request = new Request(input, init)
|
||||
requests.push({ url: request.url, body: await request.json() })
|
||||
return sseCompletion('gemini-3.8-flash')
|
||||
})
|
||||
const { adapter } = await routeAdapter(stubHostPool(createHostPool))
|
||||
// No effort named: the profile default ('high') would be refused for this model.
|
||||
assert.equal((await runTurn(adapter, 'gemini-3.8-flash')).reason.kind, 'stop')
|
||||
// Even an explicit effort from a stale session is turned into `off`.
|
||||
assert.equal((await runTurn(adapter, 'glm-5.3', { reasoningEffort: 'high' })).reason.kind, 'stop')
|
||||
assert.equal(requests.length, 2)
|
||||
for (const { body } of requests) {
|
||||
assert.equal(body.reasoning_effort, undefined)
|
||||
assert.equal(body.thinking, undefined)
|
||||
}
|
||||
assert.equal(requests[0].url, 'https://h1.example/v1/chat/completions')
|
||||
})
|
||||
|
||||
test('a request that never reached its host sets the host aside; the retry lands on the next one', async t => {
|
||||
const { createHostPool } = await import('../src/hosts.js')
|
||||
const { stubHostPool } = await import('./helpers.mjs')
|
||||
@@ -171,12 +147,12 @@ test('a model no stored key can use is explained, without blaming or retrying th
|
||||
const { createHostPool } = await import('../src/hosts.js')
|
||||
const { stubHostPool } = await import('./helpers.mjs')
|
||||
t.mock.method(globalThis, 'fetch', async () => Response.json(
|
||||
{ error: { message: "Model 'kimi-k3' is not available. Use GET /v1/models to see supported models.", type: 'invalid_request_error' } },
|
||||
{ error: { message: "Model 'gpt-6.2-astra' is not available. Use GET /v1/models to see supported models.", type: 'invalid_request_error' } },
|
||||
{ status: 400 },
|
||||
))
|
||||
const { adapter, failures } = await routeAdapter(stubHostPool(createHostPool))
|
||||
const finish = await runTurn(adapter, 'kimi-k3')
|
||||
const finish = await runTurn(adapter, 'gpt-6.2-astra')
|
||||
assert.equal(finish.reason.kind, 'error')
|
||||
assert.match(finish.reason.failure.message, /你保存的 Key 都不能使用 kimi-k3/u)
|
||||
assert.match(finish.reason.failure.message, /你保存的 Key 都不能使用 gpt-6.2-astra/u)
|
||||
assert.deepEqual(failures, [])
|
||||
})
|
||||
Reference in new issue
Block a user