From a40c59b5b49baf963a89f6bb6343fb7a7a7e461a Mon Sep 17 00:00:00 2001 From: vocode-petern Date: Fri, 20 Sep 2024 09:14:32 -0700 Subject: [PATCH] Support passing in custom connector for AsyncRequestor (#706) --- vocode/streaming/utils/async_requester.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vocode/streaming/utils/async_requester.py b/vocode/streaming/utils/async_requester.py index 5b23875cca..d3577f5909 100644 --- a/vocode/streaming/utils/async_requester.py +++ b/vocode/streaming/utils/async_requester.py @@ -1,17 +1,22 @@ +from typing import Optional + import aiohttp import httpx +from aiohttp import BaseConnector +from pydantic import BaseModel from vocode.streaming.utils.singleton import Singleton class AsyncRequestor(Singleton): - def __init__(self): - self.session = aiohttp.ClientSession() + def __init__(self, connector: Optional[BaseConnector] = None): + self.session = aiohttp.ClientSession(connector=connector) self.async_client = httpx.AsyncClient() + self.connector = connector def get_session(self): if self.session.closed: - self.session = aiohttp.ClientSession() + self.session = aiohttp.ClientSession(connector=self.connector) return self.session def get_client(self):