feat: reasoning_content in API for reasoning models (#6322)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
@@ -336,19 +336,19 @@ fn format_message_for_compacting(msg: &Message) -> String {
|
||||
let content_parts: Vec<String> = msg
|
||||
.content
|
||||
.iter()
|
||||
.map(|content| match content {
|
||||
MessageContent::Text(text) => text.text.clone(),
|
||||
MessageContent::Image(img) => format!("[image: {}]", img.mime_type),
|
||||
.filter_map(|content| match content {
|
||||
MessageContent::Text(text) => Some(text.text.clone()),
|
||||
MessageContent::Image(img) => Some(format!("[image: {}]", img.mime_type)),
|
||||
MessageContent::ToolRequest(req) => {
|
||||
if let Ok(call) = &req.tool_call {
|
||||
format!(
|
||||
Some(format!(
|
||||
"tool_request({}): {}",
|
||||
call.name,
|
||||
serde_json::to_string(&call.arguments)
|
||||
.unwrap_or_else(|_| "<<invalid json>>".to_string())
|
||||
)
|
||||
))
|
||||
} else {
|
||||
"tool_request: [error]".to_string()
|
||||
Some("tool_request: [error]".to_string())
|
||||
}
|
||||
}
|
||||
MessageContent::ToolResponse(res) => {
|
||||
@@ -362,40 +362,41 @@ fn format_message_for_compacting(msg: &Message) -> String {
|
||||
.collect();
|
||||
|
||||
if !text_items.is_empty() {
|
||||
format!("tool_response: {}", text_items.join("\n"))
|
||||
Some(format!("tool_response: {}", text_items.join("\n")))
|
||||
} else {
|
||||
"tool_response: [non-text content]".to_string()
|
||||
Some("tool_response: [non-text content]".to_string())
|
||||
}
|
||||
} else {
|
||||
"tool_response: [error]".to_string()
|
||||
Some("tool_response: [error]".to_string())
|
||||
}
|
||||
}
|
||||
MessageContent::ToolConfirmationRequest(req) => {
|
||||
format!("tool_confirmation_request: {}", req.tool_name)
|
||||
Some(format!("tool_confirmation_request: {}", req.tool_name))
|
||||
}
|
||||
MessageContent::ActionRequired(action) => match &action.data {
|
||||
ActionRequiredData::ToolConfirmation { tool_name, .. } => {
|
||||
format!("action_required(tool_confirmation): {}", tool_name)
|
||||
Some(format!("action_required(tool_confirmation): {}", tool_name))
|
||||
}
|
||||
ActionRequiredData::Elicitation { message, .. } => {
|
||||
format!("action_required(elicitation): {}", message)
|
||||
Some(format!("action_required(elicitation): {}", message))
|
||||
}
|
||||
ActionRequiredData::ElicitationResponse { id, .. } => {
|
||||
format!("action_required(elicitation_response): {}", id)
|
||||
Some(format!("action_required(elicitation_response): {}", id))
|
||||
}
|
||||
},
|
||||
MessageContent::FrontendToolRequest(req) => {
|
||||
if let Ok(call) = &req.tool_call {
|
||||
format!("frontend_tool_request: {}", call.name)
|
||||
Some(format!("frontend_tool_request: {}", call.name))
|
||||
} else {
|
||||
"frontend_tool_request: [error]".to_string()
|
||||
Some("frontend_tool_request: [error]".to_string())
|
||||
}
|
||||
}
|
||||
MessageContent::Thinking(_) => "thinking".to_string(),
|
||||
MessageContent::RedactedThinking(_) => "redacted_thinking".to_string(),
|
||||
MessageContent::Thinking(_) => None,
|
||||
MessageContent::RedactedThinking(_) => None,
|
||||
MessageContent::SystemNotification(notification) => {
|
||||
format!("system_notification: {}", notification.msg)
|
||||
Some(format!("system_notification: {}", notification.msg))
|
||||
}
|
||||
MessageContent::Reasoning(_) => None,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user