feat(api-access): unify DeepSeek model discovery and selection
- require explicit model discovery before saving DeepSeek connections - preserve selected models when refreshing the catalog - mark model lists stale when connection details change - add model refresh support to easy mode - apply built-in DeepSeek reasoning levels consistently
This commit is contained in:
1 parent
c5f68157e5
commit
2a99db2908
10 files changed
+287
-68
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import {
|
||||
applyDeepSeekModelPreset,
|
||||
DEEPSEEK_THINKING_LEVELS,
|
||||
mergeModelOptions,
|
||||
reconcileModelSelection,
|
||||
} from '../src/services/modelService';
|
||||
|
||||
describe('model discovery selection', () => {
|
||||
const discovered = [
|
||||
{ name: 'deepseek-chat' },
|
||||
{ name: 'deepseek-reasoner' },
|
||||
{ name: 'deepseek-new-model' },
|
||||
];
|
||||
|
||||
it('selects every discovered model on the first fetch for a new connection', () => {
|
||||
expect(Array.from(reconcileModelSelection(discovered, [], [], 'initial'))).toEqual([
|
||||
'deepseek-chat',
|
||||
'deepseek-reasoner',
|
||||
'deepseek-new-model',
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps saved selections and leaves newly discovered models unchecked', () => {
|
||||
expect(Array.from(reconcileModelSelection(
|
||||
discovered,
|
||||
[{ name: 'deepseek-chat' }],
|
||||
['deepseek-chat'],
|
||||
'initial',
|
||||
))).toEqual(['deepseek-chat']);
|
||||
});
|
||||
|
||||
it('preserves refresh selections, drops unavailable discoveries, and keeps configured models', () => {
|
||||
expect(Array.from(reconcileModelSelection(
|
||||
[{ name: 'deepseek-reasoner' }, { name: 'deepseek-new-model' }],
|
||||
[{ name: 'custom-model' }],
|
||||
['DEEPSEEK-REASONER', 'removed-model', 'custom-model'],
|
||||
'refresh',
|
||||
))).toEqual(['deepseek-reasoner', 'custom-model']);
|
||||
});
|
||||
|
||||
it('deduplicates model names case-insensitively and keeps configured metadata', () => {
|
||||
expect(mergeModelOptions(
|
||||
[{ name: 'deepseek-chat' }],
|
||||
[{ name: ' DEEPSEEK-CHAT ', alias: 'Chat' }],
|
||||
)).toEqual([{ name: 'DEEPSEEK-CHAT', alias: 'Chat' }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DeepSeek model preset', () => {
|
||||
it('adds built-in thinking levels while preserving existing metadata', () => {
|
||||
expect(applyDeepSeekModelPreset([{
|
||||
name: 'deepseek-reasoner',
|
||||
thinking: { custom: true, levels: ['legacy'] },
|
||||
}])).toEqual([{
|
||||
name: 'deepseek-reasoner',
|
||||
thinking: { custom: true, levels: [...DEEPSEEK_THINKING_LEVELS] },
|
||||
}]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user