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.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This feature to encourage new chats after every 25 conversations is a great idea for maintaining context and improving response quality. Here's how I'd approach implementing it within the LibreChat codebase:
1. Client-Side Implementation (React):
Conversation Count Tracking: Introduce a new Recoil state variable, conversationCount, in src/store to track the number of conversations started by the user. This counter should persist across sessions, likely using local storage. Increment this counter whenever a new conversation is initiated (e.g., when the user navigates to /chat/new or creates a new conversation).
Modal Component: Create a new component, NewChatSuggestionModal, using the existing Dialog component from src/components/ui/Dialog.tsx as a template. This modal should:
Contain informative text explaining the benefits of starting a new chat (improved context, clearer prompts, better responses).
Include two buttons: "Start a New Chat" and "Continue Current Chat".
Modal Trigger Logic: In the ChatView component (src/components/Chat/ChatView.tsx), add logic to check the conversationCount after each successful conversation submission.
tsx
// Inside ChatView.tsx
import NewChatSuggestionModal from './NewChatSuggestionModal'; // Import the new modal component
import { useRecoilValue, useRecoilState } from 'recoil';
import store from '~/store';
// ... other imports and code
function ChatView({ index = 0 }: { index?: number }) {
// ... existing code
const [conversationCount, setConversationCount] = useRecoilState(store.conversationCount);
const [showModal, setShowModal] = useState(false);
// ... inside the ChatForm submission handler or useSSE callback:
const handleConversationEnd = () => {
setConversationCount((prevCount) => prevCount + 1);
if ((conversationCount + 1) % 25 === 0 && conversationCount > 0) {
setShowModal(true);
}
};
// ... rest of the component code
return (
// ... existing JSX
{showModal && (
<NewChatSuggestionModal
isOpen={showModal}
onClose={() => setShowModal(false)}
onNewChat={chatHelpers.handleNewChat} // Pass the new chat function
/>
)}
// ... existing JSX
);
}
// ... export
"Start New Chat" Action: When the user clicks "Start a New Chat", the modal should close, the conversationCount should be reset, and a new conversation should be initiated. The chatHelpers.handleNewChat function (or a similar function) should handle the logic of creating a new conversation and updating the UI accordingly. Consider using useConversations hook and its refreshConversations function to trigger a refresh of the conversation list after creating a new one.
"Continue Current Chat" Action: When the user clicks this button, simply close the modal.
2. Persistence (Local Storage):
Recoil Persistence: Implement persistence for the conversationCount state using Recoil's persistence features or a custom persistence middleware. This ensures the count is maintained even if the user closes the browser or refreshes the page. See Recoil Persistence for details on setting this up.
3. Backend Considerations (Node.js):
The backend primarily doesn't need changes for this feature since it's mostly client-side driven. However, if you want to track conversation count server-side as well (for analytics, for example), you could add a field to the user's data in your database and increment it with each new conversation created. This would require an API endpoint to update this count.
Example NewChatSuggestionModal Component:
tsx
// NewChatSuggestionModal.tsx
import { Dialog, DialogContent, DialogTitle, DialogDescription, DialogButton, DialogClose } from '~/components/ui/Dialog';
interface NewChatSuggestionModalProps {
isOpen: boolean;
onClose: () => void;
onNewChat: () => void;
}
const NewChatSuggestionModal: React.FC<NewChatSuggestionModalProps> = ({ isOpen, onClose, onNewChat }) => (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent>
<DialogTitle>Start a Fresh Chat?</DialogTitle>
<DialogDescription>
For the best results, it's recommended to start a new chat every 25 conversations. This helps the AI maintain context and provide more accurate and relevant responses.
</DialogDescription>
<div className="flex justify-end mt-4"> {/* Adjust styling as needed */}
<DialogButton onClick={onNewChat}>Start a New Chat</DialogButton>
<DialogClose onClick={onClose}>Continue Current Chat</DialogClose>
</div>
</DialogContent>
</Dialog>
);
export default NewChatSuggestionModal;
This comprehensive approach addresses the user's request, providing a subtle yet effective way to improve the overall chat experience. Remember to thoroughly test the implementation to ensure the modal appears at the correct intervals and the actions function as expected.