Files
t66_langmem/debug_neo4j_relationships.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

88 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""
Debug Neo4j relationships to see what's happening
"""
import asyncio
from neo4j import AsyncGraphDatabase
# Configuration
NEO4J_URL = "bolt://localhost:7687"
NEO4J_USER = "neo4j"
NEO4J_PASSWORD = "langmem_neo4j_password"
async def debug_neo4j_relationships():
"""Debug Neo4j relationships"""
print("🔍 Debugging Neo4j Relationships")
print("=" * 50)
try:
driver = AsyncGraphDatabase.driver(NEO4J_URL, auth=(NEO4J_USER, NEO4J_PASSWORD))
async with driver.session() as session:
# Check all relationship types
print("1. All relationship types in database:")
result = await session.run("CALL db.relationshipTypes()")
async for record in result:
print(f" - {record[0]}")
# Check all relationships
print("\n2. All relationships:")
result = await session.run("MATCH ()-[r]->() RETURN type(r) as rel_type, count(r) as count")
relationship_count = 0
async for record in result:
print(f" {record['rel_type']}: {record['count']}")
relationship_count += record['count']
if relationship_count == 0:
print(" No relationships found!")
# Check MENTIONS relationships specifically
print("\n3. MENTIONS relationships:")
result = await session.run("MATCH (m:Memory)-[r:MENTIONS]->(e:Entity) RETURN m.id, e.name, e.type")
async for record in result:
print(f" Memory {record['m.id'][:8]}... MENTIONS {record['e.name']} ({record['e.type']})")
# Check all relationships with details
print("\n4. All relationships with details:")
result = await session.run("""
MATCH (a)-[r]->(b)
RETURN labels(a)[0] as source_label,
coalesce(a.name, a.id) as source_name,
type(r) as relationship,
labels(b)[0] as target_label,
coalesce(b.name, b.id) as target_name,
r.confidence as confidence
ORDER BY relationship
""")
async for record in result:
print(f" {record['source_label']} '{record['source_name'][:20]}...' ")
print(f" →[{record['relationship']}]→ ")
print(f" {record['target_label']} '{record['target_name'][:20]}...' (conf: {record['confidence']})")
print()
# Check if there are any dynamic relationships
print("\n5. Looking for dynamic relationships (non-MENTIONS):")
result = await session.run("""
MATCH (a)-[r]->(b)
WHERE type(r) <> 'MENTIONS'
RETURN type(r) as rel_type, count(r) as count
""")
found_dynamic = False
async for record in result:
print(f" {record['rel_type']}: {record['count']}")
found_dynamic = True
if not found_dynamic:
print(" No dynamic relationships found!")
print(" This suggests the AI relationship creation might have issues.")
await driver.close()
except Exception as e:
print(f"❌ Error: {e}")
if __name__ == "__main__":
asyncio.run(debug_neo4j_relationships())