feat: abort agent requests

This commit is contained in:
Danny Avila 2024-09-02 14:06:39 -04:00
parent 757f544a9b
commit 7d54f7147f
No known key found for this signature in database
GPG key ID: 2DD9CC89B9B50364
4 changed files with 26 additions and 5 deletions

View file

@ -46,6 +46,13 @@ class AgentClient extends BaseClient {
this.options = Object.assign({ endpoint: options.endpoint }, clientOptions);
}
/**
* Returns the aggregated content parts for the current run.
* @returns {MessageContentComplex[]} */
getContentParts() {
return this.contentParts;
}
setOptions(options) {
logger.info('[api/server/controllers/agents/client.js] setOptions', options);
}
@ -437,11 +444,18 @@ class AgentClient extends BaseClient {
});
logger.info(this.contentParts, { depth: null });
} catch (err) {
logger.error(
'[api/server/controllers/agents/client.js #chatCompletion] Unhandled error type',
if (!abortController.signal.aborted) {
logger.error(
'[api/server/controllers/agents/client.js #sendCompletion] Unhandled error type',
err,
);
throw err;
}
logger.warn(
'[api/server/controllers/agents/client.js #sendCompletion] Operation aborted',
err,
);
throw err;
}
}