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(inference): add provider_model module and update registry
Steven Enamakeldf5fb4d7a67d
diff --git a/crates/openhuman-core/src/inference/mod.rs b/crates/openhuman-core/src/inference/mod.rsindex 1cdec5c27f..3b872bab8c 100644--- a/crates/openhuman-core/src/inference/mod.rs+++ b/crates/openhuman-core/src/inference/mod.rs@@ -32,6 +32,7 @@ pub mod http;pub mod model_context;pub mod ops;pub mod provider;+pub mod provider_model;pub(crate) mod reasoning;pub mod registry;mod schemas;diff --git a/crates/openhuman-core/src/inference/provider_model.rs b/crates/openhuman-core/src/inference/provider_model.rsnew file mode 100644index 0000000000..15a01b24b2--- /dev/null+++ b/crates/openhuman-core/src/inference/provider_model.rs@@ -0,0 +1,51 @@+//! Provider-neutral helpers for resolving model ids against registered model+//! vocabularies.++use crate::config::{Config, WORKLOAD_ROLES};++/// The workload role represented by a provider-specific model alias, defaulting+/// to the generic `chat` role for concrete and unknown ids.+pub fn role_for_model(provider_id: &str, model: &str) -> String {+ crate::inference::registry::provider_model_role(provider_id, model)+ .or_else(|| WORKLOAD_ROLES.contains(&model.trim()).then(|| model.trim().to_string()))+ .unwrap_or_else(|| "chat".to_string())+}++/// Whether `model` is a provider-owned alias or a concrete model id.+pub fn is_raw_model(provider_id: &str, model: &str) -> bool {+ crate::inference::registry::provider_model_is_raw(provider_id, model)+}++/// Resolve a model hint according to the configured provider route and the+/// route's registered provider model policy.+pub fn resolve_model_hint(provider_id: &str, hint: &str, config: &Config) -> String {+ let trimmed = hint.trim();+ if trimmed.is_empty() {+ return trimmed.to_string();+ }+ let Some(role) = crate::inference::registry::provider_model_role(provider_id, trimmed)+ .or_else(|| WORKLOAD_ROLES.contains(&trimmed).then(|| trimmed.to_string()))+ else {+ return trimmed.to_string();+ };++ let route = crate::inference::provider::factory::provider_for_role(&role, config);+ let route = route.trim();+ if route.is_empty()+ || route == "cloud"+ || route == provider_id+ || route == crate::inference::provider::factory::BYOK_INCOMPLETE_SENTINEL+ {+ return crate::inference::registry::resolve_provider_model(+ provider_id,+ &role,+ config,+ Some(trimmed),+ )+ .unwrap_or_else(|| trimmed.to_string());+ }+ if let Some((_, model)) = route.split_once(':') {+ return tinyinference_providers::route::split_model_and_temperature(model).0;+ }+ route.to_string()+}diff --git a/crates/openhuman-core/src/inference/registry.rs b/crates/openhuman-core/src/inference/registry.rsindex 5f149fea4c..65003d57c1 100644--- a/crates/openhuman-core/src/inference/registry.rs+++ b/crates/openhuman-core/src/inference/registry.rs@@ -227,8 +227,11 @@ pub fn provider_model_is_alias(provider_id: &str, model: &str) -> bool {/// Whether the provider regards `model` as a concrete id for pass-through.pub fn provider_model_is_raw(provider_id: &str, model: &str) -> bool {- provider_model_hooks(provider_id)- .is_none_or(|hooks| (hooks.is_raw_model)(model))+ let model = model.trim();+ !model.is_empty()+ && !model.starts_with("hint:")+ && provider_model_hooks(provider_id)+ .map_or(true, |hooks| (hooks.is_raw_model)(model))}/// Whether the provider says `model` supports image input.@@ -259,9 +262,10 @@ pub fn provider_request_without_reasoning(provider_id: &str,request: tinyinference_llm::model::ModelRequest,) -> tinyinference_llm::model::ModelRequest {- provider_model_hooks(provider_id)- .map(|hooks| (hooks.without_reasoning)(request))- .unwrap_or(request)+ match provider_model_hooks(provider_id) {+ Some(hooks) => (hooks.without_reasoning)(request),+ None => request,+ }}/// Registers a generic config normalizer, such as a provider-owned migration