The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(inference): pass resolved credentials and client to catalog listings
Steven Enamakel4005ff77853a
diff --git a/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs b/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rsindex bc01c6418c..ca2f88763e 100644--- a/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs+++ b/crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs@@ -33,6 +33,37 @@ pub(super) fn resolve_local_runtime_key(looked_up}+/// The key and HTTP client a registered catalog listing is handed for `entry`+/// (when the provider id matched a configured entry).+fn catalog_request(+ config: &crate::config::Config,+ entry: Option<&crate::config::schema::cloud_providers::CloudProviderCreds>,+) -> Result<crate::inference::registry::CatalogRequest, String> {+ let service_key = "providers.list_models";+ let slug = entry.map(|e| e.slug.trim()).unwrap_or_default();+ let provider_key = match entry {+ Some(entry) => {+ let looked_up =+ crate::inference::provider::factory::lookup_key_for_slug(&entry.slug, config)+ .unwrap_or_default();+ resolve_local_runtime_key(&entry.slug, looked_up, config)+ }+ None => String::new(),+ };+ let client = match config+ .cloud_provider_ca_certs+ .get(slug)+ .filter(|pem| !pem.is_empty())+ {+ Some(pem) => crate::util::tls::client_with_ca_bundle_with_timeouts(pem, service_key, 30, 10)?,+ None => crate::config::build_runtime_proxy_client_with_timeouts(service_key, 30, 10),+ };+ Ok(crate::inference::registry::CatalogRequest {+ provider_key,+ client,+ })+}+/// The empty listing the managed provider answers with when no hosted catalog/// is registered.fn no_managed_catalog() -> crate::core::Outcome<serde_json::Value> {@@ -72,7 +103,12 @@ pub async fn list_configured_models_from_config(log::debug!("[providers][list_models] provider_id={provider_id} served by a registered catalog");- return (catalog.list)(config.clone()).await;+ let entry = config+ .cloud_providers+ .iter()+ .find(|e| e.id == provider_id || e.slug == provider_id);+ let request = catalog_request(config, entry)?;+ return (catalog.list)(config.clone(), request).await;}if provider_id == crate::inference::provider::factory::PROVIDER_OPENHUMAN {return Ok(no_managed_catalog());@@ -96,7 +132,10 @@ pub async fn list_configured_models_from_config(return match crate::inference::registry::catalog(crate::inference::provider::factory::PROVIDER_OPENHUMAN,) {- Some(catalog) => (catalog.list)(config.clone()).await,+ Some(catalog) => {+ let request = catalog_request(config, Some(&entry))?;+ (catalog.list)(config.clone(), request).await+ }None => Ok(no_managed_catalog()),};}diff --git a/crates/openhuman-core/src/inference/registry.rs b/crates/openhuman-core/src/inference/registry.rsindex 1233198fd2..81659f3f7e 100644--- a/crates/openhuman-core/src/inference/registry.rs+++ b/crates/openhuman-core/src/inference/registry.rs@@ -184,10 +184,27 @@ pub(crate) fn embedding(provider_id: &str) -> Option<EmbeddingFactory> {// Model catalogs// ---------------------------------------------------------------------------+/// What the core resolved for the `cloud_providers` entry a listing serves,+/// handed to the catalog so it honours the same per-entry settings every+/// other provider listing does.+#[derive(Clone)]+pub struct CatalogRequest {+ /// The key stored for the entry's slug (empty when none): the credential+ /// a catalog falls back to when there is no live session.+ pub provider_key: String,+ /// The HTTP client for the entry: the entry's CA bundle when it has one,+ /// else the runtime proxy client, under the `providers.list_models`+ /// service key.+ pub client: reqwest::Client,+}+/// Lists a provider's models: the same envelope `list_configured_models`/// returns (`{ "models": [...] }`).-pub type CatalogListing =- Arc<dyn Fn(Config) -> BoxFuture<Result<Outcome<serde_json::Value>, String>> + Send + Sync>;+pub type CatalogListing = Arc<+ dyn Fn(Config, CatalogRequest) -> BoxFuture<Result<Outcome<serde_json::Value>, String>>+ + Send+ + Sync,+>;/// Where to ask for one model's limits: `(model, config)`; `None` when the/// provider has no listing for it.diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rsindex 2f74e08076..e150d3ca1a 100644--- a/crates/openhuman-embed/src/host_internals.rs+++ b/crates/openhuman-embed/src/host_internals.rs@@ -363,7 +363,7 @@ pub mod inference_registry {pub use openhuman_core::inference::registry::{register_catalog, register_catalog_in, register_chat_model, register_chat_model_in,register_embedding, register_embedding_in, unregister_catalog, unregister_chat_model,- unregister_embedding, BoxFuture, CatalogEntry, CatalogLimits, CatalogListing,+ unregister_embedding, BoxFuture, CatalogEntry, CatalogLimits, CatalogListing, CatalogRequest,ChatModelEntry, ChatModelFactory, ChatModelRequest, EmbeddingFactory, EmbeddingRequest,ReadinessProbe,};