-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
🕐 feat: Configurable Retention Period for Temporary Chats #8056
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 #8056
Conversation
…b.com/ConstantTime/LibreChat into ConstantTime-feat/configurable-temp-chat-retention
…rcular dependencies
…adCustomConfig tests with logger mock
…itialization inside methods
@danny-avila @ConstantTime so does this use hours or days? According to the PR description, it uses days, but in the dev branch, after the merge, you can see that it is in hours: |
My bad, should have updated PR desc also. It's in hours only. |
…a#8056) * feat: Add configurable retention period for temporary chats * Addressing eslint errors * Fix: failing test due to missing registration * Update: variable name and use hours instead of days for chat retention * Addressing comments * chore: fix import order in Conversation.js * chore: import order in Message.js * chore: fix import order in config.ts * chore: move common methods to packages/api to reduce potential for circular dependencies * refactor: update temp chat retention config type to Partial<TCustomConfig> * refactor: remove unused config variable from AppService and update loadCustomConfig tests with logger mock * refactor: handle model undefined edge case by moving Session model initialization inside methods --------- Co-authored-by: Rakshit Tiwari <[email protected]>
…a#8056) * feat: Add configurable retention period for temporary chats * Addressing eslint errors * Fix: failing test due to missing registration * Update: variable name and use hours instead of days for chat retention * Addressing comments * chore: fix import order in Conversation.js * chore: import order in Message.js * chore: fix import order in config.ts * chore: move common methods to packages/api to reduce potential for circular dependencies * refactor: update temp chat retention config type to Partial<TCustomConfig> * refactor: remove unused config variable from AppService and update loadCustomConfig tests with logger mock * refactor: handle model undefined edge case by moving Session model initialization inside methods --------- Co-authored-by: Rakshit Tiwari <[email protected]>
Originally #7917
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