MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / discover_existing_provider_data

Function discover_existing_provider_data

crates/openshell-cli/src/run.rs:4522–4556  ·  view source on GitHub ↗
(
    client: &mut crate::tls::GrpcClient,
    provider_type: &str,
)

Source from the content-addressed store, hash-verified

4520}
4521
4522async fn discover_existing_provider_data(
4523 client: &mut crate::tls::GrpcClient,
4524 provider_type: &str,
4525) -> Result<Option<openshell_providers::DiscoveredProvider>> {
4526 if gateway_providers_v2_enabled(client).await? {
4527 let profile = fetch_provider_profile(client, provider_type).await?;
4528 let profile = ProviderTypeProfile::from_proto(&profile);
4529 let mut discovered =
4530 discover_from_profile(&profile, &RealDiscoveryContext).map_err(|err| {
4531 miette::miette!("failed to discover existing provider data from profile: {err}")
4532 })?;
4533
4534 // Vertex AI config keys (project ID, region, base URL, publisher) are not
4535 // declared in the profile's discovery.credentials list, so discover_from_profile
4536 // does not scan them. Scan them directly here so --from-existing captures them.
4537 if provider_type == VERTEX_AI_PROVIDER_TYPE {
4538 let discovered = discovered.get_or_insert_with(Default::default);
4539 for key in openshell_core::inference::VERTEX_AI_CONFIG_KEY_NAMES {
4540 if let Ok(val) = std::env::var(key) {
4541 let val = val.trim().to_string();
4542 if !val.is_empty() {
4543 discovered.config.entry(key.to_string()).or_insert(val);
4544 }
4545 }
4546 }
4547 }
4548
4549 Ok(discovered)
4550 } else {
4551 let registry = ProviderRegistry::new();
4552 registry
4553 .discover_existing(provider_type)
4554 .map_err(|err| miette::miette!("failed to discover existing provider data: {err}"))
4555 }
4556}
4557
4558/// Canonical provider type string for Google Vertex AI.
4559const VERTEX_AI_PROVIDER_TYPE: &str = "google-vertex-ai";

Callers 3

auto_create_providerFunction · 0.85
provider_updateFunction · 0.85

Calls 6

fetch_provider_profileFunction · 0.85
from_protoFunction · 0.85
discover_from_profileFunction · 0.85
is_emptyMethod · 0.45
discover_existingMethod · 0.45

Tested by

no test coverage detected