#!/usr/bin/env python3 """ Comprehensive test of mem0 with Supabase after cleanup """ import sys from config import load_config, get_mem0_config from mem0 import Memory def test_mem0_comprehensive(): """Comprehensive test of mem0 functionality""" print("=" * 60) print("MEM0 COMPREHENSIVE INTEGRATION TEST") print("=" * 60) try: # Load configuration system_config = load_config() config = get_mem0_config(system_config, "ollama") print("šŸš€ Initializing mem0...") memory = Memory.from_config(config) print("āœ… mem0 initialized successfully") test_user = "comprehensive_test_user" # Test 1: Add memories print("\nšŸ“ Test 1: Adding multiple memories...") memories_to_add = [ "I love using Supabase for vector databases", "Ollama provides great local LLM capabilities", "Neo4j is excellent for graph relationships", "mem0 is a powerful memory management system" ] added_memories = [] for i, content in enumerate(memories_to_add): result = memory.add(content, user_id=test_user) print(f" Memory {i+1} added: {result}") added_memories.append(result) # Test 2: Search memories print("\nšŸ” Test 2: Searching memories...") search_queries = [ "vector database", "local LLM", "graph database" ] for query in search_queries: results = memory.search(query, user_id=test_user) print(f" Search '{query}': found {len(results)} results") if results: # Handle both list and dict result formats if isinstance(results, list): for j, result in enumerate(results[:2]): # Show max 2 results if isinstance(result, dict): memory_text = result.get('memory', 'N/A') print(f" {j+1}. {memory_text[:60]}...") else: print(f" {j+1}. {str(result)[:60]}...") else: print(f" Results: {results}") # Test 3: Get all memories print("\nšŸ“‹ Test 3: Retrieving all memories...") all_memories = memory.get_all(user_id=test_user) print(f" Retrieved: {all_memories}") # Test 4: Update memory (if supported) print("\nāœļø Test 4: Update test...") try: # This might not work depending on implementation update_result = memory.update("test_id", "Updated content") print(f" Update result: {update_result}") except Exception as e: print(f" Update not supported or failed: {e}") # Test 5: History (if supported) print("\nšŸ“š Test 5: History test...") try: history = memory.history(user_id=test_user) print(f" History: {history}") except Exception as e: print(f" History not supported or failed: {e}") print("\n" + "=" * 60) print("šŸŽ‰ COMPREHENSIVE TEST COMPLETED!") print("=" * 60) return True except Exception as e: print(f"\nāŒ Test failed: {str(e)}") print(f"Error type: {type(e).__name__}") import traceback traceback.print_exc() return False if __name__ == "__main__": success = test_mem0_comprehensive() sys.exit(0 if success else 1)