Seamless conversation continuity across multiple AI models
Switch between ChatGPT, Claude, Gemini, and Groq models while maintaining perfect conversation context
π Multi-LLM Support - Seamlessly switch between OpenAI, Google, Anthropic, and Groq models
πΎ Persistent Memory - Store conversation history with metadata across different providers
π Semantic Search - Find relevant messages using vector embeddings for intelligent context retrieval
π― Unified Interface - Consistent API for interacting with different LLM providers
π¬ Interactive CLI - Easy-to-use command-line interface for conversations
βοΈ Configurable Embeddings - Support for OpenAI and Hugging Face embedding providers
π§© Context Strategies - Multiple strategies for retrieving conversation context (recent, relevant, hybrid)
π‘οΈ Error Handling - Graceful handling of API failures and rate limits
# Clone the repository
git clone https://github.com/CodeGovindz/MindLayer.git
cd MindLayer
# Install dependencies
pip install -r requirements.txt
# Install the package
pip install -e .Set up your API keys (at least one required):
# OpenAI (for ChatGPT, GPT-4)
export OPENAI_API_KEY="sk-your-openai-key"
# Google (for Gemini)
export GOOGLE_API_KEY="AIza-your-google-key"
# Anthropic (for Claude)
export ANTHROPIC_API_KEY="sk-ant-your-anthropic-key"
# Groq (for Llama, Mixtral)
export GROQ_API_KEY="gsk-your-groq-key"# Interactive CLI
python -m universal_memory_layer.cli.main
# Or use the console script
uml| Provider | Models | Status |
|---|---|---|
| OpenAI | GPT-4, GPT-3.5-turbo, GPT-5-nano | β Supported |
| Gemini Pro, Gemini-2.0-flash | β Supported | |
| Anthropic | Claude-3 Sonnet | β Supported |
| Groq | Llama-3.1-8B, Mixtral-8x7B | β Supported |
# Start the CLI
python -m universal_memory_layer.cli.main
# Available commands:
/help # Show all commands
/models # List available models
/switch # Switch between models
/recent 5 # Show last 5 messages
/search "topic" # Search conversation history
/stats # Show memory statistics
/quit # Exitfrom universal_memory_layer.conversation_manager import ConversationManager
# Initialize
manager = ConversationManager()
manager.initialize()
# Chat with GPT-4
manager.switch_model("gpt-4")
response = manager.chat("Hello! How are you?")
# Switch to Gemini while maintaining context
manager.switch_model("gemini-2.0-flash")
response = manager.chat("What did we just talk about?")
# Use different context strategies
response = manager.chat(
"Tell me more about that topic",
context_strategy="relevant", # or "recent", "hybrid"
context_count=5
)# Available models
models = manager.get_available_models()
# ['chatgpt', 'gpt-4', 'gemini', 'gemini-2.0-flash', 'claude', 'llama-3.1-8b', 'mixtral-8x7b']
# Seamless switching with memory retention
manager.switch_model("llama-3.1-8b") # Groq
response1 = manager.chat("I love machine learning")
manager.switch_model("gemini-2.0-flash") # Google
response2 = manager.chat("What do I love?") # Remembers context!| Variable | Description | Default | Example |
|---|---|---|---|
OPENAI_API_KEY |
OpenAI API key | - | sk-proj-... |
GOOGLE_API_KEY |
Google AI API key | - | AIza... |
ANTHROPIC_API_KEY |
Anthropic API key | - | sk-ant-... |
GROQ_API_KEY |
Groq API key | - | gsk_... |
UML_EMBEDDING_PROVIDER |
Embedding provider | openai |
huggingface |
UML_DATABASE_PATH |
Database file path | memory.db |
./data/memory.db |
UML_LOG_LEVEL |
Logging level | WARNING |
INFO |
Create a .env file for easy setup:
# API Keys
OPENAI_API_KEY=sk-your-openai-key
GOOGLE_API_KEY=AIza-your-google-key
GROQ_API_KEY=gsk-your-groq-key
# Settings
UML_EMBEDDING_PROVIDER=huggingface
UML_LOG_LEVEL=INFOgraph TB
CLI[π₯οΈ CLI Interface] --> CM[π§ Conversation Manager]
API[π Python API] --> CM
CM --> LLM1[π€ OpenAI Client]
CM --> LLM2[π€ Google Client]
CM --> LLM3[π€ Anthropic Client]
CM --> LLM4[π€ Groq Client]
CM --> MS[πΎ Memory Store]
MS --> DB[(ποΈ SQLite Database)]
MS --> VS[π Vector Store]
MS --> EMB[π Embeddings]
EMB --> OPENAI[OpenAI Embeddings]
EMB --> HF[π€ Hugging Face]
universal_memory_layer/
βββ π§ models/ # Data models (Message, Config)
βββ πΎ storage/ # Database & vector storage
βββ π€ clients/ # LLM client implementations
βββ π embeddings/ # Embedding providers
βββ π₯οΈ cli/ # Command-line interface
βββ π§ config_loader.py # Configuration management
βββ π logging_config.py # Logging setup
βββ β‘ conversation_manager.py # Main orchestrator
# Run all tests
pytest
# Run with coverage
pytest --cov=universal_memory_layer
# Run integration tests
python tests/run_integration_tests.py
# Test specific components
pytest tests/test_conversation_manager.py
pytest tests/storage/
pytest tests/clients/| Operation | Time | Memory |
|---|---|---|
| Model switching | <100ms | ~50MB |
| Message storage | <50ms | ~10MB |
| Context retrieval | <200ms | ~20MB |
| Semantic search | <500ms | ~100MB |
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Python: 3.8+
- Dependencies: See requirements.txt
- API Keys: At least one LLM provider
- Storage: 100MB+ free space
- API keys are never logged or stored
- Local database encryption available
- Secure memory handling
- Rate limiting and error handling
π« No Models Available
Problem: CLI shows "No models available"
Solutions:
- β Set at least one API key in environment variables
- β Verify API key format and validity
- β Check network connectivity
# Check if keys are set
echo $OPENAI_API_KEY
echo $GOOGLE_API_KEYπΎ Database Errors
Problem: SQLite database errors
Solutions:
- β Check file permissions for database directory
- β Ensure sufficient disk space
- β
Delete database file to recreate:
rm memory.db
π Embedding Issues
Problem: Embedding generation fails
Solutions:
- β OpenAI: Check API key and quota
- β Hugging Face: Ensure model can be downloaded
- β
Switch providers:
export UML_EMBEDDING_PROVIDER=huggingface
β‘ Performance Issues
Problem: Slow responses or high memory usage
Solutions:
- β
Use
context_strategy="recent"for speed - β
Reduce
context_countparameter - β
Set
UML_MAX_CONTEXT_LENGTH=2000
| Document | Description |
|---|---|
| π API Reference | Complete API documentation |
| π‘ Examples | Usage examples and patterns |
| βοΈ Configuration | Configuration options |
| π§ Troubleshooting | Detailed troubleshooting |
- OpenAI for GPT models and embeddings
- Google for Gemini models
- Anthropic for Claude models
- Groq for fast inference
- Hugging Face for open-source embeddings
- FAISS for vector search
This project is licensed under the MIT License - see the LICENSE file for details.