feat: 更新工具调用的ID处理逻辑,确保在缺失时生成唯一ID
This commit is contained in:
parent
86543f19fe
commit
87fc8cc3b7
@ -767,7 +767,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
let tc_reasoning = if has_content_or_reasoning { None } else { msg.reasoning_content.clone() };
|
||||
for tool_call in tool_calls {
|
||||
outbound.push(WsOutbound::ToolCall {
|
||||
id: msg.id.clone(),
|
||||
id: tool_call.id.clone(),
|
||||
tool_call_id: tool_call.id.clone(),
|
||||
tool_name: tool_call.name.clone(),
|
||||
arguments: tool_call.arguments.clone(),
|
||||
@ -798,7 +798,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
let tool_state = msg.tool_state.as_ref().unwrap_or(&ToolMessageState::Completed);
|
||||
match tool_state {
|
||||
ToolMessageState::Completed => vec![WsOutbound::ToolResult {
|
||||
id: msg.id.clone(),
|
||||
id: msg.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
|
||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: msg.tool_name.clone().unwrap_or_default(),
|
||||
content: msg.content.clone(),
|
||||
@ -809,7 +809,7 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
}],
|
||||
ToolMessageState::PendingUserAction => vec![WsOutbound::ToolPending {
|
||||
id: msg.id.clone(),
|
||||
id: msg.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
|
||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: msg.tool_name.clone().unwrap_or_default(),
|
||||
content: msg.content.clone(),
|
||||
|
||||
@ -32,7 +32,7 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec<WsOutb
|
||||
// AssistantResponse 已携带 reasoning 时,ToolCall 不再重复
|
||||
let tc_reasoning = if has_content_or_reasoning { None } else { message.reasoning_content.clone() };
|
||||
outbound.extend(tool_calls.iter().map(|tool_call| WsOutbound::ToolCall {
|
||||
id: message.id.clone(),
|
||||
id: tool_call.id.clone(),
|
||||
tool_call_id: tool_call.id.clone(),
|
||||
tool_name: tool_call.name.clone(),
|
||||
arguments: tool_call.arguments.clone(),
|
||||
@ -63,7 +63,7 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec<WsOutb
|
||||
.unwrap_or(&ToolMessageState::Completed)
|
||||
{
|
||||
ToolMessageState::Completed => vec![WsOutbound::ToolResult {
|
||||
id: message.id.clone(),
|
||||
id: message.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
|
||||
tool_call_id: message.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: message.tool_name.clone().unwrap_or_default(),
|
||||
content: message.content.clone(),
|
||||
@ -74,7 +74,7 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec<WsOutb
|
||||
timestamp: None,
|
||||
}],
|
||||
ToolMessageState::PendingUserAction => vec![WsOutbound::ToolPending {
|
||||
id: message.id.clone(),
|
||||
id: message.tool_call_id.clone().unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
|
||||
tool_call_id: message.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: message.tool_name.clone().unwrap_or_default(),
|
||||
content: message.content.clone(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user