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
refactor(inference): share schema field helpers across modules
Steven Enamakel8b74569925b8
diff --git a/crates/openhuman-core/src/inference/embedding_host/schemas.rs b/crates/openhuman-core/src/inference/embedding_host/schemas.rsindex f496638c38..6a08eaaf01 100644--- a/crates/openhuman-core/src/inference/embedding_host/schemas.rs+++ b/crates/openhuman-core/src/inference/embedding_host/schemas.rs@@ -7,6 +7,7 @@ use serde_json::{Map, Value};use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::Outcome;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};+use crate::inference::schema_fields::{json_output, optional_string, optional_u64, required_string};pub fn all_controller_schemas() -> Vec<ControllerSchema> {vec![@@ -246,42 +247,6 @@ fn deserialize_params<T: serde::de::DeserializeOwned>(serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))}-fn required_string(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::String,- comment,- required: true,- }-}--fn optional_string(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment,- required: false,- }-}--fn optional_u64(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),- comment,- required: false,- }-}--fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Json,- comment,- required: true,- }-}-#[cfg(test)]#[path = "schemas_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/inference/mod.rs b/crates/openhuman-core/src/inference/mod.rsindex e3432dcd62..a92a575d04 100644--- a/crates/openhuman-core/src/inference/mod.rs+++ b/crates/openhuman-core/src/inference/mod.rs@@ -36,6 +36,7 @@ pub mod provider_model;pub mod readiness;pub(crate) mod reasoning;pub mod registry;+pub(crate) mod schema_fields;mod schemas;pub mod tokenjuice;pub mod turn_models;diff --git a/crates/openhuman-core/src/inference/schema_fields.rs b/crates/openhuman-core/src/inference/schema_fields.rsnew file mode 100644index 0000000000..35473f6fb0--- /dev/null+++ b/crates/openhuman-core/src/inference/schema_fields.rs@@ -0,0 +1,39 @@+//! Shared constructors for the core's RPC schema fields.++use crate::core::{FieldSchema, TypeSchema};++pub(crate) fn required_string(name: &'static str, comment: &'static str) -> FieldSchema {+ FieldSchema {+ name,+ ty: TypeSchema::String,+ comment,+ required: true,+ }+}++pub(crate) fn optional_string(name: &'static str, comment: &'static str) -> FieldSchema {+ FieldSchema {+ name,+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),+ comment,+ required: false,+ }+}++pub(crate) fn optional_u64(name: &'static str, comment: &'static str) -> FieldSchema {+ FieldSchema {+ name,+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),+ comment,+ required: false,+ }+}++pub(crate) fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {+ FieldSchema {+ name,+ ty: TypeSchema::Json,+ comment,+ required: true,+ }+}diff --git a/crates/openhuman-core/src/inference/schemas/catalog.rs b/crates/openhuman-core/src/inference/schemas/catalog.rsindex cfad8ddda4..81293979e3 100644--- a/crates/openhuman-core/src/inference/schemas/catalog.rs+++ b/crates/openhuman-core/src/inference/schemas/catalog.rs@@ -2,6 +2,7 @@//! function, plus the field-shape helpers they are built from.use crate::core::{ControllerSchema, FieldSchema, TypeSchema};+use crate::inference::schema_fields::{json_output, optional_string, optional_u64, required_string};pub fn schemas(function: &str) -> ControllerSchema {match function {@@ -316,15 +317,6 @@ pub fn schemas(function: &str) -> ControllerSchema {}}-fn required_string(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::String,- comment,- required: true,- }-}-fn optional_bool(name: &'static str, comment: &'static str) -> FieldSchema {FieldSchema {name,@@ -343,15 +335,6 @@ fn required_bool(name: &'static str, comment: &'static str) -> FieldSchema {}}-fn optional_u64(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),- comment,- required: false,- }-}-fn optional_f64(name: &'static str, comment: &'static str) -> FieldSchema {FieldSchema {name,@@ -361,15 +344,6 @@ fn optional_f64(name: &'static str, comment: &'static str) -> FieldSchema {}}-fn optional_string(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Option(Box::new(TypeSchema::String)),- comment,- required: false,- }-}-fn optional_json(name: &'static str, comment: &'static str) -> FieldSchema {FieldSchema {name,@@ -379,11 +353,3 @@ fn optional_json(name: &'static str, comment: &'static str) -> FieldSchema {}}-fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {- FieldSchema {- name,- ty: TypeSchema::Json,- comment,- required: true,- }-}diff --git a/crates/openhuman-tinyhumans/src/inference/tiers.rs b/crates/openhuman-tinyhumans/src/inference/tiers.rsindex 09aba533c0..71f58ab60f 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers.rs@@ -27,16 +27,12 @@ pub(crate) fn legacy_tier_role(model: &str) -> Option<&'static str> {}fn hint_role(model: &str) -> Option<&'static str> {- match model.trim().strip_prefix("hint:")? {- "chat" => Some("chat"),- "reasoning" => Some("reasoning"),- "agentic" => Some("agentic"),- "coding" => Some("coding"),- "burst" => Some("burst"),- "summarization" => Some("summarization"),- "vision" => Some("vision"),- _ => None,- }+ let route = model.trim();+ tinyinference_llm::model::workload::WORKLOAD_ROUTE_TIERS+ .iter()+ .copied()+ .find(|candidate| *candidate == route)?+ .strip_prefix("hint:")}pub(crate) fn role_for_model(model: &str) -> Option<String> {diff --git a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rsindex 8552447bc4..383ac6773c 100644--- a/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/tiers_tests.rs@@ -225,6 +225,22 @@ fn managed_tier_vocabulary_maps_aliases_and_leaves_concrete_ids_raw() {assert!(!is_raw_model("hint:unknown"));}+#[test]+fn managed_hint_roles_follow_the_native_workload_route_order() {+ let native = tinyinference_llm::model::workload::WORKLOAD_ROUTE_TIERS+ .iter()+ .map(|route| route.strip_prefix("hint:").expect("native hint route"))+ .collect::<Vec<_>>();+ let public = openhuman_embed::__host::config::WORKLOAD_ROLES;+ assert_eq!(native, public);+ for (route, role) in tinyinference_llm::model::workload::WORKLOAD_ROUTE_TIERS+ .iter()+ .zip(native)+ {+ assert_eq!(role_for_model(route), Some(role.to_string()));+ }+}+#[test]fn hosted_vision_capabilities_cover_managed_aliases_and_media_models() {for model in [