Skip to content

Commit f88b7bc

Browse files
maxmichelsjpbede
andauthored
Replace duplicate constants in olama with homeassistant.const imports (home-assistant#171949)
Co-authored-by: Jan-Philipp Benecke <jan-philipp@bnck.me>
1 parent 0500987 commit f88b7bc

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

homeassistant/components/ollama/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
import ollama
99

1010
from homeassistant.config_entries import ConfigEntry, ConfigSubentry
11-
from homeassistant.const import CONF_API_KEY, CONF_URL, Platform
11+
from homeassistant.const import (
12+
CONF_API_KEY,
13+
CONF_MODEL,
14+
CONF_PROMPT,
15+
CONF_URL,
16+
Platform,
17+
)
1218
from homeassistant.core import HomeAssistant
1319
from homeassistant.exceptions import (
1420
ConfigEntryAuthFailed,
@@ -26,9 +32,7 @@
2632
from .const import (
2733
CONF_KEEP_ALIVE,
2834
CONF_MAX_HISTORY,
29-
CONF_MODEL,
3035
CONF_NUM_CTX,
31-
CONF_PROMPT,
3236
CONF_THINK,
3337
DEFAULT_AI_TASK_NAME,
3438
DEFAULT_NAME,

homeassistant/components/ollama/config_flow.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
ConfigSubentryFlow,
1919
SubentryFlowResult,
2020
)
21-
from homeassistant.const import CONF_API_KEY, CONF_LLM_HASS_API, CONF_NAME, CONF_URL
21+
from homeassistant.const import (
22+
CONF_API_KEY,
23+
CONF_LLM_HASS_API,
24+
CONF_MODEL,
25+
CONF_NAME,
26+
CONF_PROMPT,
27+
CONF_URL,
28+
)
2229
from homeassistant.core import HomeAssistant, callback
2330
from homeassistant.helpers import config_validation as cv, llm
2431
from homeassistant.helpers.selector import (
@@ -40,9 +47,7 @@
4047
from .const import (
4148
CONF_KEEP_ALIVE,
4249
CONF_MAX_HISTORY,
43-
CONF_MODEL,
4450
CONF_NUM_CTX,
45-
CONF_PROMPT,
4651
CONF_THINK,
4752
DEFAULT_AI_TASK_NAME,
4853
DEFAULT_CONVERSATION_NAME,

homeassistant/components/ollama/const.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
DEFAULT_NAME = "Ollama"
66

7-
# pylint: disable-next=home-assistant-duplicate-const
8-
CONF_MODEL = "model"
9-
# pylint: disable-next=home-assistant-duplicate-const
10-
CONF_PROMPT = "prompt"
117
CONF_THINK = "think"
128

139
CONF_KEEP_ALIVE = "keep_alive"

homeassistant/components/ollama/conversation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
from homeassistant.components import conversation
66
from homeassistant.config_entries import ConfigSubentry
7-
from homeassistant.const import CONF_LLM_HASS_API, MATCH_ALL
7+
from homeassistant.const import CONF_LLM_HASS_API, CONF_PROMPT, MATCH_ALL
88
from homeassistant.core import HomeAssistant
99
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1010

1111
from . import OllamaConfigEntry
12-
from .const import CONF_PROMPT, DOMAIN
12+
from .const import DOMAIN
1313
from .entity import OllamaBaseLLMEntity
1414

1515

homeassistant/components/ollama/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from homeassistant.components import conversation
1313
from homeassistant.config_entries import ConfigSubentry
14+
from homeassistant.const import CONF_MODEL
1415
from homeassistant.exceptions import HomeAssistantError
1516
from homeassistant.helpers import device_registry as dr, llm
1617
from homeassistant.helpers.entity import Entity
@@ -20,7 +21,6 @@
2021
from .const import (
2122
CONF_KEEP_ALIVE,
2223
CONF_MAX_HISTORY,
23-
CONF_MODEL,
2424
CONF_NUM_CTX,
2525
CONF_THINK,
2626
DEFAULT_KEEP_ALIVE,

0 commit comments

Comments
 (0)