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 rpc handlers for embed and settings
Steven Enamakel4896dde4b667
diff --git a/crates/openhuman-core/src/inference/embedding_host/factory.rs b/crates/openhuman-core/src/inference/embedding_host/factory.rsindex 385bef67a2..5cfee2e374 100644--- a/crates/openhuman-core/src/inference/embedding_host/factory.rs+++ b/crates/openhuman-core/src/inference/embedding_host/factory.rs@@ -3,13 +3,13 @@use std::sync::Arc;use crate::config::Config;+use tinyinference_embeddings::EmbeddingModel;use tinyinference_embeddings::factory::{create_configured_embedding_model, create_default_embedding_model, CredentialResolver,EmbeddingFactorySettings, ManagedModelFactory,};use super::cloud::OpenHumanCloudEmbeddingModel;-use super::provider_trait::{EmbeddingProvider, TinyInferenceEmbeddingProvider};fn settings(provider: &str,@@ -46,7 +46,7 @@ pub fn create_embedding_provider_with_credentials(dimensions: usize,api_key: &str,custom_endpoint: Option<&str>,-) -> anyhow::Result<Box<dyn EmbeddingProvider>> {+) -> anyhow::Result<Box<dyn EmbeddingModel>> {let provider = custom_endpoint.filter(|_| provider == "custom").map(|endpoint| format!("custom:{endpoint}"))@@ -68,7 +68,7 @@ pub fn create_embedding_provider_with_credentials(&credentials,&managed,)?;- Ok(Box::new(TinyInferenceEmbeddingProvider::from_boxed(model)))+ Ok(model)}/// Creates a provider using OpenHuman's credential and endpoint configuration.@@ -79,7 +79,7 @@ pub fn create_embedding_provider_with_config(dimensions: usize,api_key: &str,custom_endpoint: Option<&str>,-) -> anyhow::Result<Box<dyn EmbeddingProvider>> {+) -> anyhow::Result<Box<dyn EmbeddingModel>> {let provider = custom_endpoint.filter(|_| provider == "custom").map(|endpoint| format!("custom:{endpoint}"))@@ -96,11 +96,11 @@ pub fn create_embedding_provider_with_config(let credentials: CredentialResolver = Arc::new(move |_| api_key.clone());let model =create_configured_embedding_model(&selected, &credentials, &managed_factory(config))?;- Ok(Box::new(TinyInferenceEmbeddingProvider::from_boxed(model)))+ Ok(model)}/// Returns the configured provider, falling back to managed embeddings.-pub fn default_embedding_provider_with_config(config: &Config) -> Arc<dyn EmbeddingProvider> {+pub fn default_embedding_provider_with_config(config: &Config) -> Arc<dyn EmbeddingModel> {let selected = settings(&config.memory.embedding_provider,&config.memory.embedding_model,@@ -118,7 +118,7 @@ pub fn default_embedding_provider_with_config(config: &Config) -> Arc<dyn Embeddlog::warn!("[embeddings::factory] managed fallback failed to build: {error}");Box::new(tinyinference_embeddings::NoopEmbeddingModel)});- Arc::new(TinyInferenceEmbeddingProvider::from_boxed(model))+ Arc::from(model)}#[cfg(test)]diff --git a/crates/openhuman-core/src/inference/embedding_host/mod.rs b/crates/openhuman-core/src/inference/embedding_host/mod.rsindex 7dedbd2a1c..03052f9140 100644--- a/crates/openhuman-core/src/inference/embedding_host/mod.rs+++ b/crates/openhuman-core/src/inference/embedding_host/mod.rs@@ -15,9 +15,7 @@#[path = "cloud_adapter.rs"]pub mod cloud;-mod embedding_trait;mod factory;-mod provider_trait;mod rpc;mod schemas;@@ -28,9 +26,6 @@ pub use factory::{create_embedding_provider_with_config, create_embedding_provider_with_credentials,default_embedding_provider_with_config,};-pub use provider_trait::{- format_embedding_signature, EmbeddingProvider, TinyInferenceEmbeddingProvider,-};pub use rpc::provider_from_config;pub use schemas::{all_controller_schemas as all_embeddings_controller_schemas,diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc.rs b/crates/openhuman-core/src/inference/embedding_host/rpc.rsindex d780307984..1507964e3e 100644--- a/crates/openhuman-core/src/inference/embedding_host/rpc.rs+++ b/crates/openhuman-core/src/inference/embedding_host/rpc.rs@@ -35,7 +35,7 @@ const LOG_PREFIX: &str = "[embeddings::rpc]";/// Build an embedding provider from the live config — the same construction/// [`embed`] uses, exposed so other domains (e.g. `codegraph`) can obtain a/// provider for `signature()` + direct embedding without a JSON-RPC round-trip.-pub fn provider_from_config(config: &Config) -> anyhow::Result<Box<dyn super::EmbeddingProvider>> {+pub fn provider_from_config(config: &Config) -> anyhow::Result<Box<dyn tinyinference_embeddings::EmbeddingModel>> {build_embedder(config,&config.memory.embedding_provider,@@ -54,7 +54,7 @@ fn build_embedder(provider_name: &str,model: &str,dims: usize,-) -> anyhow::Result<Box<dyn super::EmbeddingProvider>> {+) -> anyhow::Result<Box<dyn tinyinference_embeddings::EmbeddingModel>> {let api_key = resolve_api_key(config, provider_name);let custom_endpoint = provider_name.strip_prefix("custom:").map(|s| s.to_string());let provider_slug = if provider_name.starts_with("custom:") {diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rsindex 2655fcf96d..1f3f547921 100644--- a/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/embed.rs@@ -43,8 +43,7 @@ pub async fn embed().map_err(|e| e.to_string())?;- let refs: Vec<&str> = inputs.iter().map(|s| s.as_str()).collect();- let vectors = embedder.embed(&refs).await.map_err(|e| e.to_string())?;+ let vectors = embedder.embed(&inputs).await.map_err(|e| e.to_string())?;let actual_dims = vectors.first().map(|v| v.len()).unwrap_or(0);@@ -115,7 +114,7 @@ pub async fn test_connection().map_err(|e| e.to_string())?;embedder- .embed(&["connection test"])+ .embed(&["connection test".to_string()]).await.map_err(|e| e.to_string())};diff --git a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rsindex 7b9b36799d..62c36ae8de 100644--- a/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs+++ b/crates/openhuman-core/src/inference/embedding_host/rpc/settings.rs@@ -200,7 +200,7 @@ pub async fn update_settings(rate_limit_per_min: Option<u32>,) -> Result<Outcome<serde_json::Value>, String> {use crate::config::ops as config_rpc;- use crate::inference::embedding_host::format_embedding_signature;+ use tinyinference_embeddings::format_embedding_signature;let mut config = config_rpc::load_config_with_timeout().await?;