#!/usr/bin/env python3 """Test script to verify all service connections.""" import asyncio import logging from config import Config from ollama_client import OllamaClient 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"Current config: {config.ollama_endpoint}") print(f"Bark URL: {config.bark_api_url}") print(f"Ntfy URL: {config.ntfy_api_url}") # Test Ollama print("\nšŸ¤– Testing Ollama connection...") async with OllamaClient(config) as ollama_client: ollama_ok = await ollama_client.check_health() if ollama_ok: print("āœ… Ollama service is accessible") # Test a small prompt test_prompt = "Hello, this is a test." response = await ollama_client.generate_response(test_prompt) if response: print(f"āœ… Ollama response: {response[:100]}...") else: print("āŒ Failed to get response from Ollama") else: print("āŒ Ollama 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())