Make sure template errors are reported to the LLM and front-end without panicking

This commit is contained in:
Clément Renault 2025-06-11 09:27:14 +02:00
parent 506ee40dc5
commit 77cc3678b5
No known key found for this signature in database
GPG key ID: F250A4C4E3AE5F5F
4 changed files with 49 additions and 17 deletions

View file

@ -646,7 +646,7 @@ async fn handle_meili_tools(
}
let result = match serde_json::from_str(&call.function.arguments) {
Ok(SearchInIndexParameters { index_uid, q }) => process_search_request(
Ok(SearchInIndexParameters { index_uid, q }) => match process_search_request(
index_scheduler,
auth_ctrl.clone(),
search_queue,
@ -655,7 +655,14 @@ async fn handle_meili_tools(
q,
)
.await
.map_err(|e| e.to_string()),
{
Ok(output) => Ok(output),
Err(err) => {
let error_text = err.to_string();
tx.send_error(&StreamErrorEvent::from_response_error(err)).await?;
Err(error_text)
}
},
Err(err) => Err(err.to_string()),
};
@ -664,7 +671,6 @@ async fn handle_meili_tools(
if report_sources {
tx.report_sources(resp.clone(), &call.id, &documents).await?;
}
text
}
Err(err) => err,