Files
t66_langmem/debug_fact_extraction.py
Docker Config Backup 46faa78237 Initial commit: LangMem fact-based AI memory system with docs and MCP integration
- Complete fact-based memory API with mem0-inspired approach
- Individual fact extraction and deduplication
- ADD/UPDATE/DELETE memory actions
- Precision search with 0.86+ similarity scores
- MCP server for Claude Code integration
- Neo4j graph relationships and PostgreSQL vector storage
- Comprehensive documentation with architecture and API docs
- Matrix communication integration
- Production-ready Docker setup with Ollama and Supabase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-17 13:16:19 +02:00

82 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
Debug the fact extraction system
"""
import asyncio
import sys
import os
# Add the API directory to the path
sys.path.insert(0, '/home/klas/langmem-project/src/api')
from fact_extraction import FactExtractor
async def debug_fact_extraction():
"""Debug fact extraction"""
print("🔍 Debugging Fact Extraction System")
print("=" * 50)
# Test content
test_content = "Ondrej has a son named Cyril who is 8 years old and loves playing soccer. Cyril goes to elementary school in Prague and his favorite color is blue. Ondrej works as a software engineer and lives in Czech Republic."
print(f"Content to extract facts from:")
print(f"'{test_content}'")
print()
# Create fact extractor
extractor = FactExtractor()
print("1. Testing fact extraction...")
facts = await extractor.extract_facts(test_content)
print(f"Extracted {len(facts)} facts:")
for i, fact in enumerate(facts, 1):
print(f" {i}. {fact}")
if not facts:
print("❌ No facts extracted - there might be an issue with the extraction system")
return False
else:
print("✅ Fact extraction working!")
print()
# Test memory action determination
print("2. Testing memory action determination...")
existing_memories = [
{
"id": "test-memory-1",
"content": "Ondrej has a son named Cyril",
"similarity": 0.8
}
]
new_fact = "Ondrej has a son named Cyril who is 8 years old"
action_data = await extractor.determine_memory_action(new_fact, existing_memories)
print(f"New fact: '{new_fact}'")
print(f"Action: {action_data.get('action', 'unknown')}")
print(f"Reason: {action_data.get('reason', 'no reason')}")
return True
async def main():
"""Main function"""
try:
success = await debug_fact_extraction()
if success:
print("\n🎉 Fact extraction debugging complete!")
else:
print("\n❌ Fact extraction has issues that need to be fixed.")
except Exception as e:
print(f"❌ Error during debugging: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())