mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-27 04:07:05 +00:00
⚓ fix: Skip Retention for Persistent Agent Resource Files (#13394)
This commit is contained in:
parent
06a6c42435
commit
f8d7d7f891
2 changed files with 142 additions and 2 deletions
|
|
@ -67,6 +67,17 @@ const createSanitizedUploadWrapper = (uploadFunction) => {
|
|||
};
|
||||
};
|
||||
|
||||
const isPersistentAgentResourceUpload = ({ messageAttachment, tool_resource }) =>
|
||||
!messageAttachment && !!tool_resource;
|
||||
|
||||
const getAgentFileRetentionExpiry = async ({ req, messageAttachment, tool_resource }) => {
|
||||
if (isPersistentAgentResourceUpload({ messageAttachment, tool_resource })) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return await getRetentionExpiry(req);
|
||||
};
|
||||
|
||||
const isMissingStorageError = (err) => {
|
||||
const code = err?.code ?? err?.status ?? err?.statusCode ?? err?.response?.status;
|
||||
if ([404, '404', 'ENOENT', 'NoSuchKey', 'NotFound', 'ResourceNotFound'].includes(code)) {
|
||||
|
|
@ -727,7 +738,11 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
|
|||
`Extracted text from "${file.originalname}" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.`,
|
||||
);
|
||||
}
|
||||
const retentionExpiry = await getRetentionExpiry(req);
|
||||
const retentionExpiry = await getAgentFileRetentionExpiry({
|
||||
req,
|
||||
messageAttachment,
|
||||
tool_resource,
|
||||
});
|
||||
const fileInfo = {
|
||||
...removeNullishValues({
|
||||
text,
|
||||
|
|
@ -925,7 +940,11 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
|
|||
});
|
||||
}
|
||||
|
||||
const retentionExpiry = await getRetentionExpiry(req);
|
||||
const retentionExpiry = await getAgentFileRetentionExpiry({
|
||||
req,
|
||||
messageAttachment,
|
||||
tool_resource,
|
||||
});
|
||||
const fileInfo = {
|
||||
...removeNullishValues({
|
||||
user: req.user.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue