Skip to content

Commit

Permalink
fix:Local DB conflicts with model and defaultSetting
Browse files Browse the repository at this point in the history
message:If the model saved in the local DB does not exist in the default setting, it will be automatically updated to the first model in the model list options in the default setting.
  • Loading branch information
xiexin12138 committed Dec 29, 2023
1 parent fbd4fb2 commit 3a056b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const rebuildSettingsStore = async() => {
const defaultData = defaultSettingsStore()
const data: Record<string, SettingsPayload> = {}
providerMetaList.forEach((provider) => {
const modelSetting = getProviderById(provider.id)?.globalSettings?.find(obj => obj.key === 'model')
if (modelSetting?.type === 'select') {
const modelList = modelSetting.options
const isExistModel = modelList.some(model => model.value === exportData?.[provider.id]?.model)

if (!isExistModel && exportData?.[provider.id]?.model)
exportData[provider.id].model = modelList?.[0]?.value
}
data[provider.id] = {
...defaultData[provider.id] || {},
...exportData?.[provider.id] || {},
Expand Down

0 comments on commit 3a056b9

Please sign in to comment.