Here is a simple example of how to use Mneno to add memories and search through them.
from mneno import MemoryClient# Initialize the client (defaults to in-memory storage)client = MemoryClient()# Add memoriesclient.add( "The user is building Mneno, a Python SDK for explainable AI memory.", memory_type="semantic", importance=0.9, tags=["project", "mneno"],)client.add( "User prefers lightweight Python-first SDKs.", memory_type="preference", importance=0.85,)# Search memoriesresults = client.search("What is the user building?")for result in results: print(f"Content: {result.memory.content}") print(f"Score: {result.score.total}") print(f"Reasons: {result.score.reasons}")
Mneno can help you build the perfect context for your LLM prompts, ensuring you stay within a token budget.
# Build a context package with a 50-token budgetcontext = client.build_context("What is the user building?", budget=50)print(context.text)# See why items were includedfor item in context.included: print(f"Included: {item.memory_id} (Reason: {item.reason})")