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:
90
tests/check_neo4j_data.py
Normal file
90
tests/check_neo4j_data.py
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check what data is stored in Neo4j
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from neo4j import AsyncGraphDatabase
|
||||
import json
|
||||
|
||||
# Configuration
|
||||
NEO4J_URL = "bolt://localhost:7687"
|
||||
NEO4J_USER = "neo4j"
|
||||
NEO4J_PASSWORD = "langmem_neo4j_password"
|
||||
|
||||
async def check_neo4j_data():
|
||||
"""Check Neo4j data stored by LangMem"""
|
||||
print("🔍 Checking Neo4j Data from LangMem")
|
||||
print("=" * 50)
|
||||
|
||||
try:
|
||||
driver = AsyncGraphDatabase.driver(NEO4J_URL, auth=(NEO4J_USER, NEO4J_PASSWORD))
|
||||
|
||||
async with driver.session() as session:
|
||||
# Check all nodes
|
||||
print("1. All nodes in the database:")
|
||||
result = await session.run("MATCH (n) RETURN labels(n) as labels, count(n) as count")
|
||||
async for record in result:
|
||||
print(f" {record['labels']}: {record['count']}")
|
||||
|
||||
# Check Memory nodes
|
||||
print("\n2. Memory nodes:")
|
||||
result = await session.run("MATCH (m:Memory) RETURN m.id as id, m.created_at as created_at")
|
||||
async for record in result:
|
||||
print(f" Memory ID: {record['id']}")
|
||||
print(f" Created: {record['created_at']}")
|
||||
|
||||
# Check Entity nodes
|
||||
print("\n3. Entity nodes:")
|
||||
result = await session.run("MATCH (e:Entity) RETURN e.name as name, e.type as type, e.properties_json as props")
|
||||
async for record in result:
|
||||
print(f" Entity: {record['name']} ({record['type']})")
|
||||
if record['props']:
|
||||
try:
|
||||
props = json.loads(record['props'])
|
||||
print(f" Properties: {props}")
|
||||
except:
|
||||
print(f" Properties: {record['props']}")
|
||||
|
||||
# Check relationships
|
||||
print("\n4. Relationships:")
|
||||
result = await session.run("""
|
||||
MATCH (m:Memory)-[r:RELATES_TO]->(e:Entity)
|
||||
RETURN m.id as memory_id, r.relationship as relationship,
|
||||
e.name as entity_name, r.confidence as confidence
|
||||
""")
|
||||
async for record in result:
|
||||
print(f" {record['memory_id'][:8]}... {record['relationship']} {record['entity_name']} (confidence: {record['confidence']})")
|
||||
|
||||
# Full graph visualization query
|
||||
print("\n5. Full graph structure:")
|
||||
result = await session.run("""
|
||||
MATCH (m:Memory)-[r:RELATES_TO]->(e:Entity)
|
||||
RETURN m.id as memory_id,
|
||||
r.relationship as relationship,
|
||||
e.name as entity_name,
|
||||
e.type as entity_type,
|
||||
r.confidence as confidence
|
||||
ORDER BY r.confidence DESC
|
||||
""")
|
||||
|
||||
print(" Graph relationships (Memory → Entity):")
|
||||
async for record in result:
|
||||
print(f" {record['memory_id'][:8]}... →[{record['relationship']}]→ {record['entity_name']} ({record['entity_type']}) [{record['confidence']}]")
|
||||
|
||||
await driver.close()
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("✅ Neo4j data check complete!")
|
||||
print("🌐 Neo4j Browser: http://localhost:7474")
|
||||
print(" Username: neo4j")
|
||||
print(" Password: langmem_neo4j_password")
|
||||
print("\n💡 Try these Cypher queries in Neo4j Browser:")
|
||||
print(" MATCH (n) RETURN n")
|
||||
print(" MATCH (m:Memory)-[r:RELATES_TO]->(e:Entity) RETURN m, r, e")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(check_neo4j_data())
|
||||
Reference in New Issue
Block a user