Clean and organize project structure
Major reorganization: - Created scripts/ directory for all utility scripts - Created config/ directory for configuration files - Moved all test files to tests/ directory - Updated all script paths to work with new structure - Updated README.md with new project structure diagram New structure: ├── src/ # Source code (API + MCP) ├── scripts/ # Utility scripts (start-*.sh, docs_server.py, etc.) ├── tests/ # All test files and debug utilities ├── config/ # Configuration files (JSON, Caddy config) ├── docs/ # Documentation website └── logs/ # Log files All scripts updated to use relative paths from project root. Documentation updated with new folder structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
88
tests/debug_neo4j_relationships.py
Normal file
88
tests/debug_neo4j_relationships.py
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/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())
|
||||
Reference in New Issue
Block a user