autoSwitchProvider switches the active provider and model after a successful OAuth login.
(ctx context.Context, provider, model string)
| 314 | |
| 315 | // autoSwitchProvider switches the active provider and model after a successful OAuth login. |
| 316 | func (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 | } |
no test coverage detected