MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ModelsForAuth

Method ModelsForAuth

internal/pluginhost/adapters.go:316–386  ·  view source on GitHub ↗
(ctx context.Context, auth *coreauth.Auth)

Source from the content-addressed store, hash-verified

314}
315
316func (h *Host) ModelsForAuth(ctx context.Context, auth *coreauth.Auth) AuthModelResult {
317 if h == nil || auth == nil {
318 return AuthModelResult{}
319 }
320 providerKey := normalizeProviderID(auth.Provider)
321 if providerKey == "" {
322 return AuthModelResult{}
323 }
324 for _, record := range h.activeRecords() {
325 modelProvider := record.plugin.Capabilities.ModelProvider
326 if modelProvider == nil || h.isPluginFused(record.id) {
327 continue
328 }
329 if !executorScopeAllowsOAuthModels(record.plugin.Capabilities) {
330 continue
331 }
332 authProvider := record.plugin.Capabilities.AuthProvider
333 if authProvider != nil {
334 identifier, okIdentifier := h.callAuthProviderIdentifier(record.id, authProvider)
335 if !okIdentifier || normalizeProviderID(identifier) != providerKey {
336 continue
337 }
338 } else {
339 recordProvider := normalizeProviderID(h.modelProvider(record.id))
340 if recordProvider == "" {
341 executor := record.plugin.Capabilities.Executor
342 if executor != nil {
343 candidate, okCandidate := h.executorProvider(record, executor)
344 if okCandidate {
345 recordProvider = candidate
346 }
347 }
348 }
349 if recordProvider != providerKey {
350 continue
351 }
352 }
353 resp, errModels := h.callModelsForAuth(ctx, record, modelProvider, auth)
354 if errModels != nil {
355 log.Warnf("pluginhost: models for auth %s failed: %v", auth.ID, errModels)
356 return AuthModelResult{Handled: true, Err: errModels}
357 }
358 respProvider := normalizeProviderID(resp.Provider)
359 if respProvider != "" && respProvider != providerKey {
360 continue
361 }
362 if respProvider == "" {
363 respProvider = providerKey
364 }
365 models := make([]*registry.ModelInfo, 0, len(resp.Models))
366 for _, item := range resp.Models {
367 model := pluginModelInfoToRegistryModelInfo(item)
368 if model != nil {
369 model.ID = strings.TrimSpace(model.ID)
370 }
371 if model != nil && model.ID != "" {
372 models = append(models, model)
373 }

Callers

nothing calls this directly

Calls 12

activeRecordsMethod · 0.95
isPluginFusedMethod · 0.95
modelProviderMethod · 0.95
executorProviderMethod · 0.95
callModelsForAuthMethod · 0.95
AuthDataToCoreAuthMethod · 0.95
normalizeProviderIDFunction · 0.85
authDataHasValueFunction · 0.85
authDataWithDefaultsFunction · 0.85

Tested by

no test coverage detected