| title | description |
|---|---|
Development |
Development setup and testing with MemSync |
This guide covers setting up MemSync for local development, testing, and contributing to the project.
**Prerequisites**: Python 3.9+, PostgreSQL, and Redis are required for local development.git clone https://github.com/memsync/memsync.git
cd memsyncMemSync uses Poetry for dependency management:
poetry installpoetry install
poetry run pip install groq together boto3 litellm ollama chromadb weaviate weaviate-client sentence_transformers vertexai \
google-generativeai elasticsearch opensearch-py vecs pinecone pinecone-text faiss-cpu langchain-community \
upstash-vector azure-search-documentsCreate a .env file in the project root:
# Database Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=memsync_dev
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
# API Keys
OPENAI_API_KEY=your_openai_key
API_KEY=your_api_key
# Supabase (for authentication)
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_keyInitialize the PostgreSQL database with pgvector extension:
# Create database and install pgvector
createdb memsync_dev
psql memsync_dev -c "CREATE EXTENSION vector;"
# Run migrations
cd server
alembic upgrade headcd server
python main.pydocker-compose up -dThe API server will be available at http://localhost:8000
MemSync includes comprehensive test suites for all components:
# Run all tests
poetry run pytest
# Run specific test file
poetry run pytest tests/test_memory.py
# Run with coverage
poetry run pytest --cov=memsync tests/```bash
pytest tests/test_memory.py
pytest tests/test_embeddings.py
pytest tests/test_user_registry.py
```
```bash
pytest tests/test_api_key.py
pytest tests/test_buffer.py
```
```bash
pytest tests/test_buffer.py
```
Test external integrations with sample data:
# Test Reddit integration
python tests/integration_tester.py --type reddit --username sample_user
# Test memory extraction
python tests/memory_tester.py --input "sample conversation"MemSync uses several tools to maintain code quality:
# Format code with ruff
ruff format .
# Run all formatting tools
make format# Check code with ruff
ruff check .
# Run pre-commit hooks
pre-commit run --all-files# Run mypy type checking
mypy memsync/# Install dependencies
make install
# Run tests
make test
# Format and lint code
make format
# Build package
make build
# Generate documentation
make docsMemSync includes comprehensive benchmarking against the Locomo dataset:
# Run memory indexing benchmark
python evaluation/run_experiments.py \
--technique_type memsync \
--method add \
--input_file evaluation/dataset/locomo10.json
# Run search benchmark
python evaluation/run_experiments.py \
--technique_type memsync \
--method search \
--input_file evaluation/dataset/locomo10.json
# Evaluate results
python evaluation/evals.py \
--input_file evaluation/results/memsync_search_results.jsonKey metrics tracked:
- Memory extraction accuracy: How well facts are extracted from conversations
- Search relevance: Quality of semantic search results
- Storage efficiency: Memory usage vs. retrieval accuracy
- Processing speed: Time to index and search memories
Use the interactive API documentation at http://localhost:8000/docs or test with curl:
# Health check
curl http://localhost:8000/healthcheck
# Store memories (requires auth)
curl -X POST "http://localhost:8000/v1/memories" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Test message"}], "agent_id": "test", "thread_id": "test", "source": "test"}'
# Search memories
curl -X POST "http://localhost:8000/v1/memories/search" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "test query", "limit": 5}'- Define request/response models in
server/main.py - Implement the endpoint function
- Add tests in
tests/ - Update API documentation
Example endpoint structure:
@app.post("/v1/new-endpoint")
async def new_endpoint(request: NewEndpointRequest, auth: CurrentAuth):
# Validate request
# Process with MemSync
# Return response
passCustomize memory extraction and storage:
config = {
"llm": {
"provider": "openai", # or "gemini"
"config": {
"model": "gpt-4o",
"temperature": 0.0
}
},
"embedder": {
"provider": "openai", # or custom endpoint
"config": {
"model": "text-embedding-3-large",
"embedding_dims": 1024
}
},
"vector_store": {
"provider": "pgvector",
"config": {
"collection_name": "memories_v5",
"embedding_model_dims": 1024
}
},
"memory_categories": ["career", "interests", "relationships", ...]
}Configure external service integrations:
# Social media integrations
REDDIT_CLIENT_ID = "your_reddit_client_id"
REDDIT_CLIENT_SECRET = "your_reddit_client_secret"
# Document processing
DOCLING_API_KEY = "your_docling_key"
# Monitoring
DATADOG_API_KEY = "your_datadog_key"```bash
# Check PostgreSQL status
pg_isready
# Install pgvector if missing
psql -d memsync_dev -c "CREATE EXTENSION IF NOT EXISTS vector;"
```
```bash
# Test OpenAI connection
python -c "import openai; print(openai.api_key)"
# Check memory extraction logs
tail -f logs/memsync.log
```
```bash
# Test embedding generation
python tests/test_embeddings.py
# Check vector store connection
python operations/check_embeddings.py
```
Enable detailed logging for debugging:
import logging
logging.basicConfig(level=logging.DEBUG)
# Or set environment variable
export LOG_LEVEL=DEBUG- Fork and clone the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make changes and add tests
- Run tests:
pytest - Run linting:
ruff check . - Commit changes: Follow conventional commit format
- Push and create PR
- Follow PEP 8 style guidelines
- Add type hints for all functions
- Write tests for new functionality
- Update documentation as needed
- Use conventional commit messages
All PRs must include:
- Unit tests for new functionality
- Integration tests for API changes
- Performance benchmarks for core features
- Documentation updates
- Environment variables: Configure all required environment variables
- Database: Set up PostgreSQL with pgvector in production
- Redis: Configure Redis for task queue
- Monitoring: Set up Datadog or similar monitoring
- Security: Configure CORS, rate limiting, and authentication
# Build production image
docker build -f server/Dockerfile -t memsync:latest .
# Run with docker-compose
docker-compose -f docker-compose.prod.yml up -dFor more detailed deployment instructions, see the deployment guide.
- Documentation: Check our API Reference
- Issues: Report bugs on GitHub Issues
- Community: Join our Discord community
- Email: Contact us at dev@memsync.ai