Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(embed): add completion and turn helpers to embedding crate

Steven Enamakelab6e35ca7dd6
diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.toml
index 1f3ff54b4b..5a1ea20789 100644
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@ -47,6 +47,9 @@ tinymcp-bus = { path = "../../vendor/tinymcp/crates/tinymcp-bus" }
# conversations in its own database, and the in-memory provider; same path as
# the core's so one copy resolves.
tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session" }
+# The wire request/response types `complete` converts to; same path as the
+# core's so one copy resolves.
+tinyinference-llm = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-llm" }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
url = "2"
uuid = { version = "1", features = ["v4"] }
diff --git a/crates/openhuman-embed/src/complete.rs b/crates/openhuman-embed/src/complete.rs
index 08e87f5a1a..bc9a8a13bf 100644
--- a/crates/openhuman-embed/src/complete.rs
+++ b/crates/openhuman-embed/src/complete.rs
@@ -49,7 +49,7 @@ use std::time::{Duration, Instant};
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use tinyinference_llm::message::{ContentBlock, ImageRef, Message, SystemMessage, UserMessage};
+use tinyinference_llm::message::{ContentBlock, ImageRef, Message, UserMessage};
use tinyinference_llm::model::{ModelRequest, ModelResponse};
use crate::error::CoreError;
@@ -115,7 +115,7 @@ impl ChatMessage {
fn into_wire(self) -> Message {
match self.role {
- Role::System => Message::System(SystemMessage::text(self.text)),
+ Role::System => Message::system(self.text),
Role::Assistant => Message::assistant(self.text),
Role::User => {
let mut content = vec![ContentBlock::Text(self.text)];
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index b2d29e5855..17191f5181 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -92,6 +92,7 @@ mod config;
mod core_agent;
mod error;
mod harness;
+pub mod complete;
pub mod memory;
mod runtime;
mod turn;
@@ -136,6 +137,10 @@ pub mod session_store {
pub use tinyagents_session::{Result as StoreResult, TinyAgentsError as StoreError};
}
pub use session_store::{InMemorySessionStores, SessionStoreProvider};
+pub use complete::{
+ ChatMessage, Completer, CompletionObserver, CompletionRequest, CompletionResponse,
+ CompletionTrace, CompletionUsage,
+};
pub use turn::{absolute, Route, Turn, TurnOutcome, TurnRequest};
use std::sync::Arc;
diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rs
index 1ea9f36974..8b8683c3e8 100644
--- a/crates/openhuman-embed/src/turn.rs
+++ b/crates/openhuman-embed/src/turn.rs
@@ -114,7 +114,7 @@ pub(crate) fn sanitize_url_for_display(url: &str) -> String {
/// embedder configuration. Falls back to `false` when the value does not
/// parse as an absolute URL, so an unparseable route is refused rather than
/// silently allowed.
-fn is_safe_endpoint_for_bearer(endpoint: &str) -> bool {
+pub(crate) fn is_safe_endpoint_for_bearer(endpoint: &str) -> bool {
let Ok(url) = url::Url::parse(endpoint) else {
return false;
};