-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
🕐 feat: Configurable Retention Period for Temporary Chats #7917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🕐 feat: Configurable Retention Period for Temporary Chats #7917
Conversation
c145bde
to
527a662
Compare
@ConstantTime pleae have a look at the CI failed test:
|
Addressed the above issue and build is passing now. |
packages/data-provider/src/config.ts
Outdated
@@ -503,6 +503,7 @@ export const intefaceSchema = z | |||
prompts: z.boolean().optional(), | |||
agents: z.boolean().optional(), | |||
temporaryChat: z.boolean().optional(), | |||
temporaryChatRetentionDays: z.number().min(1).max(365).optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documentation update needed: availableTools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, nitpick: rename to temporaryChatRetention
and make unit to hours for more granular customization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name update is done and documentation added here.
f990eac
to
d89ce12
Compare
thank you @ConstantTime for adding this configuration. I have a question and it is a little bit unrelated directly to this pull request, but I am curious if there is any mechanism in the code base to use this field of expiry date? or is it purely delegated to users to implement their own clean up system? we can continue chatting in the following discussion topic if you think that we shouldn't discuss it here as it's an indirect problem related to this PR: |
Hey @alifa98 The |
thanks @ConstantTime ! |
Hey @danny-avila |
* @param {TCustomConfig} [config] - The custom configuration object | ||
* @returns {number} The retention period in hours | ||
*/ | ||
function getTempChatRetentionHours(config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to packages/api
? All new backend-specific code should live, as much as possible.
Then, it gets imported from @librechat/api
after its compiled i.e. npm run build:api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Thanks for your work on this! Needed some additional changes that required moving more things over to Moved here including your original commits: |
Summary
This PR implements configurable retention periods for temporary chats, replacing the hardcoded 30-day limit with flexible configuration options via environment variables or
librechat.yaml
. Users can now set retention periods from 1 day to 1 year based on their needs.Closes #7673
Change Type
Changes Made
Core Implementation
api/server/utils/tempChatRetention.js
getTempChatRetentionDays()
: Retrieves configured retention period with validationcreateTempChatExpirationDate()
: Creates expiration dates using configured periodapi/models/Message.js
andapi/models/Conversation.js
now use configurable retentiontemporaryChatRetentionDays
to interface schema inpackages/data-provider/src/config.ts
AppService.js
to make config available to modelsConfiguration Options
TEMP_CHAT_RETENTION_DAYS=7
interface.temporaryChatRetentionDays: 14
Validation & Safety
Testing
Automated Testing
api/server/utils/__tests__/tempChatRetention.test.js
Manual Testing & Verification
Test 1: Default Behavior (30 days)
Database Verification:
Results:
Test 2: Custom 1-Day Retention
Database Verification:
Results:
Test 3: Configuration Priority
Results:
Database Schema Verification
Documentation
librechat.example.yaml
with configuration example and commentsBackward Compatibility
Performance Impact
Security Considerations