#!/usr/bin/env python3 """ Test mem0 using the exact configuration from config.py """ import sys from config import load_config, get_mem0_config from mem0 import Memory def test_config_working(): """Test mem0 using working config.py configuration""" print("=" * 60) print("MEM0 CONFIG.PY INTEGRATION TEST") print("=" * 60) try: # Load the working configuration system_config = load_config() config = get_mem0_config(system_config, "ollama") print(f"๐Ÿ”ง Loaded configuration: {config}") print("\n๐Ÿš€ Initializing mem0 with config.py...") memory = Memory.from_config(config) print("โœ… mem0 initialized successfully with working config") # Test a simple memory operation print("\n๐Ÿ“ Testing basic memory operation...") test_user = "config_test_user" test_content = "Testing mem0 with the proven configuration setup" # Test with simple memory operations print(f"Adding memory: {test_content}") result = memory.add(test_content, user_id=test_user) print(f"โœ… Memory added: {result}") print("\n๐Ÿ“‹ Testing memory retrieval...") all_memories = memory.get_all(user_id=test_user) print(f"โœ… Retrieved {len(all_memories)} memories") print(f"Memory type: {type(all_memories)}") print(f"Memory content: {all_memories}") print("\n๐Ÿงน Cleaning up...") if all_memories: try: # Handle different memory structure formats if isinstance(all_memories, list) and len(all_memories) > 0: print(f"First memory item: {all_memories[0]}") elif isinstance(all_memories, dict): print(f"Memory dict keys: {list(all_memories.keys())}") # Simple cleanup - don't worry about details for now print("โœ… Cleanup completed (skipped for debugging)") except Exception as cleanup_error: print(f" Cleanup error: {cleanup_error}") else: print("No memories to clean up") print("\n" + "=" * 60) print("๐ŸŽ‰ CONFIG.PY TEST PASSED!") 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_config_working() sys.exit(0 if success else 1)