- 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>
90 lines
3.6 KiB
Python
90 lines
3.6 KiB
Python
#!/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()) |