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

Method registerConfigAPIKeyAuths

sdk/cliproxy/service.go:1361–1404  ·  view source on GitHub ↗
(ctx context.Context, cfg *config.Config)

Source from the content-addressed store, hash-verified

1359}
1360
1361func (s *Service) registerConfigAPIKeyAuths(ctx context.Context, cfg *config.Config) {
1362 if s == nil || s.coreManager == nil || cfg == nil {
1363 return
1364 }
1365 if ctx == nil {
1366 ctx = context.Background()
1367 }
1368 configSynth := synthesizer.NewConfigSynthesizer()
1369 auths, errSynthesize := configSynth.Synthesize(&synthesizer.SynthesisContext{
1370 Config: cfg,
1371 Now: time.Now(),
1372 IDGenerator: synthesizer.NewStableIDGenerator(),
1373 })
1374 if errSynthesize != nil {
1375 log.Warnf("failed to synthesize config API key auths: %v", errSynthesize)
1376 return
1377 }
1378
1379 registrationCtx := coreauth.WithDeferredAPIKeyModelAliasRebuild(ctx)
1380 tasks := make([]modelRegistrationTask, 0, len(auths))
1381 needsAliasRebuild := false
1382 for _, auth := range auths {
1383 if !coreauth.IsConfigAPIKeyAuth(auth) {
1384 continue
1385 }
1386 prepared := s.prepareCoreAuthForModelRegistration(registrationCtx, auth)
1387 if prepared == nil {
1388 continue
1389 }
1390 needsAliasRebuild = true
1391 authForRegistration := prepared
1392 tasks = append(tasks, modelRegistrationTask{
1393 phase: modelRegistrationPhaseConfigAPIKey,
1394 category: modelRegistrationCategory(authForRegistration),
1395 run: func(compatCache *openAICompatibilityRegistrationCache) {
1396 s.completeModelRegistrationForAuthWithCache(registrationCtx, authForRegistration, compatCache)
1397 },
1398 })
1399 }
1400 if needsAliasRebuild {
1401 s.coreManager.RefreshAPIKeyModelAlias()
1402 }
1403 s.runModelRegistrationTasks(registrationCtx, tasks)
1404}
1405
1406func forceHomeRuntimeConfig(cfg *config.Config) {
1407 if cfg == nil {

Callers 2

RunMethod · 0.95

Tested by

no test coverage detected