mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
VertexParams in auth-types holds the vertex_* fields of CredentialLiteLLMParams in both spellings, with one ParamSpec per setting: the wire names, the litellm module global VertexBase.get_vertex_ai_* consults, and the environment names. A credential deserializes from text or the JSON object a config spells, an empty object counts as absent, and both credential fields are redacted in Debug. auth-gcp is split so lib.rs is the entrypoint (config, auth, constants), its lookups resolve through the specs, secret_names() derives from them, and get_vertex_ai_project_from_credentials reads a service account's project_id for hosts that need it before a token exchange. The OCR host folds the module globals in by spec at projection, so OcrSettings no longer carries vertex_project and vertex_location.
36 lines
1.3 KiB
Rust
36 lines
1.3 KiB
Rust
use std::sync::LazyLock;
|
|
|
|
use litellm_auth_types::VertexParams;
|
|
|
|
pub const CLOUD_PLATFORM_SCOPE: &str = "https://www.googleapis.com/auth/cloud-platform";
|
|
pub const GOOGLE_OAUTH_TOKEN_ENDPOINT: &str = "https://oauth2.googleapis.com/token";
|
|
pub const GOOGLE_APPLICATION_CREDENTIALS_ENV: &str = "GOOGLE_APPLICATION_CREDENTIALS";
|
|
pub const VERTEX_AI_API_KEY_ENV: &str = "VERTEX_AI_API_KEY";
|
|
pub const VERTEXAI_API_KEY_ENV: &str = "VERTEXAI_API_KEY";
|
|
pub const VERTEXAI_CREDENTIALS_ENV: &str = VertexParams::CREDENTIALS.env[0];
|
|
pub const VERTEX_LOCATION_ENV: &str = VertexParams::LOCATION.env[1];
|
|
|
|
/// Every environment name the Vertex params and the token acquisition read, for hosts
|
|
/// that resolve secrets up front.
|
|
pub fn secret_names() -> &'static [&'static str] {
|
|
static NAMES: LazyLock<Vec<&'static str>> = LazyLock::new(|| {
|
|
[
|
|
VERTEX_AI_API_KEY_ENV,
|
|
VERTEXAI_API_KEY_ENV,
|
|
GOOGLE_APPLICATION_CREDENTIALS_ENV,
|
|
]
|
|
.into_iter()
|
|
.chain(
|
|
VertexParams::SPECS
|
|
.iter()
|
|
.flat_map(|spec| spec.env.iter().copied()),
|
|
)
|
|
.fold(Vec::new(), |mut names, name| {
|
|
if !names.contains(&name) {
|
|
names.push(name);
|
|
}
|
|
names
|
|
})
|
|
});
|
|
&NAMES
|
|
}
|