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