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(search): add configurable search provider settings
Steven Enamakeld0fa78fd76f5
diff --git a/crates/openhuman-core/src/config/schema/tools/search.rs b/crates/openhuman-core/src/config/schema/tools/search.rsindex 14f57c2532..d60dda8655 100644--- a/crates/openhuman-core/src/config/schema/tools/search.rs+++ b/crates/openhuman-core/src/config/schema/tools/search.rs@@ -211,69 +211,7 @@ impl SearchEngineCredentials {}}-/// How calls to a provider are routed.-#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]-#[serde(rename_all = "snake_case")]-pub enum ProviderRoute {- /// Through the TinyHumans backend with the session credential.- Managed,- /// Straight to the provider with the user's own key.- #[default]- Direct,-}--impl ProviderRoute {- pub fn as_str(self) -> &'static str {- match self {- Self::Managed => "managed",- Self::Direct => "direct",- }- }-- pub fn parse(value: &str) -> Option<Self> {- match value.trim().to_ascii_lowercase().as_str() {- "managed" | "backend" => Some(Self::Managed),- "direct" => Some(Self::Direct),- _ => None,- }- }-}--/// How search tools are presented to the agent.-#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]-#[serde(rename_all = "snake_case")]-pub enum PresentationMode {- /// One tool per capability role (the default).- #[default]- Roles,- /// Every usable provider's own tools.- AllTools,- /// One `search` router tool with a provider argument.- Router,- /// Only the tools of `presentation_provider`.- OneProvider,-}--impl PresentationMode {- pub fn as_str(self) -> &'static str {- match self {- Self::Roles => "roles",- Self::AllTools => "all_tools",- Self::Router => "router",- Self::OneProvider => "one_provider",- }- }-- pub fn parse(value: &str) -> Option<Self> {- match value.trim().to_ascii_lowercase().as_str() {- "roles" => Some(Self::Roles),- "all_tools" => Some(Self::AllTools),- "router" => Some(Self::Router),- "one_provider" => Some(Self::OneProvider),- _ => None,- }- }-}+pub use tinysearch_bus::{PresentationMode, ProviderRoute};/// Per-provider selection.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]@@ -281,7 +219,9 @@ impl PresentationMode {pub struct SearchProviderSettings {/// Whether the user turned this provider on.pub enabled: bool,- /// Managed or direct.+ /// Managed or direct. Serialized as `managed` / `direct`.+ #[serde(with = "tinysearch_bus::managed_route")]+ #[schemars(with = "String")]pub route: ProviderRoute,}diff --git a/crates/openhuman-core/src/modules/search/mod.rs b/crates/openhuman-core/src/modules/search/mod.rsindex 0547d94e42..f434c7a522 100644--- a/crates/openhuman-core/src/modules/search/mod.rs+++ b/crates/openhuman-core/src/modules/search/mod.rs@@ -15,7 +15,7 @@ use tinysearch_bus::{ProviderRoute, SearchConfig as ModuleSearchConfig,};-use crate::config::{Config, PresentationMode, ProviderRoute};+use crate::config::Config;use crate::search::providers::{self, ResolvedProvider, ROLES};mod proxy;@@ -143,12 +143,7 @@ pub fn module_config(config: &Config) -> ModuleSearchConfig {.map(|role| (role, providers::role_order(config, role))).collect();let presentation = PresentationConfig {- mode: match config.search.presentation {- PresentationMode::Roles => PresentationMode::Roles,- PresentationMode::AllTools => PresentationMode::AllTools,- PresentationMode::Router => PresentationMode::Router,- PresentationMode::OneProvider => PresentationMode::OneProvider,- },+ mode: config.search.presentation,provider: config.search.presentation_provider.clone(),roles,};diff --git a/crates/openhuman-core/src/search/providers.rs b/crates/openhuman-core/src/search/providers.rsindex 59aa5b7b43..cf6cb695b3 100644--- a/crates/openhuman-core/src/search/providers.rs+++ b/crates/openhuman-core/src/search/providers.rs@@ -8,9 +8,11 @@//! into the TinySearch module configuration. Provider execution is not here.use serde::Serialize;-use tinysearch_bus::{default_role_providers, provider_roles, Role};+use tinysearch_bus::{+ default_role_providers, provider_roles, role_key, ProviderRoute, Role,+};-use crate::config::{Config, ProviderRoute, MANAGED_SEARCH_PROVIDERS, SEARCH_PROVIDERS};+use crate::config::{Config, MANAGED_SEARCH_PROVIDERS, SEARCH_PROVIDERS};/// One provider's resolved state.#[derive(Debug, Clone, PartialEq, Eq, Serialize)]@@ -20,6 +22,7 @@ pub struct ResolvedProvider {/// Selected by the user.pub enabled: bool,/// Chosen route (always `direct` for providers that cannot be managed).+ #[serde(serialize_with = "tinysearch_bus::managed_route::serialize")]pub route: ProviderRoute,/// Whether the provider can be reached through the managed backend.pub managed_capable: bool,@@ -158,23 +161,6 @@ pub fn effective_role_providers(.collect()}-/// All roles, in display order.-pub const ROLES: [Role; 3] = [Role::Search, Role::Answer, Role::Contents];--/// The `[search.roles]` key for a role — its serde name.-pub fn role_key(role: Role) -> &'static str {- match role {- Role::Search => crate::config::SEARCH_ROLE_SEARCH,- Role::Answer => crate::config::SEARCH_ROLE_ANSWER,- Role::Contents => crate::config::SEARCH_ROLE_CONTENTS,- }-}--/// Parse a `[search.roles]` key.-pub fn parse_role(key: &str) -> Option<Role> {- ROLES.into_iter().find(|role| role_key(*role) == key.trim())-}-#[cfg(test)]#[path = "providers_tests.rs"]mod tests;