(a *coreauth.Auth, providerKey string, models []*ModelInfo)
| 1102 | } |
| 1103 | |
| 1104 | func (s *Service) registerResolvedModelsForAuth(a *coreauth.Auth, providerKey string, models []*ModelInfo) { |
| 1105 | if a == nil || a.ID == "" { |
| 1106 | return |
| 1107 | } |
| 1108 | providerKey = strings.ToLower(strings.TrimSpace(providerKey)) |
| 1109 | if providerKey == "" { |
| 1110 | GlobalModelRegistry().UnregisterClient(a.ID) |
| 1111 | return |
| 1112 | } |
| 1113 | normalizedModels := make([]*ModelInfo, 0, len(models)) |
| 1114 | for _, model := range models { |
| 1115 | if model == nil { |
| 1116 | continue |
| 1117 | } |
| 1118 | modelID := strings.TrimSpace(model.ID) |
| 1119 | if modelID == "" { |
| 1120 | continue |
| 1121 | } |
| 1122 | clone := *model |
| 1123 | clone.ID = modelID |
| 1124 | normalizedModels = append(normalizedModels, &clone) |
| 1125 | } |
| 1126 | if len(normalizedModels) == 0 { |
| 1127 | GlobalModelRegistry().UnregisterClient(a.ID) |
| 1128 | return |
| 1129 | } |
| 1130 | GlobalModelRegistry().RegisterClient(a.ID, providerKey, normalizedModels) |
| 1131 | } |
| 1132 | |
| 1133 | func (s *Service) pluginModelsForProvider(providerKey string) []*ModelInfo { |
| 1134 | if s == nil || s.pluginHost == nil { |
no test coverage detected