#!/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())