Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for proxy servers #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caramdache
Copy link

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

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```
@areibman
Copy link
Contributor

@caramdache Just saw this--- can you clarify what you mean and/or raise a PR? Seems like a simple fix?

@caramdache
Copy link
Author

It's not such a good idea to have imports that make HTTP calls, as it may be slow or even timeout. Or you could even be behind a proxy server. You need to at least let the http library access the environnement to get the address of the proxy server. Hence the patch. Without it the import will stall for a few minutes before timing out and failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants