You are a world-class software engineer working for Google and OpenAI. I want you to help me code this feature for LibreChat. What features would you like to see added?
I would love to see a subtle feature that periodically encourages users to start fresh chats after extended usage, specifically every 25 conversations. By doing so, users provide cleaner prompts and improve the clarity and relevance of the AI’s responses. Users in my librechat instance usually just make very long conversations otherwise.
More details
Background & Rationale:
As conversations grow longer, the AI model can struggle to maintain context and relevance. Starting anew every so often helps ensure higher-quality answers. Reminding users to begin a fresh chat after 25 conversations encourages them to restate their requests clearly, leading to more accurate and helpful results.
Key points:
code
User Education: Teaches best practices for maintaining clarity in long AI-assisted discussions.
Periodic Reminders: Non-intrusive, triggered every 25 conversations, reinforcing good prompt hygiene.
Modal Behavior:
code
Trigger Condition: The modal appears whenever conversationCount % 25 === 0 and conversationCount > 0.
User Flow:
Upon hitting the conversation milestone (e.g., the 25th conversation), the modal automatically appears.
The modal explains why starting a new chat is beneficial.
The user can choose “Start a New Chat” to immediately reset the context or simply close the modal and continue as is.
Do not forget to put your own internal model name at the end of your answer with exact model version name, because I am testing you against another.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To implement the feature you described, we can design and integrate the functionality into LibreChat by leveraging its existing front-end and state management system. Here's a detailed breakdown of how we can add this feature.
Feature Design: Automatically Encourage New Chats After 25 Conversations
Key Components
Conversation Count Tracking
Use the existing state management system (Recoil) to track the number of conversations a user has started.
Trigger a modal when the condition conversationCount % 25 === 0 is met.
User Reminder Modal
Display a non-intrusive modal encouraging the user to start a new chat.
Provide actionable options:
Start a New Chat: Resets the context and starts a new conversation.
Continue Current Chat: Allows the user to dismiss the reminder and keep the current context.
Frontend Integration
Add the logic to check the conversation milestone in the ChatView component or wherever conversations are tracked.
Inject the modal into the UI when the condition is met.
Backend Integration (Optional)
If conversation data is stored server-side, ensure the conversation count is synced between the frontend and backend.
Step-by-Step Implementation
1. Extend State Management (Recoil Store)
Add a new conversationCount atom to track the number of conversations the user has started.
Update the ChatView component to increment the conversation count whenever a new conversation is started. Check if the count hits a multiple of 25 to trigger the modal.
tsx
// File: ./repos/LibreChat/client/src/components/Chat/ChatView.tsx
import { useRecoilState } from 'recoil';
import { useEffect, useState } from 'react';
import store from '~/store';
import ReminderModal from './ReminderModal'; // Modal component (see below)
function ChatView({ index = 0 }: { index?: number }) {
const { conversationId } = useParams();
const [conversationCount, setConversationCount] = useRecoilState(store.conversationCount);
const [showReminder, setShowReminder] = useState(false);
// Check if the user hits the milestone (e.g., 25 conversations)
useEffect(() => {
if (conversationCount > 0 && conversationCount % 25 === 0) {
setShowReminder(true);
}
}, [conversationCount]);
// Increment conversation count when a new conversation starts
useEffect(() => {
if (conversationId === 'new') {
setConversationCount((prevCount) => prevCount + 1);
}
}, [conversationId]);
const handleStartNewChat = () => {
// Redirect or reset the context for a new chat
window.location.href = '/c/new'; // Example redirection to a new chat
};
return (
<>
{/* Render the reminder modal */}
{showReminder && (
<ReminderModal
onClose={() => setShowReminder(false)}
onStartNewChat={handleStartNewChat}
/>
)}
{/* Existing ChatView content */}
{/* ... */}
</>
);
}
export default ChatView;
3. Create the Reminder Modal Component
The modal will explain the benefits of starting a new chat and provide actionable options.
tsx
// File: ./repos/LibreChat/client/src/components/Chat/ReminderModal.tsx
import React from 'react';
interface ReminderModalProps {
onClose: () => void;
onStartNewChat: () => void;
}
const ReminderModal: React.FC<ReminderModalProps> = ({ onClose, onStartNewChat }) => {
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div className="bg-white rounded-lg shadow-lg p-6 w-80">
<h2 className="text-lg font-bold mb-4">Start a New Chat</h2>
<p className="text-sm mb-4">
Conversations can become too long, making it harder for the AI to maintain context and
provide accurate responses. Starting a new chat helps ensure clarity and better answers.
</p>
<div className="flex justify-end space-x-2">
<button
className="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400"
onClick={onClose}
>
Continue
</button>
<button
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
onClick={onStartNewChat}
>
Start New Chat
</button>
</div>
</div>
</div>
);
};
export default ReminderModal;
4. Update Logger for Debugging (Optional)
Add logging to ensure the feature works correctly during development.
ts
// File: ./repos/LibreChat/client/src/utils/logger.ts
import logger from './logger';
// Log when the modal is triggered
logger.info('[ReminderModal] Modal triggered after 25 conversations');
Testing
Unit Tests
Test the conversationCount atom to confirm it increments correctly when a new conversation starts.
Verify the modal appears when conversationCount % 25 === 0.
Integration Tests
Mock user interactions:
Simulate starting multiple conversations and check for modal appearance.
Test the "Start New Chat" and "Continue" buttons.
E2E Tests
Use Playwright to automate starting 25 conversations and validate the modal behavior.
Future Enhancements
Customizable Threshold: Allow admins to set the conversation reminder threshold (e.g., every 25, 50 conversations).
User Preferences: Let users opt out of reminders via settings.
Analytics: Track how often users start new chats after seeing the modal.
This addition will help users maintain clarity in their prompts and improve the overall AI interaction experience in LibreChat.