57 lines
2.3 KiB
Python
Executable File
57 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Test script to verify all service connections."""
|
|
|
|
import asyncio
|
|
import logging
|
|
from config import Config
|
|
from grok_client import GrokClient
|
|
from notification_client import NotificationClient
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
async def test_all_services():
|
|
"""Test connections to all configured services."""
|
|
config = Config()
|
|
|
|
print("🔍 Testing service connections...")
|
|
print(f"OpenRouter base URL: {config.openrouter_base_url}")
|
|
print(f"Grok model: {config.openrouter_model}")
|
|
print(f"Bark URL: {config.bark_api_url}")
|
|
print(f"Ntfy URL: {config.ntfy_api_url}")
|
|
|
|
# Test Grok
|
|
print("\n🤖 Testing Grok connection...")
|
|
async with GrokClient(config) as grok_client:
|
|
grok_ok = await grok_client.check_health()
|
|
if grok_ok:
|
|
print("✅ Grok service is accessible")
|
|
|
|
# Test a small prompt
|
|
test_prompt = "Hello, this is a test."
|
|
strip_think_tags = getattr(config, 'strip_think_tags', True)
|
|
response = await grok_client.generate_response(test_prompt, strip_think_tags=strip_think_tags)
|
|
if response:
|
|
print(f"✅ Grok response: {response[:100]}...")
|
|
else:
|
|
print("❌ Failed to get response from Grok")
|
|
else:
|
|
print("❌ Grok service is not accessible")
|
|
|
|
# Test notification services
|
|
print("\n📱 Testing notification services...")
|
|
async with NotificationClient(config) as notification_client:
|
|
results = await notification_client.test_connections()
|
|
|
|
print("Bark connection:", "✅ Available" if results.get("bark") else "❌ Not configured/available")
|
|
print("Ntfy connection:", "✅ Available" if results.get("ntfy") else "❌ Not configured/available")
|
|
|
|
# If device key/topic not set, show guidance
|
|
if not config.bark_device_key:
|
|
print("💡 Bark device key not set - configure with: ./config_cli.py --set-bark-key YOUR_DEVICE_KEY")
|
|
|
|
if not config.ntfy_topic:
|
|
print("💡 Ntfy topic not set - configure with: ./config_cli.py --set-ntfy-topic YOUR_TOPIC")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_all_services()) |