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
chore: files changed crates/openhuman-core/src/inference/embedding_host/mod.rs,crates/openhuman-embe
Steven Enamakelbd50438e4832
diff --git a/crates/openhuman-core/src/inference/embedding_host/mod.rs b/crates/openhuman-core/src/inference/embedding_host/mod.rsindex 627030de05..5fb2271d6d 100644--- a/crates/openhuman-core/src/inference/embedding_host/mod.rs+++ b/crates/openhuman-core/src/inference/embedding_host/mod.rs@@ -28,6 +28,8 @@ pub use factory::{default_embedding_provider_with_config,};pub use rpc::provider_from_config;+/// The trait a provider built here implements, for hosts that hold one.+pub use tinyinference_embeddings::EmbeddingModel;pub use schemas::{all_controller_schemas as all_embeddings_controller_schemas,all_registered_controllers as all_embeddings_registered_controllers,diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rsindex e896a18bc1..3979e21def 100644--- a/crates/openhuman-embed/src/host_internals.rs+++ b/crates/openhuman-embed/src/host_internals.rs@@ -186,6 +186,7 @@ pub mod inference {pub mod embedding_host {pub use openhuman_core::inference::embedding_host::{default_embedding_provider_for_chat, default_embedding_provider_with_config,+ EmbeddingModel,};}pub mod provider {diff --git a/crates/openhuman-tinyhumans/src/jev/ranker.rs b/crates/openhuman-tinyhumans/src/jev/ranker.rsindex dfb0964400..c952899766 100644--- a/crates/openhuman-tinyhumans/src/jev/ranker.rs+++ b/crates/openhuman-tinyhumans/src/jev/ranker.rs@@ -14,7 +14,7 @@ use openhuman_embed::__host::agent::tinyagents::discovery::{};use openhuman_embed::__host::config::Config;use openhuman_embed::__host::security::approval::ApprovalChatContext;-use tinyinference_embeddings::EmbeddingModel;+use openhuman_embed::__host::inference::embedding_host::EmbeddingModel;use tinyjevclient::Client;use tinytools::{RankCandidate, RankContext, RankError, RankHit, ToolRanker};use tinytools_jev::{JevRanker, JevRankerConfig, JevStrategy};@@ -35,6 +35,15 @@ pub type ConfigLoader =pub type EmbedderFactory =Arc<dyn Fn(&Config, Option<ApprovalChatContext>) -> Arc<dyn EmbeddingModel> + Send + Sync>;+/// The core's configured embedding provider, routed to the chat when there is one.+fn default_embedder() -> EmbedderFactory {+ Arc::new(|config, chat| {+ openhuman_embed::__host::inference::embedding_host::default_embedding_provider_for_chat(+ config, chat,+ )+ })+}+/// Where the ranker reads the two env-provided Jev keys. The default is the/// process environment; a test hands in a fixed table.pub type EnvLoader = Arc<dyn Fn(&str) -> Option<String> + Send + Sync>;@@ -101,11 +110,7 @@ impl TinyHumansJevRanker {Box::pin(openhuman_embed::__host::config::ops::load_config_with_timeout())}),env: Arc::new(route::process_env),- embedder: Arc::new(|config, chat| {- openhuman_embed::__host::inference::embedding_host::default_embedding_provider_for_chat(- config, chat,- )- }),+ embedder: default_embedder(),deadline: DEFAULT_DEADLINE,cached: Mutex::new(None),}diff --git a/crates/openhuman-tinyhumans/src/jev/ranker_tests.rs b/crates/openhuman-tinyhumans/src/jev/ranker_tests.rsindex 075bdf8a6c..6857542a1a 100644--- a/crates/openhuman-tinyhumans/src/jev/ranker_tests.rs+++ b/crates/openhuman-tinyhumans/src/jev/ranker_tests.rs@@ -69,10 +69,75 @@ fn no_embedding_provider_disables_the_search() {..Config::default()};config.memory.embedding_provider = "none".into();- let err = retriever_for(&config).err().map(|e| e.to_string());+ let err = retriever_for(&config, None, &default_embedder()).err().map(|e| e.to_string());assert!(err.as_deref().is_some_and(|e| e.contains("no usable embedding provider")),"{err:?}");}++fn quiet_config(tmp: &tempfile::TempDir) -> Config {+ Config {+ workspace_dir: tmp.path().join("workspace"),+ action_dir: tmp.path().join("workspace"),+ config_path: tmp.path().join("config.toml"),+ ..Config::default()+ }+}++/// An embedder that records the chat each provider was built for and embeds+/// nothing (the `none` provider), so a search stops at "no usable embedding+/// provider" after the retriever was requested.+fn recording_embedder(seen: Arc<std::sync::Mutex<Vec<Option<ApprovalChatContext>>>>) -> EmbedderFactory {+ Arc::new(move |config, chat| {+ seen.lock().unwrap().push(chat.clone());+ let mut quiet = config.clone();+ quiet.memory.embedding_provider = "none".into();+ openhuman_embed::__host::inference::embedding_host::default_embedding_provider_for_chat(+ &quiet, chat,+ )+ })+}++/// The Jev retriever's cloud-embedding disclosure goes to the chat the search+/// runs for: the chat in the `RankContext` reaches the embedding provider+/// factory, and a search with no chat builds an unrouted provider.+#[tokio::test]+async fn the_chat_of_the_search_reaches_the_embedding_provider() {+ let tmp = tempfile::tempdir().expect("tempdir");+ let config = quiet_config(&tmp);+ let seen = Arc::new(std::sync::Mutex::new(Vec::new()));+ let ranker = TinyHumansJevRanker::new()+ .with_embedder_factory(recording_embedder(seen.clone()))+ .with_env_loader(Arc::new(|key| {+ (key == "OPENROUTER_API_KEY").then(|| "sk-test".to_owned())+ }))+ .with_config_loader(Arc::new(move || {+ let config = config.clone();+ Box::pin(async move { Ok(config) })+ }));+ let candidates = [RankCandidate::new("a", "a send a message")];++ let chat = tinytools::RankChat::new("thread-9", "client-4").with_request_id("req-2");+ let routed = RankContext::empty().with_chat(chat);+ let _ = ranker.rank("send a message", &routed, &candidates, 3).await;+ let _ = ranker+ .rank("send a message", &RankContext::empty(), &candidates, 3)+ .await;++ let seen = seen.lock().unwrap().clone();+ assert_eq!(+ seen.first().cloned().flatten(),+ Some(ApprovalChatContext {+ thread_id: "thread-9".to_owned(),+ client_id: "client-4".to_owned(),+ request_id: Some("req-2".to_owned()),+ }),+ "the first search ran in a chat: {seen:?}"+ );+ assert!(+ seen.iter().skip(1).all(Option::is_none),+ "a search with no chat builds an unrouted provider: {seen:?}"+ );+}