mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-29 04:43:56 +08:00
Release v2.0.0
This commit is contained in:
@@ -44,13 +44,8 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
session: Optional[Any] = None,
|
session: Optional[Any] = None,
|
||||||
is_anthropic: bool = False,
|
is_anthropic: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(
|
"""Initialize coordinator."""
|
||||||
hass,
|
self._name = name # Инициализируем name до вызова super().__init__
|
||||||
_LOGGER,
|
|
||||||
name=name,
|
|
||||||
update_interval=timedelta(seconds=float(request_interval)),
|
|
||||||
)
|
|
||||||
self._name = name
|
|
||||||
self._validate_params(api_key, temperature, max_tokens)
|
self._validate_params(api_key, temperature, max_tokens)
|
||||||
self._entity_id = None
|
self._entity_id = None
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
@@ -80,7 +75,19 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
self._last_request_time = 0
|
self._last_request_time = 0
|
||||||
self._is_anthropic = is_anthropic
|
self._is_anthropic = is_anthropic
|
||||||
self._session = session or aiohttp_client.async_get_clientsession(hass)
|
self._session = session or aiohttp_client.async_get_clientsession(hass)
|
||||||
self.client = None # Initialize client as None
|
self.client = None
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
hass,
|
||||||
|
_LOGGER,
|
||||||
|
name=self._name, # Используем уже установленное значение
|
||||||
|
update_interval=timedelta(seconds=float(request_interval)),
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
"""Return the name of the coordinator."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
async def async_initialize(self) -> None:
|
async def async_initialize(self) -> None:
|
||||||
"""Initialize coordinator."""
|
"""Initialize coordinator."""
|
||||||
@@ -515,11 +522,6 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
"""Set entity ID."""
|
"""Set entity ID."""
|
||||||
self._entity_id = value
|
self._entity_id = value
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Get coordinator name."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def performance_metrics(self) -> Dict[str, Any]:
|
def performance_metrics(self) -> Dict[str, Any]:
|
||||||
"""Return current performance metrics."""
|
"""Return current performance metrics."""
|
||||||
|
|||||||
Reference in New Issue
Block a user