Commit 47ce2954

Bojie Li <bojieli@gmail.com>
2023-03-30 13:11:40
set openai.proxy explicitly to Requests lib to override environmental defaults (#339)
By default, the Requests library use the proxy settings from the environment variable HTTPS_PROXY. It has higher priority than the "proxies" setting in the session, which may lead to confusing behaviors if both environment variables and the "openai.proxy" config are set. This patch explicitly informs the Requests library to use the "openai.proxy" config.
1 parent 15c6aeb
Changed files (1)
openai/api_requestor.py
@@ -521,6 +521,7 @@ class APIRequestor:
                 files=files,
                 stream=stream,
                 timeout=request_timeout if request_timeout else TIMEOUT_SECS,
+                proxies=_thread_context.session.proxies,
             )
         except requests.exceptions.Timeout as e:
             raise error.Timeout("Request timed out: {}".format(e)) from e