Skip to content

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

refactor(inference): update model routing logic

Steven Enamakel3d0a4f03a8b3
diff --git a/crates/openhuman-core/src/inference/http/backend.rs b/crates/openhuman-core/src/inference/http/backend.rs
index 2d6a119658..f5222791f1 100644
--- a/crates/openhuman-core/src/inference/http/backend.rs
+++ b/crates/openhuman-core/src/inference/http/backend.rs
@@ -12,9 +12,8 @@
//! - `"openhuman"` -> OpenHuman backend (session JWT)
use async_trait::async_trait;
-use tinyinference_llm::providers::openai::server_http::{
- strip_temperature_suffix, BackendFailure, ChatBackend, ListedModel, ResolvedChat,
-};
+use tinyinference_llm::providers::openai::server_http::{BackendFailure, ChatBackend, ListedModel, ResolvedChat};
+use tinyinference_providers::route::{bare_model_route, route_owner};
use tracing::{debug, warn};
use crate::config::Config;
@@ -26,11 +25,7 @@ pub(super) struct HostChatBackend;
/// Bare model names (no `:`, not the `openhuman` sentinel) are local Ollama models.
pub(super) fn provider_string_for(model: &str) -> String {
- if model.contains(':') || model == "openhuman" {
- model.to_string()
- } else {
- format!("ollama:{model}")
- }
+ bare_model_route(model)
}
#[async_trait]
@@ -106,24 +101,20 @@ pub(super) fn configured_models(config: &Config) -> Vec<ListedModel> {
.map(str::trim)
.filter(|model| !model.is_empty())
{
- push(
- strip_temperature_suffix(default_model).to_string(),
- "openhuman",
- );
+ // A configured default is known to be managed even when its model id
+ // contains a colon (for example `qwen3:14b`).
+ push(default_model.to_string(), "openhuman");
}
for cp in &config.cloud_providers {
if let Some(ref model) = cp.default_model {
- push(
- format!("{}:{}", cp.slug, strip_temperature_suffix(model)),
- &cp.slug,
- );
+ push(route_owner(&format!("{}:{model}", cp.slug)).0, &cp.slug);
}
}
if !config.local_ai.chat_model_id.is_empty() {
push(
- format!("ollama:{}", config.local_ai.chat_model_id),
+ route_owner(&format!("ollama:{}", config.local_ai.chat_model_id)).0,
"ollama",
);
}
@@ -142,14 +133,10 @@ pub(super) fn configured_models(config: &Config) -> Vec<ListedModel> {
.map(str::trim)
.filter(|value| !value.is_empty() && *value != "cloud" && *value != "openhuman")
{
- if let Some(model) = provider_string.strip_prefix("ollama:") {
- push(
- format!("ollama:{}", strip_temperature_suffix(model)),
- "ollama",
- );
- } else if let Some((slug, model)) = provider_string.split_once(':') {
+ if let Some((slug, _)) = provider_string.split_once(':') {
if slug != "openhuman" {
- push(format!("{slug}:{}", strip_temperature_suffix(model)), slug);
+ let (id, _) = route_owner(provider_string);
+ push(id, slug);
}
}
}