Use this file to discover all available pages before exploring further.
Memories are structured pieces of information extracted from your content. Mem[v] automatically processes text, files, videos, and other content to create searchable memories.
# Add structured memory with entitiesclient.memories.add( space_id="space_abc123", content="Sarah Chen is the VP of Engineering at Acme Corp. She uses React and TypeScript.", metadata={ "entities": ["Sarah Chen", "Acme Corp", "React", "TypeScript"], "type": "profile" })
# Search for memoriesresults = client.memories.search( space_id="space_abc123", query="What programming languages does the user prefer?", limit=10)# Process resultsfor memory in results.memories: print(f"Score: {memory.score}") print(f"Content: {memory.content}") print(f"Metadata: {memory.metadata}") print("---")
Mem[v] uses semantic search to find relevant memories even when exact keywords don’t match:
# Query: "How does the user like their UI?"# Will match: "The user prefers dark mode"results = client.memories.search( space_id="space_abc123", query="How does the user like their UI?")for memory in results.memories: print(memory.content) # Output: "The user prefers dark mode and uses Python for development"
def get_relevant_context(space_id: str, query: str, limit: int = 5) -> str: """Get relevant memories as context string.""" results = client.memories.search( space_id=space_id, query=query, limit=limit ) return "\n\n".join([m.content for m in results.memories])# Usage in a chatbotuser_query = "What are the user's preferences?"context = get_relevant_context("user_space", user_query)# Pass context to your LLMresponse = llm.generate( prompt=f"Context: {context}\n\nUser: {user_query}")
Write memory content that is self-contained and easy to understand.Good:"User prefers email notifications for important updates only"Less good:"email - important only"
Search with specific queries
More specific queries return more relevant results.Specific:"What is the user's preferred framework for backend development?"Vague:"framework"