fix(admin): 模型导入 - 按上游模型 ID 去重
This commit is contained in:
1 parent
9c785a6369
commit
83515f81b6
2 files changed
+4
-3
No files matched your search
@@ -178,7 +178,7 @@ func (s *Service) FetchAdminChannelModels(ctx context.Context, actor *model.User
|
|||||||
if idErr != nil {
|
if idErr != nil {
|
||||||
return nil, idErr
|
return nil, idErr
|
||||||
}
|
}
|
||||||
missing = append(missing, model.ChannelModel{ID: modelID, ChannelID: channelID, ModelKey: name, DisplayName: name, BillingMode: "fixed_request", Enabled: false, PriceVersion: 1})
|
missing = append(missing, model.ChannelModel{ID: modelID, ChannelID: channelID, ModelKey: name, ProviderModelKey: name, DisplayName: name, BillingMode: "fixed_request", Enabled: false, PriceVersion: 1})
|
||||||
}
|
}
|
||||||
added, err := s.repo.CreateMissingChannelModels(missing)
|
added, err := s.repo.CreateMissingChannelModels(missing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -249,7 +249,8 @@ func (s *Service) ImportAdminChannelModels(ctx context.Context, actor *model.Use
|
|||||||
}
|
}
|
||||||
known := make(map[string]struct{}, len(existing))
|
known := make(map[string]struct{}, len(existing))
|
||||||
for _, item := range existing {
|
for _, item := range existing {
|
||||||
known[channelModelCatalogKey(item.ModelKey)] = struct{}{}
|
providerKey := firstNonEmpty(item.ProviderModelKey, item.ModelKey)
|
||||||
|
known[channelModelCatalogKey(providerKey)] = struct{}{}
|
||||||
}
|
}
|
||||||
retired := retiredChannelModelKeys(channel.RetiredModelsJSON)
|
retired := retiredChannelModelKeys(channel.RetiredModelsJSON)
|
||||||
missing := make([]model.ChannelModel, 0, len(chosen))
|
missing := make([]model.ChannelModel, 0, len(chosen))
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export function ChannelModelManager({ channel, onClose, onChanged }: { channel:
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
const pagedItems = filteredItems.slice((page - 1) * pageSize, page * pageSize);
|
const pagedItems = filteredItems.slice((page - 1) * pageSize, page * pageSize);
|
||||||
const existingFetchModelKeys = new Set(items.map((item) => normalizeFetchModelKey(item.modelKey)));
|
const existingFetchModelKeys = new Set(items.flatMap((item) => [item.modelKey, item.providerModelKey].filter(Boolean).map(normalizeFetchModelKey)));
|
||||||
const selectedNewFetchModels = selectedFetchModels.filter((name) => !existingFetchModelKeys.has(normalizeFetchModelKey(name)));
|
const selectedNewFetchModels = selectedFetchModels.filter((name) => !existingFetchModelKeys.has(normalizeFetchModelKey(name)));
|
||||||
const selectedExistingFetchCount = selectedFetchModels.length - selectedNewFetchModels.length;
|
const selectedExistingFetchCount = selectedFetchModels.length - selectedNewFetchModels.length;
|
||||||
const allFetchModelsSelected = fetchPreviewModels.length > 0 && fetchPreviewModels.every((name) => selectedFetchModels.includes(name));
|
const allFetchModelsSelected = fetchPreviewModels.length > 0 && fetchPreviewModels.every((name) => selectedFetchModels.includes(name));
|
||||||
|
|||||||
Reference in new issue
Block a user