Send an event with the content of the tool calling

This commit is contained in:
Clément Renault 2025-05-14 17:15:32 +02:00 committed by Kerollmops
parent 0f2ddf560b
commit 59873fdc6c
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -324,7 +324,7 @@ async fn streamed_chat(
break 'main;
}
if let Some(text) = content {
if let Some(_) = content {
tx.send(Event::Data(sse::Data::new_json(&resp).unwrap())).await.unwrap()
}
@ -348,9 +348,6 @@ async fn streamed_chat(
})
.append(arguments.as_ref().unwrap());
}
tx.send(Event::Data(sse::Data::new_json(&resp).unwrap()))
.await
.unwrap()
}
None if !global_tool_calls.is_empty() => {
// dbg!(&global_tool_calls);
@ -441,17 +438,24 @@ async fn streamed_chat(
search_result.hits.into_iter().map(|doc| doc.document),
);
let text = formatted.join("\n");
chat_completion.messages.push(
ChatCompletionRequestMessage::Tool(
ChatCompletionRequestToolMessage {
tool_call_id: call.id,
content:
ChatCompletionRequestToolMessageContent::Text(
text,
),
},
),
let tool = ChatCompletionRequestMessage::Tool(
ChatCompletionRequestToolMessage {
tool_call_id: call.id,
content: ChatCompletionRequestToolMessageContent::Text(
text,
),
},
);
tx.send(Event::Data(
sse::Data::new_json(&json!({
"object": "chat.completion.tool.event",
"tool": tool,
}))
.unwrap(),
))
.await
.unwrap();
chat_completion.messages.push(tool);
}
}
None => (),