[model-gateway] Improve logging across core modules (#15497)

This commit is contained in:
Simo Lin
2025-12-19 13:35:28 -08:00
committed by GitHub
parent 6afc5d497b
commit ba72e759ca
19 changed files with 73 additions and 66 deletions
@@ -153,7 +153,7 @@ impl ToolParser for DeepSeekParser {
match self.parse_tool_call(mat.as_str()) {
Ok(tool) => tools.push(tool),
Err(e) => {
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
continue;
}
}
@@ -205,7 +205,7 @@ impl ToolParser for DeepSeekParser {
// Validate tool name
if !tool_indices.contains_key(func_name) {
// Invalid tool name - skip this tool, preserve indexing for next tool
tracing::warn!("Invalid tool name '{}' - skipping", func_name);
tracing::debug!("Invalid tool name '{}' - skipping", func_name);
helpers::reset_current_tool_state(
&mut self.buffer,
&mut self.current_tool_name_sent,
@@ -146,7 +146,7 @@ impl Glm4MoeParser {
Ok(Some(tool)) => tools.push(tool),
Ok(None) => continue,
Err(e) => {
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
continue;
}
}
@@ -254,7 +254,7 @@ impl ToolParser for Glm4MoeParser {
// Validate tool name
if !tool_indices.contains_key(&tool_call.function.name) {
// Invalid tool name - skip this tool, preserve indexing for next tool
tracing::warn!("Invalid tool name '{}' - skipping", tool_call.function.name);
tracing::debug!("Invalid tool name '{}' - skipping", tool_call.function.name);
helpers::reset_current_tool_state(
&mut self.buffer,
&mut false, // glm4_moe doesn't track name_sent per tool
@@ -234,7 +234,7 @@ pub fn handle_json_tool_streaming(
if let Some(name) = obj.get("name").and_then(|v| v.as_str()) {
if !tool_indices.contains_key(name) {
// Invalid tool name - skip this tool, preserve indexing for next tool
tracing::warn!("Invalid tool name '{}' - skipping", name);
tracing::debug!("Invalid tool name '{}' - skipping", name);
reset_current_tool_state(
buffer,
current_tool_name_sent,
@@ -202,7 +202,7 @@ impl ToolParser for JsonParser {
match parsed {
Ok(tools) => return Ok((normal_text, tools)),
Err(e) => tracing::warn!("parse_complete failed: {:?}", e),
Err(e) => tracing::debug!("parse_complete failed: {:?}", e),
}
}
@@ -137,7 +137,7 @@ impl ToolParser for KimiK2Parser {
});
}
Err(e) => {
tracing::warn!(
tracing::debug!(
"Failed to parse JSON arguments for {}: {}",
func_name,
e
@@ -146,7 +146,7 @@ impl ToolParser for KimiK2Parser {
}
}
} else {
tracing::warn!("Failed to parse function ID: {}", function_id);
tracing::debug!("Failed to parse function ID: {}", function_id);
continue;
}
}
@@ -204,7 +204,7 @@ impl ToolParser for KimiK2Parser {
// Validate tool name
if !tool_indices.contains_key(&func_name) {
// Invalid tool name - skip this tool, preserve indexing for next tool
tracing::warn!("Invalid tool name '{}' - skipping", func_name);
tracing::debug!("Invalid tool name '{}' - skipping", func_name);
helpers::reset_current_tool_state(
&mut self.buffer,
&mut self.current_tool_name_sent,
@@ -115,7 +115,7 @@ impl LlamaParser {
}
Err(e) => {
// Skip invalid JSON parts in semicolon-separated list
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
}
}
}
@@ -157,7 +157,7 @@ impl ToolParser for LlamaParser {
});
parsed.unwrap_or_else(|e| {
tracing::warn!("Failed to parse tool call: {:?}", e);
tracing::debug!("Failed to parse tool call: {:?}", e);
vec![]
})
};
@@ -181,7 +181,7 @@ impl MinimaxM2Parser {
}
Ok(None) => continue,
Err(e) => {
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
continue;
}
}
@@ -455,7 +455,7 @@ impl ToolParser for MinimaxM2Parser {
continue;
} else {
// Invalid function name, reset state
tracing::warn!("Invalid function name: {}", function_name);
tracing::debug!("Invalid function name: {}", function_name);
self.in_tool_call = false;
normal_text.push_str(&self.buffer);
self.buffer.clear();
@@ -189,7 +189,7 @@ impl ToolParser for MistralParser {
Ok(tools) => Ok((normal_text_before, tools)),
Err(e) => {
// If JSON parsing fails, return the original text as normal text
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
Ok((text.to_string(), vec![]))
}
}
@@ -111,8 +111,8 @@ impl ToolParser for PythonicParser {
}
}
Err(e) => {
// Log warning and return entire text as fallback
tracing::warn!("Failed to parse pythonic tool calls: {}", e);
// Log and return entire text as fallback
tracing::debug!("Failed to parse pythonic tool calls: {}", e);
Ok((text.to_string(), vec![]))
}
}
@@ -156,7 +156,7 @@ impl ToolParser for PythonicParser {
.enumerate()
.filter_map(|(idx, tool)| {
if !tool_indices.contains_key(&tool.function.name) {
tracing::warn!(
tracing::debug!(
"Invalid tool name '{}' - skipping",
tool.function.name
);
@@ -177,7 +177,7 @@ impl ToolParser for PythonicParser {
});
}
Err(e) => {
tracing::warn!("Failed to parse pythonic tool call: {}", e);
tracing::debug!("Failed to parse pythonic tool call: {}", e);
// Clear buffer on error
self.buffer.clear();
return Ok(StreamingParseResult::default());
@@ -133,7 +133,7 @@ impl ToolParser for QwenParser {
Ok(Some(tool)) => tools.push(tool),
Ok(None) => continue,
Err(e) => {
tracing::warn!("Failed to parse tool call: {:?}", e);
tracing::debug!("Failed to parse tool call: {:?}", e);
continue;
}
}
@@ -181,7 +181,7 @@ impl Step3Parser {
});
} else {
// Invalid function name
tracing::warn!("Invalid function name: {}", func_name);
tracing::debug!("Invalid function name: {}", func_name);
self.reset_streaming_state();
return Ok(StreamingParseResult {
normal_text: String::new(),
@@ -433,7 +433,7 @@ impl ToolParser for Step3Parser {
Ok(Some(tool)) => tools.push(tool),
Ok(None) => continue,
Err(e) => {
tracing::warn!("Failed to parse tool call: {}", e);
tracing::debug!("Failed to parse tool call: {}", e);
continue;
}
}