mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-29 09:23:56 +08:00
Release v2.0.0
This commit is contained in:
@@ -46,13 +46,6 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=float(request_interval)),
|
update_interval=timedelta(seconds=float(request_interval)),
|
||||||
)
|
)
|
||||||
"""Initialize coordinator."""
|
|
||||||
super().__init__(
|
|
||||||
hass,
|
|
||||||
_LOGGER,
|
|
||||||
name=DOMAIN,
|
|
||||||
update_interval=timedelta(seconds=request_interval),
|
|
||||||
)
|
|
||||||
|
|
||||||
self._validate_params(api_key, temperature, max_tokens)
|
self._validate_params(api_key, temperature, max_tokens)
|
||||||
|
|
||||||
@@ -134,11 +127,8 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
async def _async_update_data(self) -> Dict[str, Any]:
|
async def _async_update_data(self) -> Dict[str, Any]:
|
||||||
"""Update data via API."""
|
"""Update data via API."""
|
||||||
if not self._is_ready:
|
if not self._is_ready or self._question_queue.empty():
|
||||||
return self._responses
|
return {}
|
||||||
|
|
||||||
if self._question_queue.empty():
|
|
||||||
return self._responses
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
||||||
@@ -172,6 +162,12 @@ class HATextAICoordinator(DataUpdateCoordinator):
|
|||||||
_LOGGER.error("Error processing question: %s", str(err))
|
_LOGGER.error("Error processing question: %s", str(err))
|
||||||
await self._handle_api_error(question, err)
|
await self._handle_api_error(question, err)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
_LOGGER.error("Critical error in _async_update_data: %s", str(e))
|
||||||
|
self._is_ready = False
|
||||||
|
self._endpoint_status = "error"
|
||||||
|
return {}
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self._is_processing = False
|
self._is_processing = False
|
||||||
self._question_queue.task_done()
|
self._question_queue.task_done()
|
||||||
|
|||||||
Reference in New Issue
Block a user