Skip to content

Commit

Permalink
fix(cli): remove usage of httpx proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Dec 3, 2024
1 parent 534d6c5 commit 439ab56
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/openai/cli/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .. import _ApiType, __version__
from ._api import register_commands
from ._utils import can_use_http2
from .._types import ProxiesDict
from ._errors import CLIError, display_error
from .._compat import PYDANTIC_V2, ConfigDict, model_parse
from .._models import BaseModel
Expand Down Expand Up @@ -167,17 +166,17 @@ def _main() -> None:
if args.verbosity != 0:
sys.stderr.write("Warning: --verbosity isn't supported yet\n")

proxies: ProxiesDict = {}
proxies: dict[str, httpx.BaseTransport] = {}
if args.proxy is not None:
for proxy in args.proxy:
key = "https://" if proxy.startswith("https") else "http://"
if key in proxies:
raise CLIError(f"Multiple {key} proxies given - only the last one would be used")

proxies[key] = proxy
proxies[key] = httpx.HTTPTransport(proxy=httpx.Proxy(httpx.URL(proxy)))

http_client = httpx.Client(
proxies=proxies or None,
mounts=proxies or None,
http2=can_use_http2(),
)
openai.http_client = http_client
Expand Down

0 comments on commit 439ab56

Please sign in to comment.