Learning to fly in AI
A LangChain-based personal assistant with multi-memory capabilities, powered by Claude (Anthropic). This assistant remembers facts about you, tracks your todos, follows custom instructions, and stores everything locally on your machine.
-
Multi-Memory System
- 📝 Instructions: System-level directives that guide the assistant's behavior
- 📚 Facts: Factual information about you (preferences, personal info, habits, etc.)
- ✅ Todos: Your task list with priorities and completion tracking
-
TrustCall Integration: Uses Claude's structured output for reliable memory extraction
-
Spy Monitoring: Comprehensive logging of all operations and memory updates
-
Local Storage: All memories stored in JSON files on your machine
-
Auto-Memory Extraction: Automatically extracts and updates memories from conversations
src/
├── memory/ # Memory system (types, storage)
├── agent/ # LangChain agent and memory processor
└── monitoring/ # Spy logging system
memories/ # Local JSON storage (created on first run)
├── instructions.json
├── facts.json
└── todos.json
logs/ # Session logs (created on first run)
└── session_*.jsonl
pip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .envEdit .env and add your Anthropic API key:
ANTHROPIC_API_KEY=your_actual_api_key_here
Get your API key from: https://console.anthropic.com/
python main.pyJust type naturally and the assistant will respond while automatically extracting and storing memories:
You: Hi! I'm John and I live in San Francisco.
Assistant: Hello John! Nice to meet you...
You: I prefer Python over JavaScript for backend work.
Assistant: Got it! I'll keep that in mind...
/todos- View your todo list/facts- View all stored facts about you/instructions- View system instructions/summary- View session statistics/clear- Clear conversation history (keeps memories)/quitor/exit- Exit the program
Adding Todos:
You: Remind me to buy groceries tomorrow and finish the project report by Friday.
Assistant: I'll help you track those tasks...
Setting Preferences:
You: I prefer concise responses and always use metric units.
Assistant: Understood! I'll keep my responses concise and use metric units...
Asking Questions:
You: What do you know about my preferences?
Assistant: Based on what you've told me...
-
Memory Extraction: After each conversation, the system uses Claude with structured output (TrustCall) to extract:
- New facts about you
- Todo items
- Behavioral instructions
-
Local Storage: All memories are stored in
memories/as JSON files:instructions.json- How the assistant should behavefacts.json- Information about youtodos.json- Your task list
-
Context Building: Each message includes current memories in the system prompt, so the assistant always has access to everything it knows about you
-
Monitoring: The
spy()system logs all operations tologs/for debugging and analysis
- Priority-based (1-10)
- Guide assistant behavior
- Example: "Always be concise", "Use metric units"
- Categorized information about you
- Categories: preferences, personal_info, habits, work, hobbies, etc.
- Example: "User prefers dark mode", "User is a software engineer"
- Priority-based (1-5)
- Track completion status
- Optional due dates and tags
- Example: "Buy groceries [Priority 3]"
-
src/memory/- Memory types and storage systemmemory_types.py- Pydantic models for Instructions, Facts, Todosmemory_store.py- JSON-based persistence layer
-
src/agent/- Agent implementationassistant.py- Main PersonalAssistant classmemory_processor.py- TrustCall-based memory extraction
-
src/monitoring/- Logging and monitoringspy.py- Event logging system
Add a new memory type:
- Define model in
src/memory/memory_types.py - Add storage methods in
src/memory/memory_store.py - Update
MemoryUpdatemodel - Update memory processor prompt
Customize extraction:
Edit the system prompt in src/agent/memory_processor.py
- Python 3.8+
- Anthropic API key
- Dependencies listed in
requirements.txt
- All data stored locally on your machine
- No data sent anywhere except to Anthropic's API for processing
- API key stored in
.env(not committed to git) - Memories stored in plain JSON (human-readable)
MIT License - Feel free to modify and use as you like!