Skip to content

Commit

Permalink
Fix the "assistant search" issue (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixR49 committed Nov 20, 2024
1 parent e6996e1 commit eb16469
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
11 changes: 5 additions & 6 deletions custom_components/huggingchat_conversation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from homeassistant.helpers import intent, template

from .const import (
CONF_ASSISTANT_NAME,
CONF_ASSISTANT_ID,
CONF_ASSISTANTS,
CONF_CHAT_MODEL,
CONF_PROMPT,
CONF_WEB_SEARCH,
CONF_WEB_SEARCH_ENGINE,
CONF_WEB_SEARCH_PROMPT,
DEFAULT_ASSISTANT_NAME,
DEFAULT_ASSISTANT_ID,
DEFAULT_ASSISTANTS,
DEFAULT_CHAT_MODEL,
DEFAULT_PROMPT,
Expand Down Expand Up @@ -84,8 +84,8 @@ async def async_process(
assistants = self.entry.options.get(
CONF_ASSISTANTS, DEFAULT_ASSISTANTS
)
assistant_name = self.entry.options.get(
CONF_ASSISTANT_NAME, DEFAULT_ASSISTANT_NAME
assistant_id = self.entry.options.get(
CONF_ASSISTANT_ID, DEFAULT_ASSISTANT_ID
)
web_search = self.entry.options.get(CONF_WEB_SEARCH, DEFAULT_WEB_SEARCH)
web_search_engine = self.entry.options.get(
Expand Down Expand Up @@ -197,8 +197,7 @@ async def aget_results():

try:
if assistants:
assistant = await self.hass.async_add_executor_job(chatbot.search_assistant, assistant_name)
await self.hass.async_add_executor_job(chatbot.new_conversation, model, prompt, True, assistant)
await self.hass.async_add_executor_job(chatbot.new_conversation, model, prompt, True, assistant_id)

if web_search & (web_search_engine == "google"):
result = await self.hass.async_add_executor_job(
Expand Down
12 changes: 6 additions & 6 deletions custom_components/huggingchat_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)

from .const import (
CONF_ASSISTANT_NAME,
CONF_ASSISTANT_ID,
CONF_ASSISTANTS,
CONF_CHAT_MODEL,
CONF_EMAIL,
Expand All @@ -32,7 +32,7 @@
CONF_WEB_SEARCH,
CONF_WEB_SEARCH_ENGINE,
CONF_WEB_SEARCH_PROMPT,
DEFAULT_ASSISTANT_NAME,
DEFAULT_ASSISTANT_ID,
DEFAULT_ASSISTANTS,
DEFAULT_CHAT_MODEL,
DEFAULT_EMAIL,
Expand Down Expand Up @@ -64,7 +64,7 @@
CONF_CHAT_MODEL: DEFAULT_CHAT_MODEL,
CONF_PROMPT: DEFAULT_PROMPT,
CONF_ASSISTANTS: DEFAULT_ASSISTANTS,
CONF_ASSISTANT_NAME: DEFAULT_ASSISTANT_NAME,
CONF_ASSISTANT_ID: DEFAULT_ASSISTANT_ID,
CONF_WEB_SEARCH: DEFAULT_WEB_SEARCH,
CONF_WEB_SEARCH_ENGINE: DEFAULT_WEB_SEARCH_ENGINE,
CONF_WEB_SEARCH_PROMPT: DEFAULT_WEB_SEARCH_PROMPT,
Expand Down Expand Up @@ -187,9 +187,9 @@ def initialize_chatbot(cookies):
default=DEFAULT_ASSISTANTS,
): bool,
vol.Optional(
CONF_ASSISTANT_NAME,
description={"suggested_value": options[CONF_ASSISTANT_NAME]},
default=DEFAULT_ASSISTANT_NAME,
CONF_ASSISTANT_ID,
description={"suggested_value": options[CONF_ASSISTANT_ID]},
default=DEFAULT_ASSISTANT_ID,
): str,
vol.Optional(
CONF_WEB_SEARCH,
Expand Down
4 changes: 2 additions & 2 deletions custom_components/huggingchat_conversation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"""
DEFAULT_ASSISTANTS = False
CONF_ASSISTANTS = "enable_assistants"
DEFAULT_ASSISTANT_NAME = "ChatGpt"
CONF_ASSISTANT_NAME = "assistant_id"
DEFAULT_ASSISTANT_ID = "65bd6d583140495b7e30f744"
CONF_ASSISTANT_ID = "assistant_id"
DEFAULT_WEB_SEARCH = False
CONF_WEB_SEARCH = "web_search"
DEFAULT_WEB_SEARCH_ENGINE = "ddg"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/huggingchat_conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/PhoenixR49/hass-huggingchat-conversation/issues",
"requirements": ["hugchat==0.4.16", "duckduckgo-search==6.3.5"],
"version": "1.3.6"
"version": "1.3.7"
}
2 changes: 1 addition & 1 deletion custom_components/huggingchat_conversation/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"chat_model": "Completion model",
"prompt": "Prompt template",
"enable_assistants": "Enable Assistants",
"assistant_name": "Assistant ID",
"assistant_id": "Assistant ID",
"web_search": "Enable Web search",
"web_search_engine": "Search engine",
"web_search_prompt": "Search prompt template"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"chat_model": "Chat-Modell",
"prompt": "Prompt-Vorlage",
"enable_assistants": "Assistenten aktivieren",
"assistant_name": "Assistenten-ID",
"assistant_id": "Assistenten-ID",
"web_search": "Web-Suche aktivieren",
"web_search_engine": "Suchmaschine",
"web_search_prompt": "Suchaufforderung"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"chat_model": "Completion model",
"prompt": "Prompt template",
"enable_assistants": "Enable assistants",
"assistant_name": "Assistant ID",
"assistant_id": "Assistant ID",
"web_search": "Enable Web search",
"web_search_engine": "Search engine",
"web_search_prompt": "Search prompt template"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"chat_model": "Modèle de complétion",
"prompt": "Modèle d'invite",
"enable_assistants": "Activer les assistants",
"assistant_name": "Identifiant de l'assistant",
"assistant_id": "Identifiant de l'assistant",
"web_search": "Activer la recherche Web",
"web_search_engine": "Moteur de recherche",
"web_search_prompt": "Modèle d'invite de recherche"
Expand Down

0 comments on commit eb16469

Please sign in to comment.