fully use aiohttp session

This commit is contained in:
Nexus 2024-04-14 18:45:48 +01:00
parent 3a3804fc18
commit a2b2ad6f9d
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -102,7 +102,7 @@ class OllamaDownloadHandler:
self.status = line["status"]
async def __aiter__(self):
async with httpx.AsyncClient(base_url=self.base_url) as client:
async with aiohttp.ClientSession(base_url=self.base_url) as client:
async with client.post("/api/pull", json={"name": self.model, "stream": True}, timeout=None) as response:
response.raise_for_status()
async for line in ollama_stream(response.content):
@ -164,7 +164,7 @@ class OllamaChatHandler:
self._abort.set()
async def __aiter__(self):
async with httpx.AsyncClient(base_url=self.base_url) as client:
async with aiohttp.ClientSession(base_url=self.base_url) as client:
async with client.post(
"/api/chat",
json={