The following key operations are required to implement contextual memory:
1. Memory entry
utilizationprocess_and_commit_sessionmethodology to handle the dialog:
memory.process_and_commit_session(
"用户说他喜欢拿铁咖啡",
session_id="chat-20230501"
)
The system automatically analyzes the entities and relationships in the text, generates Markdown files and creates Git commits.
2. Contextual search
pass (a bill or inspection etc)get_contextOn-demand access to background information:
- basic model(depth="basic"): return the core attributes of the matching entities
- depth mode(depth="deep"): Contains the full file of the entity in question.
- chronological pattern(depth="temporal"): history of changes to attach this information to the record
3. Integration of LLM
Enter the search results as part of the system prompt word:
context = memory.get_context("用户的咖啡偏好", depth="deep")
prompt = f"基于以下上下文:{context},请生成回复..."
This combination enables a dialog system with true long-term memory.
This answer comes from the articleDiffMem: a Git-based versioned memory repository for AI intelligencesThe
































