Create AI copilots that remember user context, preferences, and project history to provide personalized assistance across coding, writing, and workflow tasks.
AI copilots are intelligent assistants that work alongside users to enhance productivity. Unlike chatbots that respond to queries, copilots proactively understand context, anticipate needs, and adapt to individual working styles. Memori gives copilots the memory they need to truly assist — not just respond.
from memori import Memorifrom openai import OpenAIclass CodingCopilot: def __init__(self, developer_id: str): self.client = OpenAI() self.mem = Memori().llm.register(self.client) # Attribution links memories to this developer self.mem.attribution( entity_id=developer_id, process_id="coding_copilot" ) def assist(self, request: str) -> str: """Provide coding assistance.""" response = self.client.chat.completions.create( model="gpt-4o-mini", messages=[ { "role": "system", "content": "You are an expert coding copilot. Learn the developer's " "tech stack, coding style, and project context. Provide " "personalized, context-aware assistance." }, {"role": "user", "content": request} ] ) return response.choices[0].message.contentif __name__ == "__main__": copilot = CodingCopilot("developer_jane") # Day 1: Establish context print("Developer: Help me set up a new FastAPI project with PostgreSQL") response1 = copilot.assist( "Help me set up a new FastAPI project with PostgreSQL. " "I prefer SQLAlchemy 2.0 with async support and Pydantic v2 models." ) print(f"Copilot: {response1}\n") print("Developer: Show me how to structure the database models") response2 = copilot.assist( "Show me how to structure the database models for a user authentication system." ) print(f"Copilot: {response2}\n") copilot.mem.augmentation.wait() # Day 2: Copilot remembers preferences print("--- Next day ---\n") print("Developer: Add email verification to the auth system") response3 = copilot.assist( "Add email verification to the authentication system." ) print(f"Copilot: {response3}") # Copilot recalls: FastAPI, PostgreSQL, SQLAlchemy 2.0 async, Pydantic v2
4
Run the Copilot
python coding_copilot.py
The copilot remembers your tech stack and preferences, providing consistent, personalized assistance!
Create a writing assistant that learns your style, tone, and project context.
from memori import Memorifrom anthropic import Anthropicclass WritingCopilot: def __init__(self, writer_id: str): self.client = Anthropic() self.mem = Memori().llm.register(self.client) self.mem.attribution( entity_id=writer_id, process_id="writing_copilot" ) def assist(self, request: str) -> str: """Provide writing assistance.""" response = self.client.messages.create( model="claude-sonnet-4-5-20250929", max_tokens=1024, messages=[ { "role": "user", "content": [ { "type": "text", "text": f"You are a writing copilot. Learn the writer's style, " f"tone, and preferences. Provide personalized assistance.\n\n" f"{request}" } ] } ] ) return response.content[0].text# Usagecopilot = WritingCopilot("writer_john")# Establish writing styleresponse1 = copilot.assist( "Help me write the introduction for a blog post about AI memory systems. " "I prefer a conversational tone with technical depth, similar to how Stripe " "writes their docs — friendly but precise.")print(response1)copilot.mem.augmentation.wait()# Later: Copilot adapts to learned styleresponse2 = copilot.assist( "Write a conclusion for the AI memory blog post.")print(response2)# Copilot recalls: Conversational tone, technical depth, Stripe-style docs
Build a copilot that assists with data analysis, remembering datasets, preferences, and insights.
from memori import Memorifrom openai import OpenAIimport pandas as pdclass DataCopilot: def __init__(self, analyst_id: str): self.client = OpenAI() self.mem = Memori().llm.register(self.client) self.mem.attribution( entity_id=analyst_id, process_id="data_copilot" ) def analyze(self, query: str) -> str: """Assist with data analysis.""" response = self.client.chat.completions.create( model="gpt-4o-mini", messages=[ { "role": "system", "content": "You are a data analysis copilot. Remember datasets, " "analysis patterns, and user preferences. Provide insights " "and suggestions based on previous work." }, {"role": "user", "content": query} ] ) return response.choices[0].message.content# Usagecopilot = DataCopilot("analyst_sarah")# Initial analysisresponse1 = copilot.analyze( "I'm analyzing sales data for Q1 2025. Main dataset has columns: " "date, product_id, revenue, region, customer_segment. " "I want to focus on growth trends by region.")print(response1)copilot.mem.augmentation.wait()# Follow-up analysisresponse2 = copilot.analyze( "Now compare Q1 performance to Q4 2024.")print(response2)# Copilot recalls: Q1 dataset structure, focus on regional growth# Later: Similar analysis for Q2response3 = copilot.analyze( "Analyze Q2 sales data using the same approach.")print(response3)# Copilot applies learned patterns to new data
Let users teach the copilot their preferences gradually:
# Session 1: Broad contextcopilot.assist("I'm building a web API with Python")# Session 2: More specificcopilot.assist("Using FastAPI with async PostgreSQL")# Session 3: Very specific copilot.assist("Prefer SQLAlchemy 2.0 with declarative models")# Future sessions: Copilot knows the full stack
Use Descriptive Entity IDs
Make entity IDs meaningful for better tracking:
# Good: Combines user + contextentity_id="dev_alice_project_api"entity_id="writer_john_blog_ai"entity_id="analyst_sarah_q1_sales"# Avoid: Too genericentity_id="user_1"
Separate Copilots by Domain
Use different process IDs for different types of assistance:
# Code assistancemem.attribution( entity_id="dev_alice", process_id="coding_copilot")# Documentation assistancemem.attribution( entity_id="dev_alice", process_id="docs_copilot")# Facts are shared, but conversation contexts are separate
Handle Session Boundaries Thoughtfully
Use sessions to group related work:
# Start new session for new featuremem.new_session()copilot.assist("Starting work on user authentication")# Multiple interactions in same sessioncopilot.assist("Add password hashing")copilot.assist("Implement JWT tokens")# New feature = new sessionmem.new_session()copilot.assist("Now working on email notifications")