mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
🛠️ refactor: Improve Logging and Error Handling in ToolService
and useSSE
(#2922)
* refactor(ToolService): streamline logging and tool error handling, also ensure generated outputs always have `output` field * refactor(useSSE): error message for server connection issue * refactor: add back capture group of sensitive information.js * hotfix: cohere chinese character unicode issue, return aggregated reply
This commit is contained in:
parent
a6058c5669
commit
08d6bea359
4 changed files with 34 additions and 30 deletions
|
@ -340,29 +340,26 @@ async function processRequiredActions(client, requiredActions) {
|
|||
currentAction.toolInput = currentAction.toolInput.input;
|
||||
}
|
||||
|
||||
try {
|
||||
const promise = tool
|
||||
._call(currentAction.toolInput)
|
||||
.then(handleToolOutput)
|
||||
.catch((error) => {
|
||||
logger.error(`Error processing tool ${currentAction.tool}`, error);
|
||||
return {
|
||||
tool_call_id: currentAction.toolCallId,
|
||||
output: `Error processing tool ${currentAction.tool}: ${redactMessage(error.message)}`,
|
||||
};
|
||||
});
|
||||
promises.push(promise);
|
||||
} catch (error) {
|
||||
const handleToolError = (error) => {
|
||||
logger.error(
|
||||
`tool_call_id: ${currentAction.toolCallId} | Error processing tool ${currentAction.tool}`,
|
||||
error,
|
||||
);
|
||||
promises.push(
|
||||
Promise.resolve({
|
||||
tool_call_id: currentAction.toolCallId,
|
||||
error: error.message,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
tool_call_id: currentAction.toolCallId,
|
||||
output: `Error processing tool ${currentAction.tool}: ${redactMessage(error.message, 256)}`,
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
const promise = tool
|
||||
._call(currentAction.toolInput)
|
||||
.then(handleToolOutput)
|
||||
.catch(handleToolError);
|
||||
promises.push(promise);
|
||||
} catch (error) {
|
||||
const toolOutputError = handleToolError(error);
|
||||
promises.push(Promise.resolve(toolOutputError));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue