[router]restructure protocol modules for better organization (#9321)

This commit is contained in:
Keyang Ru
2025-08-18 18:07:58 -07:00
committed by GitHub
parent 3c2c9f6c9e
commit ce67b2d586
23 changed files with 1056 additions and 951 deletions

View File

@@ -0,0 +1,36 @@
// Common types shared across all protocol implementations
use serde::{Deserialize, Serialize};
/// Helper function for serde default value
pub fn default_true() -> bool {
true
}
/// Common trait for all generation requests across different APIs
pub trait GenerationRequest: Send + Sync {
/// Check if the request is for streaming
fn is_stream(&self) -> bool;
/// Get the model name if specified
fn get_model(&self) -> Option<&str>;
/// Extract text content for routing decisions
fn extract_text_for_routing(&self) -> String;
}
/// Helper type for string or array of strings
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum StringOrArray {
String(String),
Array(Vec<String>),
}
/// LoRA adapter path - can be single path or batch of paths (SGLang extension)
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum LoRAPath {
Single(Option<String>),
Batch(Vec<Option<String>>),
}