MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetMissingModels

Function GetMissingModels

model/missing_models.go:4–30  ·  view source on GitHub ↗

GetMissingModels returns model names that are referenced in the system

()

Source from the content-addressed store, hash-verified

2
3// GetMissingModels returns model names that are referenced in the system
4func GetMissingModels() ([]string, error) {
5 // 1. 获取所有已启用模型(去重)
6 models := GetEnabledModels()
7 if len(models) == 0 {
8 return []string{}, nil
9 }
10
11 // 2. 查询已有的元数据模型名
12 var existing []string
13 if err := DB.Model(&Model{}).Where("model_name IN ?", models).Pluck("model_name", &existing).Error; err != nil {
14 return nil, err
15 }
16
17 existingSet := make(map[string]struct{}, len(existing))
18 for _, e := range existing {
19 existingSet[e] = struct{}{}
20 }
21
22 // 3. 收集缺失模型
23 var missing []string
24 for _, name := range models {
25 if _, ok := existingSet[name]; !ok {
26 missing = append(missing, name)
27 }
28 }
29 return missing, nil
30}

Callers 3

SyncUpstreamModelsFunction · 0.92
SyncUpstreamPreviewFunction · 0.92
GetMissingModelsFunction · 0.92

Calls 1

GetEnabledModelsFunction · 0.85

Tested by

no test coverage detected