Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(agent-cli): configure account providers

thinhlpgc48e326c337f
diff --git a/src-tauri/src/core/cli/auth/account.rs b/src-tauri/src/core/cli/auth/account.rs
index c8d4ff960..17040edc2 100644
--- a/src-tauri/src/core/cli/auth/account.rs
+++ b/src-tauri/src/core/cli/auth/account.rs
@@ -340,6 +340,22 @@ pub async fn complete_callback_login(
let code = accept_callback(listener, &login).await?;
let token = exchange(&login, &code).await?;
store(login.provider, &token)?;
+ let definition = crate::core::cli::auth::provider_by_id(login.provider.credential_provider())
+ .ok_or_else(|| "selected account is unavailable".to_string())?;
+ if let Err(error) = crate::core::agent::global_config::set_provider(
+ definition.id,
+ crate::core::agent::global_config::ProviderUpdate {
+ api_key: None,
+ clear_api_key: true,
+ base_url: Some(definition.default_base_url),
+ models: None,
+ api_type: matches!(definition.transport, crate::core::cli::auth::Transport::Anthropic)
+ .then_some("anthropic".to_string()),
+ },
+ ) {
+ let _ = CredentialStore::delete(login.provider.credential_provider());
+ return Err(format!("could not save the provider configuration: {error}"));
+ }
Ok(login.provider)
}
#[cfg(test)]