orchestration integration (#623)

* orchestration integration

* Convert compact json to spaced json
This commit is contained in:
Shuguang Chen 2025-12-17 17:20:19 -08:00 committed by GitHub
parent d5a273f740
commit cb82a83c7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1164 additions and 1 deletions

View file

@ -1,3 +1,5 @@
pub mod llm_router;
pub mod orchestrator_model;
pub mod orchestrator_model_v1;
pub mod router_model;
pub mod router_model_v1;

View file

@ -0,0 +1,30 @@
use common::configuration::AgentUsagePreference;
use hermesllm::apis::openai::{ChatCompletionsRequest, Message};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum OrchestratorModelError {
#[error("Failed to parse JSON: {0}")]
JsonError(#[from] serde_json::Error),
}
pub type Result<T> = std::result::Result<T, OrchestratorModelError>;
/// OrchestratorModel trait for handling orchestration requests.
/// Unlike RouterModel which returns a single route, OrchestratorModel
/// can return multiple routes as the model output format is:
/// {"route": ["route_name_1", "route_name_2", ...]}
pub trait OrchestratorModel: Send + Sync {
fn generate_request(
&self,
messages: &[Message],
usage_preferences: &Option<Vec<AgentUsagePreference>>,
) -> ChatCompletionsRequest;
/// Returns a vector of (route_name, model_name) tuples for all matched routes.
fn parse_response(
&self,
content: &str,
usage_preferences: &Option<Vec<AgentUsagePreference>>,
) -> Result<Option<Vec<(String, String)>>>;
fn get_model_name(&self) -> String;
}

File diff suppressed because it is too large Load diff