[router] remove old/oudated/useless comments across code base (#10968)

This commit is contained in:
Simo Lin
2025-09-26 13:48:50 -04:00
committed by GitHub
parent a7fe6e10a1
commit aae7ead2d0
56 changed files with 19 additions and 645 deletions

View File

@@ -12,8 +12,6 @@ async fn test_json_streaming_simple() {
let parser = JsonParser::new();
let mut state = ParseState::new();
// Phase 2 note: This test sends the full JSON at once in the last chunk
// In real streaming, chunks would be smaller
let full_json = r#"{"name": "get_weather", "arguments": {"location": "San Francisco"}}"#;
let result = parser
@@ -21,7 +19,6 @@ async fn test_json_streaming_simple() {
.await
.unwrap();
// With complete JSON sent at once, we should get ToolComplete
match result {
StreamResult::ToolComplete(tool) => {
assert_eq!(tool.function.name, "get_weather");
@@ -37,7 +34,6 @@ async fn test_json_streaming_array() {
let parser = JsonParser::new();
let mut state = ParseState::new();
// Stream a JSON array of tools
let chunks = vec![
r#"["#,
r#"{"name": "tool1", "#,
@@ -57,7 +53,6 @@ async fn test_json_streaming_array() {
}
// Current implementation may handle this differently
// We're mainly testing that it doesn't crash
assert!(tool_count <= 2, "Should parse at most 2 tools");
}
@@ -95,7 +90,6 @@ async fn test_pythonic_streaming() {
let parser = PythonicParser::new();
let mut state = ParseState::new();
// Send complete pythonic format at once
let full_input = r#"[get_weather(city="London", units="celsius")]"#;
let result = parser
@@ -149,7 +143,6 @@ async fn test_qwen_streaming() {
let parser = QwenParser::new();
let mut state = ParseState::new();
// Send complete Qwen format at once (with exact format expected by parser)
// Note: Parser expects newline after both tags
let full_input = "<tool_call>\n{\"name\": \"translate\", \"arguments\": {\"text\": \"hello\", \"to\": \"zh\"}}\n</tool_call>";
@@ -176,12 +169,10 @@ async fn test_streaming_incomplete_stays_incomplete() {
let parser = JsonParser::new();
let mut state = ParseState::new();
// Send truly incomplete JSON that can't be auto-completed
let chunks = vec![r#"{"na"#, r#"me": "#];
for chunk in chunks {
let result = parser.parse_incremental(chunk, &mut state).await.unwrap();
// Should return Incomplete for partial JSON that can't be auto-completed
assert!(
matches!(result, StreamResult::Incomplete),
"Should return Incomplete for partial JSON, got: {:?}",
@@ -189,7 +180,6 @@ async fn test_streaming_incomplete_stays_incomplete() {
);
}
// Buffer should contain the accumulated incomplete JSON
assert!(!state.buffer.is_empty());
}
@@ -198,8 +188,6 @@ async fn test_streaming_with_text_before_tool() {
let parser = JsonParser::new();
let mut state = ParseState::new();
// For streaming, the parser expects clean JSON
// Mixed text extraction only works in parse_complete, not parse_incremental
let full_input = r#"{"name": "test", "arguments": {}}"#;
let result = parser
@@ -221,10 +209,8 @@ async fn test_streaming_with_text_before_tool() {
async fn test_streaming_buffer_accumulation() {
let parser = JsonParser::new();
// Test: Complete JSON should clear buffer after parsing
let mut state = ParseState::new();
// Send partial JSON that can't be interpreted as complete
let result1 = parser
.parse_incremental(r#"{"na"#, &mut state)
.await
@@ -236,7 +222,6 @@ async fn test_streaming_buffer_accumulation() {
"Buffer should accumulate incomplete JSON"
);
// Send rest of JSON
let result2 = parser
.parse_incremental(r#"me": "test", "arguments": {}}"#, &mut state)
.await
@@ -262,7 +247,6 @@ async fn test_streaming_multiple_tools_sequential() {
let parser = QwenParser::new();
let mut state = ParseState::new();
// Send complete Qwen format with newlines
let full_input = r#"<tool_call>
{"name": "tool1", "arguments": {}}
</tool_call>"#;
@@ -286,13 +270,11 @@ async fn test_streaming_multiple_tools_sequential() {
async fn test_streaming_reset_after_error() {
let parser = JsonParser::new();
// First attempt with invalid JSON
let mut state1 = ParseState::new();
let _ = parser
.parse_incremental(r#"{"name": invalid}"#, &mut state1)
.await;
// Second attempt with valid JSON should work with fresh state
let mut state2 = ParseState::new();
let result = parser
.parse_incremental(r#"{"name": "test", "arguments": {}}"#, &mut state2)
@@ -309,7 +291,6 @@ async fn test_streaming_with_unicode_chunks() {
let parser = JsonParser::new();
let mut state = ParseState::new();
// Send complete JSON with unicode
let full_input = r#"{"name": "translate", "arguments": {"text": "Hello 世界 🌍"}}"#;
let result = parser
@@ -317,8 +298,6 @@ async fn test_streaming_with_unicode_chunks() {
.await
.unwrap();
// Phase 2 may return partial results even with complete JSON
// The important thing is that unicode is handled without crashes
match result {
StreamResult::ToolComplete(tool) => {
assert_eq!(tool.function.name, "translate");
@@ -327,10 +306,8 @@ async fn test_streaming_with_unicode_chunks() {
}
StreamResult::ToolName { name, .. } => {
assert_eq!(name, "translate");
// Phase 2 partial streaming behavior - acceptable
}
StreamResult::ToolArguments { arguments, .. } => {
// Verify unicode was preserved
let args: serde_json::Value = serde_json::from_str(&arguments).unwrap();
assert!(args["text"].as_str().unwrap().contains("世界"));
}