applyProviderSwitch switches the active provider (and its default model), updating the client, model cache and gateway runtime mirror. Shared by the numbered /switch picker and the /provider command so both paths behave identically.
(ctx context.Context, newProvider string)
| 269 | // numbered /switch picker and the /provider command so both paths behave |
| 270 | // identically. |
| 271 | func (cli *ChatCLI) applyProviderSwitch(ctx context.Context, newProvider string) error { |
| 272 | newModel := cli.providerDefaultModel(newProvider) |
| 273 | newClient, err := cli.manager.GetClient(newProvider, newModel) |
| 274 | if err != nil { |
| 275 | cli.logger.Error("Erro ao trocar de provedor", zap.Error(err)) |
| 276 | fmt.Println(i18n.T("cli.error.switch_provider_failed")) |
| 277 | return err |
| 278 | } |
| 279 | |
| 280 | cli.Client = newClient |
| 281 | cli.Provider = newProvider |
| 282 | cli.Model = newModel |
| 283 | fmt.Println(i18n.T("status.provider_switched", cli.Client.GetModelName(), cli.Provider)) |
| 284 | fmt.Println() |
| 285 | cli.refreshModelCache(ctx) |
| 286 | // Mirror the live choice for a running/future gateway daemon (separate process). |
| 287 | cli.writeRuntimeModelState() |
| 288 | return nil |
| 289 | } |
| 290 | |
| 291 | // handleProviderCommand switches the active LLM provider by name — the |
| 292 | // single-command, navigable counterpart to the numbered /switch picker. Bare |
no test coverage detected