{ lib, python3, fetchFromGitHub, }: python3.pkgs.buildPythonPackage rec { pname = "mem0ai"; version = "1.0.0"; pyproject = true; src = fetchFromGitHub { owner = "mem0ai"; repo = "mem0"; rev = "v${version}"; hash = "sha256-DluzIhwL/GanqtRSMW7ax+OVc2kZjbwQ0lpPCQFnD58="; }; # Relax Python dependency version constraints # mem0 has strict version pins that may not match nixpkgs versions pythonRelaxDeps = true; build-system = with python3.pkgs; [ hatchling ]; dependencies = with python3.pkgs; [ litellm qdrant-client pydantic openai posthog pytz sqlalchemy protobuf uvicorn fastapi ]; optional-dependencies = with python3.pkgs; { graph = [ # Note: some graph dependencies may not be available in nixpkgs # neo4j is available, others will need to be packaged separately ]; vector_stores = [ # chromadb # available in nixpkgs # pinecone-client # may need packaging # weaviate-client # may need packaging # faiss # available as faiss-cpu psycopg pymongo pymysql redis elasticsearch ]; llms = [ groq openai # together # may need packaging # litellm # may need packaging # ollama # may need packaging # google-generativeai # may need packaging ]; extras = [ boto3 # langchain-community # may need packaging # sentence-transformers # may need packaging elasticsearch # fastembed # may need packaging ]; }; # Skip tests for now since they require additional test dependencies doCheck = false; # Disable imports check because mem0 tries to create directories at import time # which fails in the Nix sandbox (/homeless-shelter) pythonImportsCheck = []; postInstall = '' install -Dm755 ${./server.py} $out/bin/mem0-server ''; meta = with lib; { description = "Long-term memory layer for AI agents with REST API support"; longDescription = '' Mem0 provides a sophisticated memory layer for AI applications, offering: - Memory management for AI agents (add, search, update, delete) - REST API server for easy integration - Support for multiple vector storage backends (Qdrant, Chroma, etc.) - Graph memory capabilities - Multi-modal support - Configurable LLM and embedding models ''; homepage = "https://github.com/mem0ai/mem0"; changelog = "https://github.com/mem0ai/mem0/releases/tag/v${version}"; license = licenses.asl20; platforms = platforms.linux; }; }