#!/usr/bin/env python3
"""
Тест Google Gemini API
"""

import google.generativeai as genai
from config import Config

def test_gemini_api():
    """Тестируем подключение к Google Gemini API"""
    try:
        print("🔍 Тестируем Google Gemini API...")
        print(f"🔑 API ключ: {Config.NANO_BANANA_API_KEY[:20]}...")
        
        # Настраиваем API
        genai.configure(api_key=Config.NANO_BANANA_API_KEY)
        
        # Тестовый запрос используя старый API
        print("🚀 Отправляем тестовый запрос...")
        response = genai.generate_text(prompt="Привет! Как дела?")
        
        if hasattr(response, 'result') and response.result:
            print("✅ API работает!")
            print(f"📝 Ответ: {response.result[:100]}...")
            return True
        else:
            print("❌ API не вернул текстовый ответ")
            print(f"🔍 Тип ответа: {type(response)}")
            print(f"🔍 Атрибуты: {dir(response)}")
            return False
            
    except Exception as e:
        print(f"❌ Ошибка API: {e}")
        print(f"🔍 Тип ошибки: {type(e)}")
        return False

if __name__ == '__main__':
    test_gemini_api()
