[router] Move all protocols to spec.rs file (#9519)

This commit is contained in:
Keyang Ru
2025-08-22 14:18:47 -07:00
committed by GitHub
parent c4500233ff
commit 5ef545e678
29 changed files with 2432 additions and 2572 deletions

View File

@@ -5,13 +5,9 @@
use serde_json::{from_str, to_string, to_value};
use sglang_router_rs::core::{BasicWorker, WorkerType};
use sglang_router_rs::protocols::{
common::StringOrArray,
generate::{GenerateParameters, GenerateRequest, SamplingParams},
openai::{
chat::{ChatCompletionRequest, ChatMessage, UserMessageContent},
completions::CompletionRequest,
},
use sglang_router_rs::protocols::spec::{
ChatCompletionRequest, ChatMessage, CompletionRequest, GenerateParameters, GenerateRequest,
SamplingParams, StringOrArray, UserMessageContent,
};
/// Create a default GenerateRequest for benchmarks with minimal fields set

View File

@@ -1,8 +1,10 @@
// Integration test for Responses API
use sglang_router_rs::protocols::common::GenerationRequest;
use sglang_router_rs::protocols::openai::responses::request::ResponseInput;
use sglang_router_rs::protocols::openai::responses::*;
use sglang_router_rs::protocols::spec::{
GenerationRequest, ReasoningEffort, ResponseInput, ResponseReasoningParam, ResponseStatus,
ResponseTool, ResponseToolType, ResponsesRequest, ResponsesResponse, ServiceTier, ToolChoice,
ToolChoiceValue, Truncation, UsageInfo,
};
#[test]
fn test_responses_request_creation() {
@@ -24,7 +26,7 @@ fn test_responses_request_creation() {
store: true,
stream: false,
temperature: Some(0.7),
tool_choice: ToolChoice::Auto,
tool_choice: ToolChoice::Value(ToolChoiceValue::Auto),
tools: vec![ResponseTool {
r#type: ResponseToolType::WebSearchPreview,
}],
@@ -67,7 +69,7 @@ fn test_sampling_params_conversion() {
store: true, // Use default true
stream: false,
temperature: Some(0.8),
tool_choice: ToolChoice::Auto,
tool_choice: ToolChoice::Value(ToolChoiceValue::Auto),
tools: vec![],
top_logprobs: 0, // Use default 0
top_p: Some(0.95),
@@ -177,7 +179,7 @@ fn test_json_serialization() {
store: false,
stream: true,
temperature: Some(0.9),
tool_choice: ToolChoice::Required,
tool_choice: ToolChoice::Value(ToolChoiceValue::Required),
tools: vec![ResponseTool {
r#type: ResponseToolType::CodeInterpreter,
}],