mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-06-16 04:48:47 +02:00
Make sure to send the tool response before the error message
This commit is contained in:
parent
77cc3678b5
commit
7533a11143
@ -645,6 +645,8 @@ async fn handle_meili_tools(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut error = None;
|
||||||
|
|
||||||
let result = match serde_json::from_str(&call.function.arguments) {
|
let result = match serde_json::from_str(&call.function.arguments) {
|
||||||
Ok(SearchInIndexParameters { index_uid, q }) => match process_search_request(
|
Ok(SearchInIndexParameters { index_uid, q }) => match process_search_request(
|
||||||
index_scheduler,
|
index_scheduler,
|
||||||
@ -658,8 +660,8 @@ async fn handle_meili_tools(
|
|||||||
{
|
{
|
||||||
Ok(output) => Ok(output),
|
Ok(output) => Ok(output),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let error_text = err.to_string();
|
let error_text = format!("the search tool call failed with {err}");
|
||||||
tx.send_error(&StreamErrorEvent::from_response_error(err)).await?;
|
error = Some(err);
|
||||||
Err(error_text)
|
Err(error_text)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -686,6 +688,10 @@ async fn handle_meili_tools(
|
|||||||
}
|
}
|
||||||
|
|
||||||
chat_completion.messages.push(tool);
|
chat_completion.messages.push(tool);
|
||||||
|
|
||||||
|
if let Some(error) = error {
|
||||||
|
tx.send_error(&StreamErrorEvent::from_response_error(error)).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user