195 lines
5.6 KiB
TypeScript
195 lines
5.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
estimateImportedModelVisionTokens,
|
|
getImportedModelProfile,
|
|
} from '../../shared/imported-model-profile';
|
|
import { normalizeImportedModelCapabilities } from '../../shared/user-model-config';
|
|
import {
|
|
getKnownModelCapabilityKind,
|
|
getModelCapabilityLabel,
|
|
isKnownImageInputModelId,
|
|
} from '../../shared/model-capabilities';
|
|
|
|
describe('getImportedModelProfile', () => {
|
|
it('returns native DeepSeek V4 Pro thinking levels without generic placeholders', () => {
|
|
expect(getImportedModelProfile('deepseek-v4-pro')).toMatchObject({
|
|
modalities: {
|
|
input: ['text'],
|
|
output: ['text'],
|
|
},
|
|
limit: {
|
|
context: 1_000_000,
|
|
output: 384_000,
|
|
},
|
|
pi: {
|
|
reasoning: true,
|
|
thinkingLevelMap: {
|
|
minimal: null,
|
|
low: 'low',
|
|
medium: null,
|
|
high: 'high',
|
|
max: 'max',
|
|
},
|
|
compat: {
|
|
thinkingFormat: 'deepseek',
|
|
supportsReasoningEffort: true,
|
|
requiresReasoningContentOnAssistantMessages: true,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it('normalizes Works model capabilities by normalized model id and supported effort', () => {
|
|
expect(normalizeImportedModelCapabilities({
|
|
'deepseek/deepseek-v4-pro': {
|
|
reasoning_efforts: ['max', 'low', 'low', 'medium', 'unsupported'],
|
|
reasoning_can_disable: true,
|
|
},
|
|
'qwen3.8-max': {
|
|
reasoning_efforts: ['high'],
|
|
reasoning_can_disable: false,
|
|
},
|
|
'unknown-model': {
|
|
reasoning_efforts: ['low'],
|
|
reasoning_can_disable: 'yes',
|
|
},
|
|
}, ['deepseek-v4-pro', 'qwen3.8-max'])).toEqual({
|
|
'deepseek-v4-pro': {
|
|
reasoningEfforts: ['low', 'max'],
|
|
reasoningCanDisable: true,
|
|
},
|
|
'qwen3.8-max': {
|
|
reasoningEfforts: ['high'],
|
|
reasoningCanDisable: false,
|
|
},
|
|
});
|
|
});
|
|
|
|
it('preserves an explicit empty effort list so the server can disable local reasoning metadata', () => {
|
|
expect(normalizeImportedModelCapabilities({
|
|
'deepseek-v4-pro': {
|
|
reasoning_efforts: [],
|
|
reasoning_can_disable: false,
|
|
},
|
|
}, ['deepseek-v4-pro'])).toEqual({
|
|
'deepseek-v4-pro': {
|
|
reasoningEfforts: [],
|
|
reasoningCanDisable: false,
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
'qwen3.6-plus',
|
|
'qwen3.6-plus-2026-04-02',
|
|
])('returns verified limits and hybrid-thinking support for %s', (modelId) => {
|
|
expect(getImportedModelProfile(modelId)).toEqual({
|
|
modalities: {
|
|
input: ['text', 'image'],
|
|
output: ['text'],
|
|
},
|
|
limit: {
|
|
context: 1_000_000,
|
|
output: 65_536,
|
|
},
|
|
visionTokenEstimator: 'qwen-32px-grid',
|
|
pi: {
|
|
reasoning: true,
|
|
thinkingLevelMap: {
|
|
minimal: null,
|
|
low: null,
|
|
medium: null,
|
|
high: 'high',
|
|
},
|
|
compat: {
|
|
thinkingFormat: 'qwen',
|
|
supportsDeveloperRole: false,
|
|
supportsReasoningEffort: false,
|
|
supportsStore: false,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
'qwen3.7-plus',
|
|
'qwen3.7-plus-2026-05-26',
|
|
])('returns verified limits for %s without guessing its Pi reasoning map', (modelId) => {
|
|
expect(getImportedModelProfile(modelId)).toEqual({
|
|
modalities: {
|
|
input: ['text', 'image'],
|
|
output: ['text'],
|
|
},
|
|
limit: {
|
|
context: 1_000_000,
|
|
output: 65_536,
|
|
},
|
|
visionTokenEstimator: 'qwen-32px-grid',
|
|
});
|
|
});
|
|
|
|
it('returns the verified Qwen3.8 Max Pi reasoning levels', () => {
|
|
expect(getImportedModelProfile('qwen3.8-max')).toEqual({
|
|
modalities: {
|
|
input: ['text', 'image'],
|
|
output: ['text'],
|
|
},
|
|
limit: {
|
|
context: 1_000_000,
|
|
output: 131_072,
|
|
},
|
|
pi: {
|
|
reasoning: true,
|
|
thinkingLevelMap: {
|
|
minimal: null,
|
|
low: 'low',
|
|
medium: 'medium',
|
|
high: 'xhigh',
|
|
},
|
|
compat: {
|
|
thinkingFormat: 'qwen',
|
|
supportsDeveloperRole: false,
|
|
supportsReasoningEffort: true,
|
|
supportsStore: false,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each(['qwen-vl-max', 'qwen2.5-vl-72b-instruct', 'qwen-omni-turbo'])(
|
|
'keeps image modalities without guessed limits for %s',
|
|
(modelId) => {
|
|
const profile = getImportedModelProfile(modelId);
|
|
expect(profile?.modalities.input).toEqual(['text', 'image']);
|
|
expect(profile).not.toHaveProperty('limit');
|
|
expect(profile).not.toHaveProperty('visionTokenEstimator');
|
|
},
|
|
);
|
|
|
|
it.each([
|
|
'qwen3.8-plus',
|
|
'qwen3.7-plus-latest',
|
|
'qwen3.7-plus-2026-06-15',
|
|
'qwen3.6-plus-2026-04-03',
|
|
'qwen3.7-plus-2026-99-99',
|
|
'deepseek-chat',
|
|
'',
|
|
])('does not guess metadata for %s', (modelId) => {
|
|
expect(getImportedModelProfile(modelId)).toBeNull();
|
|
});
|
|
|
|
it('estimates only profiles with the verified Qwen grid formula', () => {
|
|
expect(estimateImportedModelVisionTokens('qwen3.7-plus', 1930, 1086)).toBe(2049);
|
|
expect(estimateImportedModelVisionTokens('qwen-vl-max', 1930, 1086)).toBeNull();
|
|
});
|
|
|
|
it('keeps the legacy capability helpers delegated to the same profile', () => {
|
|
expect(isKnownImageInputModelId('qwen3.7-plus')).toBe(true);
|
|
expect(isKnownImageInputModelId('deepseek-chat')).toBe(false);
|
|
expect(getKnownModelCapabilityKind('qwen-vl-max')).toBe('multimodal');
|
|
expect(getKnownModelCapabilityKind('deepseek-chat')).toBe('text');
|
|
expect(getModelCapabilityLabel('multimodal')).toBe('多模态');
|
|
expect(getModelCapabilityLabel('text')).toBe('文本');
|
|
});
|
|
});
|