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

98 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""
Debug Matrix API connection step by step
"""
import asyncio
import json
import httpx
# Matrix configuration
MATRIX_HOMESERVER = "https://matrix.klas.chat"
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
HOME_ASSISTANT_ROOM_ID = "!xZkScMybPseErYMJDz:matrix.klas.chat"
async def test_matrix_connection():
"""Test Matrix connection step by step"""
print("🔍 Testing Matrix API connection...")
headers = {
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
"Content-Type": "application/json"
}
try:
async with httpx.AsyncClient() as client:
# Test 1: Check if we can access the Matrix server
print("\n1. Testing Matrix server access...")
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/versions", timeout=30.0)
print(f" Status: {response.status_code}")
if response.status_code == 200:
print(" ✅ Matrix server is accessible")
else:
print(" ❌ Matrix server access failed")
return False
# Test 2: Check if our access token is valid
print("\n2. Testing access token...")
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/v3/account/whoami", headers=headers, timeout=30.0)
print(f" Status: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f" ✅ Access token valid, user: {data.get('user_id')}")
else:
print(" ❌ Access token invalid")
print(f" Response: {response.text}")
return False
# Test 3: Check if we can access the Home Assistant room
print("\n3. Testing Home Assistant room access...")
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/state/m.room.name", headers=headers, timeout=30.0)
print(f" Status: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f" ✅ Room accessible, name: {data.get('name')}")
else:
print(" ❌ Room access failed")
print(f" Response: {response.text}")
return False
# Test 4: Send a simple test message
print("\n4. Sending test message...")
message_data = {
"msgtype": "m.text",
"body": "🔧 Matrix API test message from LangMem debug script"
}
response = await client.post(
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/send/m.room.message",
headers=headers,
json=message_data,
timeout=30.0
)
print(f" Status: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f" ✅ Message sent successfully!")
print(f" Event ID: {data.get('event_id')}")
return True
else:
print(" ❌ Message sending failed")
print(f" Response: {response.text}")
return False
except Exception as e:
print(f"❌ Error during testing: {e}")
return False
async def main():
"""Main function"""
success = await test_matrix_connection()
if success:
print("\n🎉 All Matrix API tests passed!")
else:
print("\n❌ Matrix API tests failed!")
if __name__ == "__main__":
asyncio.run(main())