#!/usr/bin/env python3 """ Test mem0 with Supabase configuration """ import os import sys from mem0 import Memory def test_mem0_supabase(): """Test mem0 with Supabase vector store""" print("=" * 60) print("MEM0 + SUPABASE END-TO-END TEST") print("=" * 60) try: # Load configuration with Supabase config = { "vector_store": { "provider": "supabase", "config": { "connection_string": "postgresql://supabase_admin:CzkaYmRvc26Y@localhost:5435/postgres", "collection_name": "mem0_test_memories", "embedding_model_dims": 1536, } }, "graph_store": { "provider": "neo4j", "config": { "url": "bolt://localhost:7687", "username": "neo4j", "password": "password" } }, "llm": { "provider": "ollama", "config": { "model": "qwen2.5:7b", "temperature": 0.1, "max_tokens": 1000, "ollama_base_url": "http://localhost:11434" } }, "embedder": { "provider": "ollama", "config": { "model": "nomic-embed-text:latest", "ollama_base_url": "http://localhost:11434" } } } print("๐Ÿ”ง Initializing mem0 with Supabase configuration...") memory = Memory.from_config(config) print("โœ… mem0 initialized successfully") # Test memory operations print("\n๐Ÿ“ Testing memory addition...") test_user = "test_user_supabase" test_content = "I love building AI applications with Supabase and mem0" result = memory.add(test_content, user_id=test_user) print(f"โœ… Memory added: {result}") print("\n๐Ÿ” Testing memory search...") search_results = memory.search("AI applications", user_id=test_user) print(f"โœ… Search completed, found {len(search_results)} results") if search_results: print(f" First result: {search_results[0]['memory']}") print("\n๐Ÿ“‹ Testing memory retrieval...") all_memories = memory.get_all(user_id=test_user) print(f"โœ… Retrieved {len(all_memories)} memories for user {test_user}") print("\n๐Ÿงน Cleaning up test data...") for mem in all_memories: memory.delete(mem['id']) print("โœ… Test cleanup completed") print("\n" + "=" * 60) print("๐ŸŽ‰ ALL TESTS PASSED - MEM0 + SUPABASE WORKING!") print("=" * 60) return True except Exception as e: print(f"\nโŒ Test failed: {str(e)}") print(f"Error type: {type(e).__name__}") import traceback print("\nFull traceback:") traceback.print_exc() return False if __name__ == "__main__": success = test_mem0_supabase() sys.exit(0 if success else 1)