MCPcopy Create free account
hub / github.com/diillson/chatcli / autoSwitchProvider

Method autoSwitchProvider

cli/command_handler_connect.go:316–329  ·  view source on GitHub ↗

autoSwitchProvider switches the active provider and model after a successful OAuth login.

(ctx context.Context, provider, model string)

Source from the content-addressed store, hash-verified

314
315// autoSwitchProvider switches the active provider and model after a successful OAuth login.
316func (ch *CommandHandler) autoSwitchProvider(ctx context.Context, provider, model string) {
317 newClient, err := ch.cli.manager.GetClient(provider, model)
318 if err != nil {
319 ch.cli.logger.Warn("Auto-switch after OAuth login failed, use /switch manually",
320 zap.String("provider", provider), zap.Error(err))
321 fmt.Println(i18n.T("cli.switch.change_model_error", model, err))
322 return
323 }
324 ch.cli.Client = newClient
325 ch.cli.Provider = provider
326 ch.cli.Model = model
327 fmt.Println(i18n.T("status.provider_switched", ch.cli.Client.GetModelName(), ch.cli.Provider))
328 ch.cli.refreshModelCache(ctx)
329}

Callers 1

handleAuthCommandMethod · 0.95

Calls 7

TFunction · 0.92
WarnMethod · 0.80
refreshModelCacheMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.65
GetModelNameMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected