orchestration integration

This commit is contained in:
Shuguang Chen 2025-11-26 15:57:23 -08:00
parent b01a81927d
commit 50c5ec9246
6 changed files with 1027 additions and 1 deletions

View file

@ -14,7 +14,7 @@ derivative = "2.2.0"
thiserror = "1.0.64"
tiktoken-rs = "0.5.9"
rand = "0.8.5"
serde_json = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
hex = "0.4.3"
urlencoding = "2.1.3"
url = "2.5.4"

View file

@ -252,6 +252,39 @@ pub struct RoutingPreference {
pub description: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct AgentUsagePreference {
pub model: String,
pub orchestration_preferences: Vec<OrchestrationPreference>,
}
/// OrchestrationPreference with custom serialization to always include default parameters.
/// The parameters field is always serialized as:
/// {"type": "object", "properties": {}, "required": []}
#[derive(Debug, Clone, Deserialize)]
pub struct OrchestrationPreference {
pub name: String,
pub description: String,
}
impl serde::Serialize for OrchestrationPreference {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut state = serializer.serialize_struct("OrchestrationPreference", 3)?;
state.serialize_field("name", &self.name)?;
state.serialize_field("description", &self.description)?;
state.serialize_field("parameters", &serde_json::json!({
"type": "object",
"properties": {},
"required": []
}))?;
state.end()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
//TODO: use enum for model, but if there is a new model, we need to update the code
pub struct LlmProvider {