Fix ollama blocking on load_default_certs (#125012)
* Fix ollama blocking on load_default_certs * Use get_default_context instead of client_context
This commit is contained in:
parent
56667ec2bc
commit
ef8fc3913e
2 changed files with 6 additions and 2 deletions
|
@ -13,6 +13,7 @@ from homeassistant.const import CONF_URL, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
from homeassistant.util.ssl import get_default_context
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_KEEP_ALIVE,
|
CONF_KEEP_ALIVE,
|
||||||
|
@ -43,7 +44,7 @@ PLATFORMS = (Platform.CONVERSATION,)
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Ollama from a config entry."""
|
"""Set up Ollama from a config entry."""
|
||||||
settings = {**entry.data, **entry.options}
|
settings = {**entry.data, **entry.options}
|
||||||
client = ollama.AsyncClient(host=settings[CONF_URL])
|
client = ollama.AsyncClient(host=settings[CONF_URL], verify=get_default_context())
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(DEFAULT_TIMEOUT):
|
async with asyncio.timeout(DEFAULT_TIMEOUT):
|
||||||
await client.list()
|
await client.list()
|
||||||
|
|
|
@ -33,6 +33,7 @@ from homeassistant.helpers.selector import (
|
||||||
TextSelectorConfig,
|
TextSelectorConfig,
|
||||||
TextSelectorType,
|
TextSelectorType,
|
||||||
)
|
)
|
||||||
|
from homeassistant.util.ssl import get_default_context
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_KEEP_ALIVE,
|
CONF_KEEP_ALIVE,
|
||||||
|
@ -91,7 +92,9 @@ class OllamaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client = ollama.AsyncClient(host=self.url)
|
self.client = ollama.AsyncClient(
|
||||||
|
host=self.url, verify=get_default_context()
|
||||||
|
)
|
||||||
async with asyncio.timeout(DEFAULT_TIMEOUT):
|
async with asyncio.timeout(DEFAULT_TIMEOUT):
|
||||||
response = await self.client.list()
|
response = await self.client.list()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue