mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:19:28 +00:00
feat(provider): optimize provider and model configuration management (#377)
* feat(provider): optimize provider and model configuration management * style(provider): use default tabs variant in provider settings dialog * style(provider): make tabs list full width * feat(provider): make model card row clickable and remove pencil edit icon * feat(settings): persist active settings tab in url hash * feat(agent): add search box and alphabetical sorting for provider and model selectors * refactor(providers): remove frontend pagination and display all models in scrollable list * fix(providers): address code review findings for model editing, i18n, and api protocol propagation
This commit is contained in:
@@ -1257,3 +1257,31 @@ describe('createAgentSession enabled skill filtering', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('getModelFromDb', () => {
|
||||
it('should prioritize provider active api protocol over model config api', () => {
|
||||
const providers: DbProviderInfo[] = [
|
||||
{
|
||||
name: 'custom-provider',
|
||||
config: { api: 'anthropic-messages', apiKey: 'KEY' },
|
||||
models: [
|
||||
{
|
||||
modelId: 'my-model',
|
||||
name: 'My Model',
|
||||
config: {
|
||||
api: 'openai-responses', // stale model config
|
||||
reasoning: false,
|
||||
input: ['text'],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 128000,
|
||||
maxTokens: 4096,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const model = getModelFromDb(providers, 'custom-provider', 'my-model')
|
||||
expect(model.api).toBe('anthropic-messages')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -70,10 +70,10 @@ export function getModelFromDb(providers: DbProviderInfo[], providerName: string
|
||||
if (dbProvider.config.baseUrl) {
|
||||
m.baseUrl = dbProvider.config.baseUrl
|
||||
}
|
||||
Object.assign(m, dbModel.config)
|
||||
if (dbProvider.config.api) {
|
||||
m.api = dbProvider.config.api
|
||||
}
|
||||
Object.assign(m, dbModel.config)
|
||||
if (dbModel.name) {
|
||||
m.name = dbModel.name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user