#!/usr/bin/env python
"""
Test script for OpenRouter model configuration in report synthesis.
"""

import asyncio
import logging
from report.report_synthesis import get_report_synthesizer

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

async def test_openrouter_model():
    """Test OpenRouter model configuration."""
    logger.info("Testing OpenRouter model configuration...")
    
    # Get report synthesizer with OpenRouter model
    synthesizer = get_report_synthesizer("openrouter-claude-3.7-sonnet")
    
    # Print model configuration
    logger.info(f"Using model: {synthesizer.model_name}")
    logger.info(f"Model config: {synthesizer.model_config}")
    
    # Create a simple test message
    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, can you help me with a test?"}
    ]
    
    try:
        # Generate completion
        logger.info("Generating completion...")
        response = await synthesizer.generate_completion(messages)
        
        # Print response
        logger.info(f"Response: {response}")
        
        return True
    except Exception as e:
        logger.error(f"Error testing OpenRouter model: {e}")
        return False

async def main():
    """Main function."""
    success = await test_openrouter_model()
    
    if success:
        logger.info("OpenRouter model test successful!")
    else:
        logger.error("OpenRouter model test failed!")

if __name__ == "__main__":
    asyncio.run(main())
