release: dsh-infstarapi 0.2.0
CI / test (push) Canceled after 0s

This commit is contained in:
Coldsmile_7 committed 2026-11-26 08:24:56 +08:00
1 parent a8f689e39c
commit c340aec110
59 files changed
+1108 -1590

No files matched your search

+17 -72
View File
@@ -7,18 +7,11 @@ import { GEEK2API_MODELS, GEEK2API_MODEL_IDS, modelForHost } from '../src/catalo
import { DEFAULT_API_HOST, DEFAULT_REASONING_LEVEL, PROVIDER } from '../src/constants.js'
const byId = id => GEEK2API_MODELS.find(model => model.id === id)
const CLAUDE = ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-4-5-20251001']
const RESPONSES = ['gpt-6.1-sol', 'gpt-6-astra', 'gpt-6-luna', 'grok-4.6', 'grok-4.7']
const COMPLETIONS = ['deepseek-v4.1-flash', 'deepseek-v4-pro', 'gemini-3.8-flash', 'glm-5.3', 'kimi-k3']
const GPT = ['gpt-6.1-sol', 'gpt-6.2-sol', 'gpt-6.2-astra']
const DEEPSEEK = ['deepseek-v4.1-flash', 'deepseek-v4-pro']
test('ships the Geek2API catalog, every model on this route', () => {
assert.deepEqual([...GEEK2API_MODEL_IDS], [
'claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-4-5-20251001',
'gpt-6.1-sol', 'gpt-6-astra', 'gpt-6-luna',
'deepseek-v4.1-flash', 'deepseek-v4-pro',
'grok-4.6', 'grok-4.7',
'gemini-3.8-flash', 'glm-5.3', 'kimi-k3',
])
test('ships only the requested GPT and DeepSeek models', () => {
assert.deepEqual([...GEEK2API_MODEL_IDS], [...GPT, ...DEEPSEEK])
assert.equal(new Set(GEEK2API_MODEL_IDS).size, GEEK2API_MODEL_IDS.length)
for (const model of GEEK2API_MODELS) {
assert.equal(model.provider, PROVIDER)
@@ -27,50 +20,22 @@ test('ships the Geek2API catalog, every model on this route', () => {
}
})
test('declares image input only where the model takes it', () => {
for (const id of ['deepseek-v4-pro', 'glm-5.3']) assert.deepEqual([...byId(id).input], ['text'], id)
for (const id of [...CLAUDE, ...RESPONSES, 'deepseek-v4.1-flash', 'gemini-3.8-flash', 'kimi-k3']) {
assert.deepEqual([...byId(id).input], ['text', 'image'], id)
}
})
test('pins each model to the protocol and base URL the gateway serves', () => {
// Anthropic traffic carries no /v1: the Anthropic client appends /v1/messages.
for (const id of CLAUDE) {
assert.equal(byId(id).api, 'anthropic-messages', id)
assert.equal(byId(id).baseUrl, DEFAULT_API_HOST, id)
}
// OpenAI-style traffic carries /v1 and never an endpoint path.
for (const id of RESPONSES) {
test('uses the InfStarAPI root and each model protocol', () => {
for (const id of GPT) {
assert.equal(byId(id).api, 'openai-responses', id)
assert.equal(byId(id).baseUrl, `${DEFAULT_API_HOST}/v1`, id)
}
for (const id of COMPLETIONS) {
for (const id of DEEPSEEK) {
assert.equal(byId(id).api, 'openai-completions', id)
assert.equal(byId(id).baseUrl, `${DEFAULT_API_HOST}/v1`, id)
}
assert.equal(byId('gpt-6-astra').contextWindow, 1_050_000)
assert.equal(byId('grok-4.7').contextWindow, 500_000)
assert.equal(byId('grok-4.7').compat.supportsLongCacheRetention, false)
assert.equal(byId('grok-4.6').compat.supportsLongCacheRetention, false)
assert.equal(DEFAULT_API_HOST, 'https://sub.infstar.org')
})
test("offers each vendor's documented effort levels", () => {
for (const id of ['deepseek-v4.1-flash', 'deepseek-v4-pro']) {
assert.deepEqual(getSupportedThinkingLevels(byId(id)), ['off', 'low', 'high', 'max'], id)
}
for (const id of ['gpt-6.1-sol', 'gpt-6-astra', 'gpt-6-luna', 'claude-opus-5-5', 'claude-sonnet-5-5']) {
assert.deepEqual(getSupportedThinkingLevels(byId(id)), ['low', 'medium', 'high', 'xhigh', 'max'], id)
}
assert.deepEqual(getSupportedThinkingLevels(byId('claude-haiku-4-5-20251001')), ['low', 'medium', 'high'])
for (const id of ['grok-4.6', 'grok-4.7']) {
assert.deepEqual(getSupportedThinkingLevels(byId(id)), ['low', 'medium', 'high', 'xhigh'], id)
}
// The gateway passes no reasoning control through for these: only `off`.
for (const id of ['gemini-3.8-flash', 'glm-5.3', 'kimi-k3']) {
assert.equal(byId(id).reasoning, false, id)
assert.deepEqual(getSupportedThinkingLevels(byId(id)), ['off'], id)
}
test('preserves known DeepSeek capabilities and reasoning levels', () => {
assert.deepEqual([...byId('deepseek-v4-pro').input], ['text'])
assert.deepEqual(getSupportedThinkingLevels(byId('deepseek-v4.1-flash')), ['off', 'low', 'high', 'max'])
assert.deepEqual(getSupportedThinkingLevels(byId('deepseek-v4-pro')), ['off', 'low', 'high', 'max'])
})
test('every reasoning model accepts the route default effort', () => {
@@ -79,32 +44,12 @@ test('every reasoning model accepts the route default effort', () => {
}
})
test('declares the wire dialect each protocol needs', () => {
for (const id of ['deepseek-v4.1-flash', 'deepseek-v4-pro']) {
assert.equal(byId(id).compat.thinkingFormat, 'deepseek', id)
assert.equal(byId(id).compat.maxTokensField, 'max_tokens', id)
assert.equal(byId(id).compat.requiresReasoningContentOnAssistantMessages, true, id)
}
// Claude 5.x always thinks adaptively and rejects temperature.
for (const id of ['claude-opus-5-5', 'claude-sonnet-5-5']) {
assert.equal(byId(id).compat.forceAdaptiveThinking, true, id)
assert.equal(byId(id).compat.supportsTemperature, false, id)
}
assert.equal(byId('claude-haiku-4-5-20251001').compat, undefined)
assert.equal(byId('gpt-6.1-sol').compat, undefined)
for (const id of ['gemini-3.8-flash', 'glm-5.3', 'kimi-k3']) {
assert.equal(byId(id).compat.supportsDeveloperRole, false, id)
}
})
test('modelForHost re-roots the base URL and keeps its path', () => {
test('re-roots model base URLs without changing model IDs', () => {
const gpt = byId('gpt-6.1-sol')
const claude = byId('claude-opus-5-5')
assert.equal(modelForHost(gpt, 'https://hk2.geek2api.com').baseUrl, 'https://hk2.geek2api.com/v1')
assert.equal(modelForHost(claude, 'https://hk2.geek2api.com').baseUrl, 'https://hk2.geek2api.com')
assert.equal(modelForHost(gpt, 'https://hk2.geek2api.com').id, 'gpt-6.1-sol')
assert.equal(gpt.baseUrl, `${DEFAULT_API_HOST}/v1`, 'the catalog entry is untouched')
assert.equal(modelForHost(gpt, DEFAULT_API_HOST), gpt, 'same host returns the entry itself')
assert.equal(modelForHost(gpt, 'https://backup.example').baseUrl, 'https://backup.example/v1')
assert.equal(modelForHost(gpt, 'https://backup.example').id, 'gpt-6.1-sol')
assert.equal(gpt.baseUrl, `${DEFAULT_API_HOST}/v1`)
assert.equal(modelForHost(gpt, DEFAULT_API_HOST), gpt)
assert.equal(modelForHost(gpt, undefined), gpt)
assert.equal(modelForHost(undefined, 'https://x.example'), undefined)
})