mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-05-25 09:03:59 +02:00
Send an event with the content of the tool calling
This commit is contained in:
parent
6e8b371111
commit
e0c8c11a94
@ -324,7 +324,7 @@ async fn streamed_chat(
|
|||||||
break 'main;
|
break 'main;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(text) = content {
|
if let Some(_) = content {
|
||||||
tx.send(Event::Data(sse::Data::new_json(&resp).unwrap())).await.unwrap()
|
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());
|
.append(arguments.as_ref().unwrap());
|
||||||
}
|
}
|
||||||
tx.send(Event::Data(sse::Data::new_json(&resp).unwrap()))
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
None if !global_tool_calls.is_empty() => {
|
None if !global_tool_calls.is_empty() => {
|
||||||
// dbg!(&global_tool_calls);
|
// dbg!(&global_tool_calls);
|
||||||
@ -441,17 +438,24 @@ async fn streamed_chat(
|
|||||||
search_result.hits.into_iter().map(|doc| doc.document),
|
search_result.hits.into_iter().map(|doc| doc.document),
|
||||||
);
|
);
|
||||||
let text = formatted.join("\n");
|
let text = formatted.join("\n");
|
||||||
chat_completion.messages.push(
|
let tool = ChatCompletionRequestMessage::Tool(
|
||||||
ChatCompletionRequestMessage::Tool(
|
|
||||||
ChatCompletionRequestToolMessage {
|
ChatCompletionRequestToolMessage {
|
||||||
tool_call_id: call.id,
|
tool_call_id: call.id,
|
||||||
content:
|
content: ChatCompletionRequestToolMessageContent::Text(
|
||||||
ChatCompletionRequestToolMessageContent::Text(
|
|
||||||
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 => (),
|
None => (),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user