Skip to content

Commit

Permalink
Revert unnesesary CONF_MODEL_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
black-roland committed Dec 12, 2024
1 parent 9b74d88 commit 52f63ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
13 changes: 6 additions & 7 deletions custom_components/yandexgpt_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
CONF_CHAT_MODEL,
CONF_FOLDER_ID,
CONF_MAX_TOKENS,
CONF_MODEL_NAME,
CONF_MODEL_VERSION,
CONF_PROMPT,
CONF_RECOMMENDED,
CONF_TEMPERATURE,
DEFAULT_CHAT_MODEL,
DEFAULT_INSTRUCTIONS_PROMPT_RU,
DEFAULT_MODEL_NAME,
DEFAULT_MODEL_VERSION,
DOMAIN,
RECOMMENDED_MAX_TOKENS,
Expand Down Expand Up @@ -126,7 +125,7 @@ async def async_step_init(
CONF_RECOMMENDED: user_input[CONF_RECOMMENDED],
CONF_PROMPT: user_input[CONF_PROMPT],
CONF_LLM_HASS_API: user_input[CONF_LLM_HASS_API],
CONF_MODEL_NAME: user_input[CONF_MODEL_NAME],
CONF_CHAT_MODEL: user_input[CONF_CHAT_MODEL],
}

suggested_values = options.copy()
Expand All @@ -135,7 +134,7 @@ async def async_step_init(

if suggested_values.get(CONF_CHAT_MODEL):
deprecated_model_name = suggested_values[CONF_CHAT_MODEL].split("/")[0]
suggested_values[CONF_MODEL_NAME] = deprecated_model_name
suggested_values[CONF_CHAT_MODEL] = deprecated_model_name

schema = self.add_suggested_values_to_schema(
vol.Schema(yandexgpt_config_option_schema(self.hass, options)),
Expand Down Expand Up @@ -185,9 +184,9 @@ def yandexgpt_config_option_schema(
SelectSelectorConfig(options=hass_apis, translation_key=CONF_LLM_HASS_API)
),
vol.Optional(
CONF_MODEL_NAME,
description={"suggested_value": options.get(CONF_MODEL_NAME)},
default=DEFAULT_MODEL_NAME,
CONF_CHAT_MODEL,
description={"suggested_value": options.get(CONF_CHAT_MODEL)},
default=DEFAULT_CHAT_MODEL,
): SelectSelector(
SelectSelectorConfig(mode=SelectSelectorMode.DROPDOWN, options=model_names)
),
Expand Down
5 changes: 2 additions & 3 deletions custom_components/yandexgpt_conversation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
CONF_RECOMMENDED = "recommended"
CONF_MAX_TOKENS = "max_tokens"
CONF_TEMPERATURE = "temperature"
CONF_CHAT_MODEL = "chat_model" # deprecated
CONF_MODEL_NAME = "model_name"
CONF_CHAT_MODEL = "chat_model"
CONF_MODEL_VERSION = "model_version"
DEFAULT_MODEL_NAME = "yandexgpt-lite"
DEFAULT_CHAT_MODEL = "yandexgpt-lite"
DEFAULT_MODEL_VERSION = "latest"
RECOMMENDED_MAX_TOKENS = 1024
RECOMMENDED_TEMPERATURE = 0.6
Expand Down
6 changes: 2 additions & 4 deletions custom_components/yandexgpt_conversation/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
BASE_PROMPT_RU,
CONF_CHAT_MODEL,
CONF_MAX_TOKENS,
CONF_MODEL_NAME,
CONF_MODEL_VERSION,
CONF_PROMPT,
CONF_TEMPERATURE,
DEFAULT_CHAT_MODEL,
DEFAULT_INSTRUCTIONS_PROMPT_RU,
DEFAULT_MODEL_NAME,
DEFAULT_MODEL_VERSION,
DOMAIN,
LOGGER,
Expand Down Expand Up @@ -190,9 +189,8 @@ async def async_process(
)

client: AsyncYCloudML = self.entry.runtime_data
model_name = options.get(CONF_MODEL_NAME, DEFAULT_MODEL_NAME)
# model name and version were stored in a different format previously
model_name = options.get(CONF_CHAT_MODEL, model_name).split("/")[0]
model_name = options.get(CONF_CHAT_MODEL, DEFAULT_CHAT_MODEL).split("/")[0]
model_ver = options.get(CONF_MODEL_VERSION, DEFAULT_MODEL_VERSION)
model_conf = {
"temperature": options.get(CONF_TEMPERATURE, RECOMMENDED_TEMPERATURE),
Expand Down

0 comments on commit 52f63ce

Please sign in to comment.