#!/usr/bin/env python3
"""Direct test of Qwen via Graphiti worker in the container."""
import subprocess, json
# Build payload
key = ""
with open("/etc/graphiti/graphiti.env") as f:
for line in f:
if line.startswith("OPENROUTER_API_KEY="):
key = line.split("=", 1)[1].strip()
break
payload = {
"model": "qwen/qwen3.7-flash",
"messages": [{"role": "user", "content": '{"test": true}'}],
"effective_timeout": 60,
"api_key": key,
"base_url": "https://openrouter.ai/api/v1"
}
# Write to temp file on VPS
with open('/tmp/test_worker.json', 'w') as f:
json.dump(payload, f)
# Copy to container and run worker
subprocess.run(['docker', 'cp', '/tmp/test_worker.json',
'graphiti-service:/app/test_payload.json'], check=True)
# Run llm_call_worker.py with the test payload
result = subprocess.run(
['docker', 'exec', 'graphiti-service', 'python3', '-c',
'import json, asyncio; '
'from llm_call_worker import call; '
'result = asyncio.run(call(json.load(open("/app/test_payload.json")))); '
'print(json.dumps(result, indent=2))'],
capture_output=True, text=True, timeout=90
)
print("STDOUT:")
try:
data = json.loads(result.stdout.strip())
print(f"OK: {data.get('ok')}")
print(f"Raw content present: {bool(data.get('raw'))}")
if data.get('raw'):
print(f"Content (first 200 chars): {repr(data['raw'][:200])}")
# Try parse as JSON
try:
parsed = json.loads(data['raw'])
print(f"Parsed successfully: {parsed}")
except:
pass
else:
print(f"Raw value: {data.get('raw')}")
print(f"Error type: {data.get('error_type','N/A')}")
print(f"Error message: {data.get('error','')[:200]}")
except Exception as e:
print(f"Parse error: {e}")
print(result.stdout[:500])
if result.stderr:
print(f"\nSTDERR:\n{result.stderr[:500]}")