Skip to content

Commit

Permalink
Support passing in custom connector for AsyncRequestor (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
vocode-petern authored Sep 20, 2024
1 parent dc983a0 commit a40c59b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vocode/streaming/utils/async_requester.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit a40c59b

Please sign in to comment.