Properly return a client in with_client

This commit is contained in:
Nexus 2024-04-14 18:34:04 +01:00
parent 3f894c493d
commit c219158c62
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -194,7 +194,7 @@ class OllamaClient:
def with_client( def with_client(
self, self,
timeout: httpx.Timeout | float | int | None = None timeout: httpx.Timeout | float | int | None = None
) -> contextlib.AbstractContextManager[httpx.AsyncClient]: ) -> httpx.AsyncClient:
""" """
Creates an instance for a request, with properly populated values. Creates an instance for a request, with properly populated values.
:param timeout: :param timeout:
@ -206,8 +206,7 @@ class OllamaClient:
timeout = httpx.Timeout(timeout) timeout = httpx.Timeout(timeout)
else: else:
timeout = timeout or httpx.Timeout(60) timeout = timeout or httpx.Timeout(60)
async with httpx.AsyncClient(base_url=self.base_url, timeout=timeout, auth=self.authorisation) as client: return httpx.AsyncClient(base_url=self.base_url, timeout=timeout, auth=self.authorisation)
yield client
async def get_tags(self) -> dict[typing.Literal["models"], dict[str, str, int, dict[str, str, None]]]: async def get_tags(self) -> dict[typing.Literal["models"], dict[str, str, int, dict[str, str, None]]]:
""" """