Release v2.0.0

This commit is contained in:
SMKRV
2024-11-23 21:55:34 +03:00
parent 894b600b09
commit 500c7fbe30
@@ -14,6 +14,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.exceptions import HomeAssistantError, UpdateFailed
from openai import AsyncOpenAI, APIError, AuthenticationError, RateLimitError from openai import AsyncOpenAI, APIError, AuthenticationError, RateLimitError
from anthropic import AsyncAnthropic from anthropic import AsyncAnthropic
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@@ -103,6 +104,7 @@ class HATextAICoordinator(DataUpdateCoordinator):
self._session = session or aiohttp_client.async_get_clientsession(hass) self._session = session or aiohttp_client.async_get_clientsession(hass)
self.client = None self.client = None
self.hass = hass # Store hass reference for _init_client self.hass = hass # Store hass reference for _init_client
self._start_time = time.time()
# History and metrics # History and metrics
self._history: List[Dict[str, Any]] = [] self._history: List[Dict[str, Any]] = []
@@ -156,6 +158,18 @@ class HATextAICoordinator(DataUpdateCoordinator):
_LOGGER.error("Error initializing API client: %s", str(e)) _LOGGER.error("Error initializing API client: %s", str(e))
raise raise
async def async_initialize(self) -> None:
"""Initialize coordinator."""
try:
await self._init_client()
self._is_ready = True
self._endpoint_status = "connected"
except Exception as e:
self._last_error = str(e)
self._endpoint_status = "error"
_LOGGER.error("Failed to initialize coordinator: %s", str(e))
raise
async def async_ask( async def async_ask(
self, self,
question: str, question: str,