Use clientsession instead of httpx

This commit is contained in:
Nexus 2024-04-14 18:40:53 +01:00
parent ec89cc95b9
commit 38bc54d37f
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -193,8 +193,8 @@ class OllamaClient:
def with_client(
self,
timeout: httpx.Timeout | float | int | None = None
) -> httpx.AsyncClient:
timeout: aiohttp.ClientTimeout | float | int | None = None
) -> aiohttp.ClientSession:
"""
Creates an instance for a request, with properly populated values.
:param timeout:
@ -202,11 +202,11 @@ class OllamaClient:
"""
if isinstance(timeout, (float, int)):
if timeout == -1:
timeout = None
timeout = httpx.Timeout(timeout)
timeout = 10800
timeout = aiohttp.ClientTimeout(timeout)
else:
timeout = timeout or httpx.Timeout(60)
return httpx.AsyncClient(base_url=self.base_url, timeout=timeout, auth=self.authorisation)
return aiohttp.ClientSession(self.base_url, timeout=timeout, auth=self.authorisation)
async def get_tags(self) -> dict[typing.Literal["models"], dict[str, str, int, dict[str, str, None]]]:
"""