[router]restructure protocol modules for better organization (#9321)
This commit is contained in:
36
sgl-router/src/protocols/common.rs
Normal file
36
sgl-router/src/protocols/common.rs
Normal 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>>),
|
||||
}
|
||||
Reference in New Issue
Block a user