import ollama
import json
from utils import setup_logging

logger = setup_logging()

def test_llm_connection():
    """Test if Llama3.3 is working"""
    try:
        response = ollama.chat(
            model='llama3.3',
            messages=[
                {
                    'role': 'user',
                    'content': 'Respond with only this JSON: {"status": "working", "message": "LLM is responding"}'
                }
            ]
        )
        
        print("="*60)
        print("LLM RESPONSE:")
        print(response['message']['content'])
        print("="*60)
        
        # Try to parse
        try:
            data = json.loads(response['message']['content'])
            print("✓ JSON parsing successful!")
            print(data)
        except:
            print("✗ JSON parsing failed")
            
    except Exception as e:
        print(f"ERROR: {e}")

if __name__ == "__main__":
    test_llm_connection()