Skip to content

Commit 76c5629

Browse files
author
SMKRV
committed
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.
1 parent 7958bd0 commit 76c5629

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

custom_components/ha_text_ai/api_client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ async def _create_gemini_completion(
263263
Dictionary with response content and token usage
264264
"""
265265
try:
266-
# Импортируем библиотеку в отдельном потоке, чтобы избежать блокировки event loop
267266
def import_genai():
268267
from google import genai
269268
return genai
@@ -273,7 +272,6 @@ def import_genai():
273272
# Extract API key from headers (Bearer token)
274273
api_key = self.headers.get("Authorization", "").replace("Bearer ", "")
275274

276-
# Создаем клиент в отдельном потоке
277275
def create_client():
278276
if self.endpoint and self.endpoint != "https://generativelanguage.googleapis.com/v1beta":
279277
return genai.Client(api_key=api_key, transport="rest",
@@ -314,7 +312,6 @@ def create_config():
314312

315313
config = await asyncio.to_thread(create_config)
316314

317-
# Выполняем запрос в отдельном потоке
318315
def generate_content():
319316
# For single message without history, use generate_content
320317
if len(contents) <= 1:

0 commit comments

Comments
 (0)