[router] remove old/oudated/useless comments across code base (#10968)
This commit is contained in:
@@ -49,12 +49,6 @@ use std::collections::HashMap;
|
||||
// - StringOrArray & LoRAPath types
|
||||
// - Helper functions
|
||||
|
||||
// ==================================================================
|
||||
// = OPENAI SPEC - Chat Completions API =
|
||||
// ==================================================================
|
||||
|
||||
// ============= Message Types =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum ChatMessage {
|
||||
@@ -119,8 +113,6 @@ pub struct ImageUrl {
|
||||
pub detail: Option<String>, // "auto", "low", or "high"
|
||||
}
|
||||
|
||||
// ============= Response Format Types =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ResponseFormat {
|
||||
@@ -140,8 +132,6 @@ pub struct JsonSchemaFormat {
|
||||
pub strict: Option<bool>,
|
||||
}
|
||||
|
||||
// ============= Streaming Delta Types =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ChatMessageDelta {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -177,8 +167,6 @@ pub struct FunctionCallDelta {
|
||||
pub arguments: Option<String>,
|
||||
}
|
||||
|
||||
// ============= Request =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
||||
pub struct ChatCompletionRequest {
|
||||
/// A list of messages comprising the conversation so far
|
||||
@@ -299,7 +287,6 @@ pub struct ChatCompletionRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub verbosity: Option<i32>,
|
||||
|
||||
// ============= SGLang Extensions =============
|
||||
/// Top-k sampling parameter (-1 to disable)
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub top_k: Option<i32>,
|
||||
@@ -423,8 +410,6 @@ impl GenerationRequest for ChatCompletionRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Regular Response =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ChatCompletionResponse {
|
||||
pub id: String,
|
||||
@@ -453,8 +438,6 @@ pub struct ChatChoice {
|
||||
pub hidden_states: Option<Vec<f32>>,
|
||||
}
|
||||
|
||||
// ============= Streaming Response =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ChatCompletionStreamResponse {
|
||||
pub id: String,
|
||||
@@ -477,9 +460,6 @@ pub struct ChatStreamChoice {
|
||||
pub finish_reason: Option<String>,
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = OPENAI SPEC - Completions API =
|
||||
// ==================================================================
|
||||
// Completions API request types (v1/completions) - DEPRECATED but still supported
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
@@ -554,7 +534,6 @@ pub struct CompletionRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub seed: Option<i64>,
|
||||
|
||||
// ============= SGLang Extensions =============
|
||||
/// Top-k sampling parameter (-1 to disable)
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub top_k: Option<i32>,
|
||||
@@ -599,7 +578,6 @@ pub struct CompletionRequest {
|
||||
#[serde(default = "default_true")]
|
||||
pub skip_special_tokens: bool,
|
||||
|
||||
// ============= SGLang Extensions =============
|
||||
/// Path to LoRA adapter(s) for model customization
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub lora_path: Option<LoRAPath>,
|
||||
@@ -638,8 +616,6 @@ impl GenerationRequest for CompletionRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Regular Response =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct CompletionResponse {
|
||||
pub id: String,
|
||||
@@ -668,8 +644,6 @@ pub struct CompletionChoice {
|
||||
pub hidden_states: Option<Vec<f32>>,
|
||||
}
|
||||
|
||||
// ============= Streaming Response =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct CompletionStreamResponse {
|
||||
pub id: String,
|
||||
@@ -690,12 +664,6 @@ pub struct CompletionStreamChoice {
|
||||
pub finish_reason: Option<String>,
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = OPENAI SPEC - Responses API =
|
||||
// ==================================================================
|
||||
|
||||
// ============= Tool Definitions =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ResponseTool {
|
||||
#[serde(rename = "type")]
|
||||
@@ -709,8 +677,6 @@ pub enum ResponseToolType {
|
||||
CodeInterpreter,
|
||||
}
|
||||
|
||||
// ============= Reasoning Configuration =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ResponseReasoningParam {
|
||||
#[serde(default = "default_reasoning_effort")]
|
||||
@@ -729,8 +695,6 @@ pub enum ReasoningEffort {
|
||||
High,
|
||||
}
|
||||
|
||||
// ============= Input/Output Items =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -790,8 +754,6 @@ pub enum ResponseReasoningContent {
|
||||
ReasoningText { text: String },
|
||||
}
|
||||
|
||||
// ============= Output Items for Response =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -823,8 +785,6 @@ pub enum ResponseOutputItem {
|
||||
},
|
||||
}
|
||||
|
||||
// ============= Service Tier =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ServiceTier {
|
||||
@@ -841,8 +801,6 @@ impl Default for ServiceTier {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Truncation =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Truncation {
|
||||
@@ -856,8 +814,6 @@ impl Default for Truncation {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Response Status =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ResponseStatus {
|
||||
@@ -868,8 +824,6 @@ pub enum ResponseStatus {
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
// ============= Reasoning Info =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ReasoningInfo {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -878,8 +832,6 @@ pub struct ReasoningInfo {
|
||||
pub summary: Option<String>,
|
||||
}
|
||||
|
||||
// ============= Text Format =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ResponseTextFormat {
|
||||
pub format: TextFormatType,
|
||||
@@ -891,8 +843,6 @@ pub struct TextFormatType {
|
||||
pub format_type: String,
|
||||
}
|
||||
|
||||
// ============= Include Fields =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum IncludeField {
|
||||
@@ -910,8 +860,6 @@ pub enum IncludeField {
|
||||
ReasoningEncryptedContent,
|
||||
}
|
||||
|
||||
// ============= Usage Info =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct UsageInfo {
|
||||
pub prompt_tokens: u32,
|
||||
@@ -928,8 +876,6 @@ pub struct PromptTokenUsageInfo {
|
||||
pub cached_tokens: u32,
|
||||
}
|
||||
|
||||
// ============= Response Usage Format =============
|
||||
|
||||
/// OpenAI Responses API usage format (different from standard UsageInfo)
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ResponseUsage {
|
||||
@@ -1038,7 +984,6 @@ fn generate_request_id() -> String {
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct ResponsesRequest {
|
||||
// ============= Core OpenAI API fields =============
|
||||
/// Run the request in the background
|
||||
#[serde(default)]
|
||||
pub background: bool,
|
||||
@@ -1122,7 +1067,6 @@ pub struct ResponsesRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub user: Option<String>,
|
||||
|
||||
// ============= SGLang Extensions =============
|
||||
/// Request ID
|
||||
#[serde(default = "generate_request_id")]
|
||||
pub request_id: String,
|
||||
@@ -1606,8 +1550,6 @@ impl ResponsesResponse {
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Helper Functions =============
|
||||
|
||||
impl ResponseOutputItem {
|
||||
/// Create a new message output item
|
||||
pub fn new_message(
|
||||
@@ -1708,20 +1650,12 @@ impl UsageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = OPENAI SPEC - Common =
|
||||
// ==================================================================
|
||||
|
||||
// ============= Shared Request Components =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct StreamOptions {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub include_usage: Option<bool>,
|
||||
}
|
||||
|
||||
// ============= Tool Choice Types =============
|
||||
|
||||
/// Tool choice value for simple string options
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -1793,8 +1727,6 @@ pub struct FunctionCallResponse {
|
||||
pub arguments: Option<String>, // JSON string
|
||||
}
|
||||
|
||||
// ============= Usage Tracking =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Usage {
|
||||
pub prompt_tokens: u32,
|
||||
@@ -1809,8 +1741,6 @@ pub struct CompletionTokensDetails {
|
||||
pub reasoning_tokens: Option<u32>,
|
||||
}
|
||||
|
||||
// ============= Logprobs Types =============
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct LogProbs {
|
||||
pub tokens: Vec<String>,
|
||||
@@ -1860,10 +1790,6 @@ pub struct ErrorDetail {
|
||||
pub code: Option<String>,
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = SGLANG SPEC - GENERATE API =
|
||||
// ==================================================================
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum InputIds {
|
||||
@@ -1975,7 +1901,6 @@ pub struct GenerateRequest {
|
||||
#[serde(default)]
|
||||
pub return_logprob: bool,
|
||||
|
||||
// ============= SGLang Extensions =============
|
||||
/// Path to LoRA adapter(s) for model customization
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub lora_path: Option<LoRAPath>,
|
||||
@@ -2036,10 +1961,6 @@ impl GenerationRequest for GenerateRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = SGLANG SPEC - RERANK API =
|
||||
// ==================================================================
|
||||
|
||||
// Constants for rerank API
|
||||
pub const DEFAULT_MODEL_NAME: &str = "default";
|
||||
|
||||
@@ -2237,10 +2158,6 @@ impl RerankResponse {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = OPENAI SPEC - Embeddings API =
|
||||
// ==================================================================
|
||||
|
||||
/// Embeddings request compatible with OpenAI API
|
||||
/// We intentionally keep fields flexible to pass through to workers.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
@@ -2292,10 +2209,6 @@ impl GenerationRequest for EmbeddingRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = COMMON =
|
||||
// ==================================================================
|
||||
|
||||
/// Helper function for serde default value
|
||||
pub fn default_true() -> bool {
|
||||
true
|
||||
@@ -2359,10 +2272,6 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::{from_str, json, to_string};
|
||||
|
||||
// ==================================================================
|
||||
// = RERANK REQUEST TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_rerank_request_serialization() {
|
||||
let request = RerankRequest {
|
||||
@@ -2534,10 +2443,6 @@ mod tests {
|
||||
assert_eq!(request.effective_top_k(), 3);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = RERANK RESPONSE TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_rerank_response_creation() {
|
||||
let results = vec![
|
||||
@@ -2709,10 +2614,6 @@ mod tests {
|
||||
assert_eq!(response.results[0].document, None);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = RERANK RESULT TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_rerank_result_serialization() {
|
||||
let result = RerankResult {
|
||||
@@ -2755,10 +2656,6 @@ mod tests {
|
||||
assert_eq!(deserialized.meta_info, result.meta_info);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = V1 COMPATIBILITY TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_v1_rerank_req_input_serialization() {
|
||||
let v1_input = V1RerankReqInput {
|
||||
@@ -2791,10 +2688,6 @@ mod tests {
|
||||
assert_eq!(request.user, None);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = GENERATION REQUEST TRAIT TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_rerank_request_generation_request_trait() {
|
||||
let request = RerankRequest {
|
||||
@@ -2812,10 +2705,6 @@ mod tests {
|
||||
assert_eq!(request.extract_text_for_routing(), "test query");
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = EDGE CASES AND STRESS TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_rerank_request_very_long_query() {
|
||||
let long_query = "a".repeat(100000);
|
||||
@@ -2918,10 +2807,6 @@ mod tests {
|
||||
assert_eq!(usage.total_tokens, 150);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = INTEGRATION TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_full_rerank_workflow() {
|
||||
// Create request
|
||||
@@ -2980,7 +2865,6 @@ mod tests {
|
||||
// Apply top_k
|
||||
response.apply_top_k(request.effective_top_k());
|
||||
|
||||
// Verify results
|
||||
assert_eq!(response.results.len(), 2);
|
||||
assert_eq!(response.results[0].score, 0.95);
|
||||
assert_eq!(response.results[0].index, 0);
|
||||
@@ -2995,10 +2879,6 @@ mod tests {
|
||||
assert_eq!(deserialized.model, response.model);
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// = EMBEDDINGS REQUEST TESTS =
|
||||
// ==================================================================
|
||||
|
||||
#[test]
|
||||
fn test_embedding_request_serialization_string_input() {
|
||||
let req = EmbeddingRequest {
|
||||
|
||||
Reference in New Issue
Block a user