mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
📝 refactor: Memory Instructions for Improved Performance (#8463)
This commit is contained in:
parent
aeeb860fe0
commit
a9f01bb86f
1 changed files with 23 additions and 22 deletions
|
|
@ -40,33 +40,33 @@ export const memoryInstructions =
|
|||
const getDefaultInstructions = (
|
||||
validKeys?: string[],
|
||||
tokenLimit?: number,
|
||||
) => `Use the \`set_memory\` tool to save important information about the user, but ONLY when the user has explicitly provided this information. If there is nothing to note about the user specifically, END THE TURN IMMEDIATELY.
|
||||
) => `Use the \`set_memory\` tool to save important information about the user, but ONLY when the user has requested you to remember something.
|
||||
|
||||
The \`delete_memory\` tool should only be used in two scenarios:
|
||||
The \`delete_memory\` tool should only be used in two scenarios:
|
||||
1. When the user explicitly asks to forget or remove specific information
|
||||
2. When updating existing memories, use the \`set_memory\` tool instead of deleting and re-adding the memory.
|
||||
|
||||
${
|
||||
validKeys && validKeys.length > 0
|
||||
? `CRITICAL INSTRUCTION: Only the following keys are valid for storing memories:
|
||||
${validKeys.map((key) => `- ${key}`).join('\n ')}`
|
||||
: 'You can use any appropriate key to store memories about the user.'
|
||||
}
|
||||
|
||||
${
|
||||
tokenLimit
|
||||
? `⚠️ TOKEN LIMIT: Each memory value must not exceed ${tokenLimit} tokens. Be concise and store only essential information.`
|
||||
: ''
|
||||
}
|
||||
1. ONLY use memory tools when the user requests memory actions with phrases like:
|
||||
- "Remember [that] [I]..."
|
||||
- "Don't forget [that] [I]..."
|
||||
- "Please remember..."
|
||||
- "Store this..."
|
||||
- "Forget [that] [I]..."
|
||||
- "Delete the memory about..."
|
||||
|
||||
⚠️ WARNING ⚠️
|
||||
DO NOT STORE ANY INFORMATION UNLESS THE USER HAS EXPLICITLY PROVIDED IT.
|
||||
ONLY store information the user has EXPLICITLY shared.
|
||||
NEVER guess or assume user information.
|
||||
ALL memory values must be factual statements about THIS specific user.
|
||||
If nothing needs to be stored, DO NOT CALL any memory tools.
|
||||
If you're unsure whether to store something, DO NOT store it.
|
||||
If nothing needs to be stored, END THE TURN IMMEDIATELY.`;
|
||||
2. NEVER store information just because the user mentioned it in conversation.
|
||||
|
||||
3. NEVER use memory tools when the user asks you to use other tools or invoke tools in general.
|
||||
|
||||
4. Memory tools are ONLY for memory requests, not for general tool usage.
|
||||
|
||||
5. If the user doesn't ask you to remember or forget something, DO NOT use any memory tools.
|
||||
|
||||
${validKeys && validKeys.length > 0 ? `\nVALID KEYS: ${validKeys.join(', ')}` : ''}
|
||||
|
||||
${tokenLimit ? `\nTOKEN LIMIT: Maximum ${tokenLimit} tokens per memory value.` : ''}
|
||||
|
||||
When in doubt, and the user hasn't asked to remember or forget anything, END THE TURN IMMEDIATELY.`;
|
||||
|
||||
/**
|
||||
* Creates a memory tool instance with user context
|
||||
|
|
@ -368,6 +368,7 @@ ${memory ?? 'No existing memories'}`;
|
|||
thread_id: `memory-run-${conversationId}`,
|
||||
},
|
||||
streamMode: 'values',
|
||||
recursionLimit: 3,
|
||||
version: 'v2',
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue