Skip to content

Commit

Permalink
check if already_configured
Browse files Browse the repository at this point in the history
  • Loading branch information
ej52 committed Nov 10, 2023
1 parent cbe2b37 commit 66fd604
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/ollama_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ async def async_step_user(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA
)

# Search for duplicates with the same CONF_BASE_URL value.
for existing_entry in self._async_current_entries(include_ignore=False):
if existing_entry.data.get(CONF_BASE_URL) == user_input[CONF_BASE_URL]:
return self.async_abort(reason="already_configured")

errors = {}
try:
self.client = OllamaApiClient(
Expand All @@ -114,7 +119,7 @@ async def async_step_user(
LOGGER.exception("Unexpected exception: %s", exception)
errors["base"] = "unknown"
else:
return self.async_create_entry(title="", data=user_input)
return self.async_create_entry(title=f"Ollama - {user_input[CONF_BASE_URL]}", data=user_input)

return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
Expand Down

0 comments on commit 66fd604

Please sign in to comment.