feat: Add LM Studio and ModelScope as system LLM providers

- Update llm.ts to include LM Studio and ModelScope in initial system providers
- Modify migrate.ts to add migration logic for adding these new providers
- Ensure providers are added only if they don't already exist in the configuration
This commit is contained in:
kangfenmao 2025-02-15 01:03:09 +08:00
parent 2c17f75f4f
commit 30959e2380
2 changed files with 47 additions and 20 deletions

View File

@ -386,6 +386,26 @@ const initialState: LlmState = {
models: SYSTEM_MODELS.infini, models: SYSTEM_MODELS.infini,
isSystem: true, isSystem: true,
enabled: false enabled: false
},
{
id: 'lmstudio',
name: 'LM Studio',
type: 'openai',
apiKey: '',
apiHost: 'http://localhost:1234',
models: SYSTEM_MODELS.lmstudio,
isSystem: true,
enabled: true
},
{
id: 'modelscope',
name: 'ModelScope',
type: 'openai',
apiKey: '',
apiHost: 'https://api-inference.modelscope.cn/v1/',
models: SYSTEM_MODELS.modelscope,
isSystem: true,
enabled: false
} }
], ],
settings: { settings: {
@ -414,26 +434,6 @@ const getIntegratedInitialState = () => {
models: [model], models: [model],
isSystem: true, isSystem: true,
enabled: true enabled: true
},
{
id: 'lmstudio',
name: 'LM Studio',
type: 'openai',
apiKey: '',
apiHost: 'http://localhost:1234',
models: [model],
isSystem: true,
enabled: true
},
{
id: 'modelscope',
name: 'ModelScope',
type: 'openai',
apiKey: '',
apiHost: 'https://api-inference.modelscope.cn/v1/',
models: SYSTEM_MODELS.modelscope,
isSystem: true,
enabled: false
} }
], ],
settings: { settings: {

View File

@ -1035,6 +1035,33 @@ const migrateConfig = {
state.minapps.enabled.push(notebooklm) state.minapps.enabled.push(notebooklm)
} }
} }
if (!state.llm.providers.find((provider) => provider.id === 'modelscope')) {
state.llm.providers.push({
id: 'modelscope',
name: 'ModelScope',
type: 'openai',
apiKey: '',
apiHost: 'https://api-inference.modelscope.cn/v1/',
models: SYSTEM_MODELS.modelscope,
isSystem: true,
enabled: false
})
}
if (!state.llm.providers.find((provider) => provider.id === 'lmstudio')) {
state.llm.providers.push({
id: 'lmstudio',
name: 'LM Studio',
type: 'openai',
apiKey: '',
apiHost: 'http://localhost:1234',
models: SYSTEM_MODELS.lmstudio,
isSystem: true,
enabled: false
})
}
return state return state
} }
} }