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(embedding_host): add embedding host factory module
Steven Enamakel7a622853d3ef
diff --git a/crates/openhuman-core/src/inference/embedding_host/factory.rs b/crates/openhuman-core/src/inference/embedding_host/factory.rsindex dfa7dfd7a1..2901e0bc97 100644--- a/crates/openhuman-core/src/inference/embedding_host/factory.rs+++ b/crates/openhuman-core/src/inference/embedding_host/factory.rs@@ -74,6 +74,7 @@ pub fn create_embedding_provider_with_credentials(}/// Creates a provider using OpenHuman's credential and endpoint configuration.+/// Its cloud disclosures are unrouted; see [`create_embedding_provider_for_chat`].pub fn create_embedding_provider_with_config(config: &Config,provider: &str,@@ -81,6 +82,29 @@ pub fn create_embedding_provider_with_config(dimensions: usize,api_key: &str,custom_endpoint: Option<&str>,+) -> anyhow::Result<Box<dyn EmbeddingModel>> {+ create_embedding_provider_for_chat(+ config,+ provider,+ model,+ dimensions,+ api_key,+ custom_endpoint,+ None,+ )+}++/// [`create_embedding_provider_with_config`] for a call made in a chat turn:+/// the managed (cloud) model discloses its egress to `chat`, the turn's thread+/// and client, so the disclosure card reaches the chat that triggered it.+pub fn create_embedding_provider_for_chat(+ config: &Config,+ provider: &str,+ model: &str,+ dimensions: usize,+ api_key: &str,+ custom_endpoint: Option<&str>,+ chat: Option<ApprovalChatContext>,) -> anyhow::Result<Box<dyn EmbeddingModel>> {let provider = custom_endpoint.filter(|_| provider == "custom")@@ -97,12 +121,22 @@ pub fn create_embedding_provider_with_config(let api_key = api_key.to_owned();let credentials: CredentialResolver = Arc::new(move |_| api_key.clone());let model =- create_configured_embedding_model(&selected, &credentials, &managed_factory(config))?;+ create_configured_embedding_model(&selected, &credentials, &managed_factory(config, chat))?;Ok(model)}-/// Returns the configured provider, falling back to managed embeddings.+/// Returns the configured provider, falling back to managed embeddings. Its+/// cloud disclosures are unrouted; see [`default_embedding_provider_for_chat`].pub fn default_embedding_provider_with_config(config: &Config) -> Arc<dyn EmbeddingModel> {+ default_embedding_provider_for_chat(config, None)+}++/// [`default_embedding_provider_with_config`] for a call made in a chat turn:+/// the managed (cloud) model discloses its egress to `chat`.+pub fn default_embedding_provider_for_chat(+ config: &Config,+ chat: Option<ApprovalChatContext>,+) -> Arc<dyn EmbeddingModel> {let selected = settings(&config.memory.embedding_provider,&config.memory.embedding_model,@@ -114,7 +148,7 @@ pub fn default_embedding_provider_with_config(config: &Config) -> Arc<dyn Embeddlet model = create_default_embedding_model(&selected,&credential_resolver(config),- &managed_factory(config),+ &managed_factory(config, chat),).unwrap_or_else(|error| {log::warn!("[embeddings::factory] managed fallback failed to build: {error}");diff --git a/crates/openhuman-core/src/inference/embedding_host/mod.rs b/crates/openhuman-core/src/inference/embedding_host/mod.rsindex 03052f9140..627030de05 100644--- a/crates/openhuman-core/src/inference/embedding_host/mod.rs+++ b/crates/openhuman-core/src/inference/embedding_host/mod.rs@@ -23,7 +23,8 @@ pub use cloud::{OpenHumanCloudEmbeddingModel, DEFAULT_CLOUD_EMBEDDING_DIMENSIONS, DEFAULT_CLOUD_EMBEDDING_MODEL,};pub use factory::{- create_embedding_provider_with_config, create_embedding_provider_with_credentials,+ create_embedding_provider_for_chat, create_embedding_provider_with_config,+ create_embedding_provider_with_credentials, default_embedding_provider_for_chat,default_embedding_provider_with_config,};pub use rpc::provider_from_config;