mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-26 09:04:00 +08:00
Release v2.0.0
This commit is contained in:
@@ -4,17 +4,18 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import voluptuous as vol
|
|
||||||
from typing import Any, Dict, Optional
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
from async_timeout import timeout
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from async_timeout import timeout
|
|
||||||
|
|
||||||
from .coordinator import HATextAICoordinator
|
from .coordinator import HATextAICoordinator
|
||||||
from .const import (
|
from .const import (
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"""Config flow for HA text AI integration."""
|
"""Config flow for HA text AI integration."""
|
||||||
|
import logging
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
import voluptuous as vol
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@@ -33,7 +33,6 @@ from .const import (
|
|||||||
MIN_REQUEST_INTERVAL,
|
MIN_REQUEST_INTERVAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
import logging
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class HATextAIConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class HATextAIConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional, List
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from openai import AsyncOpenAI, APIError, RateLimitError
|
import httpx
|
||||||
|
from openai import AsyncOpenAI, APIError, AuthenticationError, RateLimitError
|
||||||
from anthropic import AsyncAnthropic
|
from anthropic import AsyncAnthropic
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
"""Sensor platform for HA text AI."""
|
"""Sensor platform for HA text AI."""
|
||||||
from datetime import datetime
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import SensorEntity
|
||||||
SensorEntity,
|
|
||||||
SensorStateClass,
|
|
||||||
SensorDeviceClass,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
@@ -22,21 +17,11 @@ from .const import (
|
|||||||
CONF_API_PROVIDER,
|
CONF_API_PROVIDER,
|
||||||
ATTR_QUESTION,
|
ATTR_QUESTION,
|
||||||
ATTR_RESPONSE,
|
ATTR_RESPONSE,
|
||||||
ATTR_LAST_UPDATED,
|
|
||||||
ATTR_MODEL,
|
ATTR_MODEL,
|
||||||
ATTR_TEMPERATURE,
|
|
||||||
ATTR_MAX_TOKENS,
|
|
||||||
ATTR_TOTAL_RESPONSES,
|
ATTR_TOTAL_RESPONSES,
|
||||||
ATTR_SYSTEM_PROMPT,
|
|
||||||
ATTR_QUEUE_SIZE,
|
|
||||||
ATTR_API_STATUS,
|
ATTR_API_STATUS,
|
||||||
ATTR_ERROR_COUNT,
|
ATTR_ERROR_COUNT,
|
||||||
ATTR_LAST_ERROR,
|
ATTR_LAST_ERROR,
|
||||||
ATTR_RESPONSE_TIME,
|
|
||||||
ATTR_API_VERSION,
|
|
||||||
ATTR_ENDPOINT_STATUS,
|
|
||||||
ATTR_REQUEST_COUNT,
|
|
||||||
ATTR_TOKENS_USED,
|
|
||||||
ENTITY_ICON,
|
ENTITY_ICON,
|
||||||
ENTITY_ICON_ERROR,
|
ENTITY_ICON_ERROR,
|
||||||
ENTITY_ICON_PROCESSING,
|
ENTITY_ICON_PROCESSING,
|
||||||
|
|||||||
Reference in New Issue
Block a user