Add device info to OpenAI (#118077)
This commit is contained in:
parent
d71c7705ae
commit
a257f63119
2 changed files with 10 additions and 3 deletions
|
@ -86,7 +86,7 @@ class OpenAIConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title="OpenAI Conversation",
|
title="ChatGPT",
|
||||||
data=user_input,
|
data=user_input,
|
||||||
options={CONF_LLM_HASS_API: llm.LLM_API_ASSIST},
|
options={CONF_LLM_HASS_API: llm.LLM_API_ASSIST},
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_LLM_HASS_API, MATCH_ALL
|
from homeassistant.const import CONF_LLM_HASS_API, MATCH_ALL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError, TemplateError
|
from homeassistant.exceptions import HomeAssistantError, TemplateError
|
||||||
from homeassistant.helpers import intent, llm, template
|
from homeassistant.helpers import device_registry as dr, intent, llm, template
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util import ulid
|
from homeassistant.util import ulid
|
||||||
|
|
||||||
|
@ -60,13 +60,20 @@ class OpenAIConversationEntity(
|
||||||
"""OpenAI conversation agent."""
|
"""OpenAI conversation agent."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
def __init__(self, entry: ConfigEntry) -> None:
|
def __init__(self, entry: ConfigEntry) -> None:
|
||||||
"""Initialize the agent."""
|
"""Initialize the agent."""
|
||||||
self.entry = entry
|
self.entry = entry
|
||||||
self.history: dict[str, list[dict]] = {}
|
self.history: dict[str, list[dict]] = {}
|
||||||
self._attr_name = entry.title
|
|
||||||
self._attr_unique_id = entry.entry_id
|
self._attr_unique_id = entry.entry_id
|
||||||
|
self._attr_device_info = dr.DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, entry.entry_id)},
|
||||||
|
name=entry.title,
|
||||||
|
manufacturer="OpenAI",
|
||||||
|
model="ChatGPT",
|
||||||
|
entry_type=dr.DeviceEntryType.SERVICE,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_languages(self) -> list[str] | Literal["*"]:
|
def supported_languages(self) -> list[str] | Literal["*"]:
|
||||||
|
|
Loading…
Add table
Reference in a new issue