Enhance your Dify applications with long-term memory by integrating the Memobase plugin. This guide will walk you through setting up and using the plugin to create more intelligent, context-aware AI agents.
Memobase uses a buffer system to optimize processing costs and efficiency:
Buffered Processing: Messages are not processed immediately. Instead, they are stored in a user buffer until it reaches 512 tokens or other trigger conditions are met.
Automatic Flush: When the buffer is full or remains idle for a certain period, Memobase automatically processes all buffered messages together.
Manual Flush: You can trigger immediate processing using the Flush Buffer tool in the Dify plugin.
Testing & Debugging: Use flush after conversations to see immediate results during development.
Session End Detection: Trigger flush when users leave the chat or close the session.
Critical Updates: When immediate memory processing is required for important information.
Avoid flushing after every message as it increases token consumption significantly. Let Memobase handle automatic processing for optimal cost efficiency.
Here is a basic Dify workflow that uses the Memobase plugin to store and retrieve memory without immediate processing:
A basic Dify workflow for memory storage and retrieval.
You can download the complete workflow file from: memobase.ymlThis workflow is suitable for most production scenarios where automatic buffer processing is sufficient.
For scenarios requiring immediate memory processing (testing, debugging, or session-end detection), use this enhanced workflow:
A Dify workflow with explicit buffer flush for immediate processing.
You can download the complete workflow file from: memobase_flush_workflow.ymlThis workflow includes the Flush Buffer step to ensure conversation data is processed immediately. Use this pattern when:
You need to see memory updates right away during testing
The user is ending their session
You’re storing critical information that must be available immediately
By integrating Memobase, you can build sophisticated AI applications that learn from and remember past interactions, leading to more engaging and personalized user experiences.