From b187384cdc0211c3004c3c4b6e1a2848eb5770bc Mon Sep 17 00:00:00 2001 From: caramdache Date: Mon, 26 Aug 2024 16:23:39 +0200 Subject: [PATCH] Add support for proxy servers Add `trust_env=True` so that AIOHTTP will use the proxy server defined in the environment, if any. If this is not done, the following import will result in a (long) timeout: ```from tokencost import calculate_prompt_cost, calculate_completion_cost``` --- tokencost/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokencost/constants.py b/tokencost/constants.py index bc59234..e69c770 100644 --- a/tokencost/constants.py +++ b/tokencost/constants.py @@ -34,7 +34,7 @@ async def fetch_costs(): Raises: Exception: If the request fails. """ - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: async with session.get(PRICES_URL) as response: if response.status == 200: return await response.json(content_type=None)