(
client: &mut crate::tls::GrpcClient,
provider_type: &str,
)
| 4520 | } |
| 4521 | |
| 4522 | async 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. |
| 4559 | const VERTEX_AI_PROVIDER_TYPE: &str = "google-vertex-ai"; |
no test coverage detected