Skip to content

Commit

Permalink
fix: strip / from base_url when making request
Browse files Browse the repository at this point in the history
  • Loading branch information
ej52 committed Nov 4, 2023
1 parent 8ad6299 commit 848a69b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions custom_components/ollama_conversation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ async def async_step_user(

errors = {}
try:
# Cannot use cv.url validation in the schema itself, so
# apply extra validation here.
cv.url_no_path(user_input[CONF_BASE_URL])

client = OllamaApiClient(
base_url=user_input[CONF_BASE_URL],
base_url=cv.url_no_path(user_input[CONF_BASE_URL]).rstrip("/"),
session=async_create_clientsession(self.hass),
)
await client.async_get_heartbeat()
Expand Down Expand Up @@ -132,12 +128,8 @@ async def async_step_init(
return self.async_create_entry(title="Ollama Conversation", data=user_input)

try:
# Cannot use cv.url validation in the schema itself, so
# apply extra validation here.
cv.url_no_path(self.config_entry.data[CONF_BASE_URL])

client = OllamaApiClient(
base_url=self.config_entry.data[CONF_BASE_URL],
base_url=cv.url_no_path(self.config_entry.data[CONF_BASE_URL]).rstrip("/"),
session=async_create_clientsession(self.hass),
)
response = await client.async_get_models()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ollama_conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"integration_type": "service",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/ej52/hass-ollama-conversatio/issues",
"version": "0.1.4"
"version": "0.1.5"
}

0 comments on commit 848a69b

Please sign in to comment.