Skip to content

Commit

Permalink
fix:add proxy parameter when httpx >= 0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-ckt committed Dec 11, 2024
1 parent 3cd8bea commit 1db7559
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dbgpt/model/utils/chatgpt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class OpenAIParameters:
api_azure_deployment: Optional[str] = None
full_url: Optional[str] = None
proxies: Optional["ProxiesTypes"] = None
proxy: Optional["ProxyTypes"] = None


def _initialize_openai_v1(init_params: OpenAIParameters):
Expand Down Expand Up @@ -155,9 +156,14 @@ def _build_openai_client(init_params: OpenAIParameters) -> Tuple[str, ClientType
# Remove proxies for httpx AsyncClient when httpx version >= 0.28.0
httpx_version = metadata.version("httpx")
if httpx_version >= "0.28.0":
http_client = httpx.AsyncClient()
else:
if init_params.proxy:
http_client = httpx.AsyncClient(proxy=init_params.proxy)
else:
http_client = httpx.AsyncClient()
elif init_params.proxies:
http_client = httpx.AsyncClient(proxies=init_params.proxies)
else:
http_client = httpx.AsyncClient()
async_client.http_client = http_client
return api_type, async_client

Expand Down

0 comments on commit 1db7559

Please sign in to comment.