Add device info to OpenAI (#118077)

This commit is contained in:
Paulus Schoutsen 2024-05-24 23:55:01 -04:00 committed by GitHub
parent d71c7705ae
commit a257f63119
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -86,7 +86,7 @@ class OpenAIConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "unknown"
else:
return self.async_create_entry(
title="OpenAI Conversation",
title="ChatGPT",
data=user_input,
options={CONF_LLM_HASS_API: llm.LLM_API_ASSIST},
)

View file

@ -12,7 +12,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_LLM_HASS_API, MATCH_ALL
from homeassistant.core import HomeAssistant
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.util import ulid
@ -60,13 +60,20 @@ class OpenAIConversationEntity(
"""OpenAI conversation agent."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, entry: ConfigEntry) -> None:
"""Initialize the agent."""
self.entry = entry
self.history: dict[str, list[dict]] = {}
self._attr_name = entry.title
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
def supported_languages(self) -> list[str] | Literal["*"]: