A playful, loyal AI companion that leverages long-term memory for personalized friendship and support.
The Ted backend is built around a clean, modular architecture with clear separation of concerns:
src/
├── agent.py # CLI interface entry point
├── boot.py # Application bootstrapping and dependency wiring
├── config.py # Centralized configuration parameters
├── export_schema.py # Memory export schemas
├── llm.py # LLM client for chat completions
├── memory.py # Memory management and retrieval
├── ted.py # Core Ted agent implementation
└── utils.py # Utility functions and helpers
The central component that orchestrates the interaction between memory retrieval and LLM generation. Ted:
- Remembers what matters to you and brings up relevant memories
- Formats conversation context
- Passes everything to the LLM for response generation
- Stores conversations in memory
Handles all aspects of memory:
- Retrieval of semantically relevant memories
- Storage of conversations
- Thread history management
- Recent conversation formatting
Responsible for:
- Formatting the system prompt with the appropriate context
- Generating responses via the OpenAI API
- Handling streaming responses
Centralizes all configuration parameters:
- LLM settings
- Memory parameters
- Agent defaults
- File paths
The Ted system can be accessed through:
from src.ted import Ted
from src.boot import memory_manager, llm_client
# Initialize the Ted agent
ted = Ted(memory_manager, llm_client, user_id="your_user_id")
# Get a response
response = ted("What should I focus on this week?")
# Or stream a response
for token in ted.stream_reply("What are my priorities?"):
print(token, end="", flush=True)- Separation of Concerns: Each module has a specific responsibility
- Configuration Centralization: All parameters are defined in one place
- Clean Interface: The Ted class provides a simple, intuitive API
- Robust Memory Management: Efficient retrieval and storage of memories
- Lightweight Dependencies: Minimal external dependencies
To contribute to the Ted backend:
-
Ensure you have the required environment variables:
MEM0_API_KEYOPENAI_API_KEY
-
Follow the existing architecture patterns
-
Add appropriate logging for debugging and monitoring
-
Maintain comprehensive docstrings
-
Respect the existing configuration system