From 76c5629fa0f6bca3e6ab10552f26dcd0dd71189a Mon Sep 17 00:00:00 2001 From: SMKRV Date: Wed, 21 May 2025 01:27:47 +0300 Subject: [PATCH] refactor(google-gemini): rewrite integration using google-genai 1.16.0 Completely rewrote the Google Gemini integration logic based on google-genai 1.16.0 to fix issue #6. Key changes: - Updated to the latest google-genai library - Made API endpoint abstract while retaining option for custom endpoint configuration - Refactored logic and classes exclusively within Google Gemini implementation - All changes are limited to Google Gemini integration refactoring with no impact on other functionality. --- custom_components/ha_text_ai/api_client.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/custom_components/ha_text_ai/api_client.py b/custom_components/ha_text_ai/api_client.py index b45f906..8346784 100644 --- a/custom_components/ha_text_ai/api_client.py +++ b/custom_components/ha_text_ai/api_client.py @@ -263,7 +263,6 @@ class APIClient: Dictionary with response content and token usage """ try: - # Импортируем библиотеку в отдельном потоке, чтобы избежать блокировки event loop def import_genai(): from google import genai return genai @@ -273,7 +272,6 @@ class APIClient: # Extract API key from headers (Bearer token) api_key = self.headers.get("Authorization", "").replace("Bearer ", "") - # Создаем клиент в отдельном потоке def create_client(): if self.endpoint and self.endpoint != "https://generativelanguage.googleapis.com/v1beta": return genai.Client(api_key=api_key, transport="rest", @@ -314,7 +312,6 @@ class APIClient: config = await asyncio.to_thread(create_config) - # Выполняем запрос в отдельном потоке def generate_content(): # For single message without history, use generate_content if len(contents) <= 1: