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

73 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""
Check recent messages in Home Assistant room
"""
import asyncio
import json
import httpx
from datetime import datetime
# 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 check_recent_messages():
"""Check recent messages in Home Assistant room"""
print("📨 Checking recent messages in Home Assistant room...")
headers = {
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
"Content-Type": "application/json"
}
try:
async with httpx.AsyncClient() as client:
# Get recent messages from the room
response = await client.get(
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/messages?dir=b&limit=10",
headers=headers,
timeout=30.0
)
if response.status_code == 200:
data = response.json()
events = data.get('chunk', [])
print(f"✅ Found {len(events)} recent events")
print("\n📋 Recent messages:")
for i, event in enumerate(events):
if event.get('type') == 'm.room.message':
content = event.get('content', {})
body = content.get('body', '')
sender = event.get('sender', '')
timestamp = event.get('origin_server_ts', 0)
# Convert timestamp to readable format
dt = datetime.fromtimestamp(timestamp / 1000)
time_str = dt.strftime('%Y-%m-%d %H:%M:%S')
print(f" {i+1}. [{time_str}] {sender}: {body}")
# Check if this is our test message
if "Matrix API test message from LangMem debug script" in body:
print(" ✅ This is our test message!")
return True
else:
print(f"❌ Failed to get messages: {response.status_code}")
print(f"Response: {response.text}")
return False
except Exception as e:
print(f"❌ Error checking messages: {e}")
return False
async def main():
"""Main function"""
await check_recent_messages()
if __name__ == "__main__":
asyncio.run(main())