Skip to content

Commit

Permalink
fix: base_url and config lfow
Browse files Browse the repository at this point in the history
  • Loading branch information
ej52 committed Nov 4, 2023
1 parent 6b9f1c4 commit 619cb52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 0 additions & 3 deletions custom_components/ollama_conversation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def __init__(
session: aiohttp.ClientSession,
) -> None:
"""Sample API Client."""
if not base_url.endswith("/"):
base_url = f"{base_url}/"

self._base_url = base_url
self._session = session

Expand Down
15 changes: 4 additions & 11 deletions custom_components/ollama_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ async def async_step_init(
if user_input is not None:
return self.async_create_entry(title="Ollama Conversation", data=user_input)

errors = {}
try:
# Cannot use cv.url validation in the schema itself, so
# apply extra validation here.
Expand All @@ -142,21 +141,15 @@ async def async_step_init(
session=async_create_clientsession(self.hass),
)
response = await client.async_get_models()
except vol.Invalid:
errors["base"] = "invalid_url"
except OllamaApiClientAuthenticationError:
errors["base"] = "invalid_auth"
except OllamaApiClientCommunicationError:
errors["base"] = "cannot_connect"
models = response["models"]
except OllamaApiClientError as exception:
LOGGER.exception("Unexpected exception: %s", exception)
errors["base"] = "unknown"
models = []

schema = ollama_config_option_schema(self.config_entry.options, [model["name"] for model in response["models"]])
schema = ollama_config_option_schema(self.config_entry.options, [model["name"] for model in models])
return self.async_show_form(
step_id="init",
data_schema=vol.Schema(schema),
errors=errors
data_schema=vol.Schema(schema)
)


Expand Down

0 comments on commit 619cb52

Please sign in to comment.