diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index 9a328f386..e8023b717 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -9,7 +9,6 @@ import json import time from typing import NamedTuple, Union -import httpx from openai import ( APIConnectionError, AsyncAzureOpenAI, @@ -18,6 +17,7 @@ from openai import ( AzureOpenAI, OpenAI, ) +from openai._base_client import AsyncHttpxClientWrapper, SyncHttpxClientWrapper from openai.types import CompletionUsage from openai.types.chat import ChatCompletion, ChatCompletionChunk from tenacity import ( @@ -190,8 +190,8 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter): # to use proxy, openai v1 needs http_client proxy_params = self._get_proxy_params() if proxy_params: - kwargs["http_client"] = httpx.Client(**proxy_params) - async_kwargs["http_client"] = httpx.AsyncClient(**proxy_params) + kwargs["http_client"] = SyncHttpxClientWrapper(**proxy_params) + async_kwargs["http_client"] = AsyncHttpxClientWrapper(**proxy_params) return kwargs, async_kwargs diff --git a/requirements.txt b/requirements.txt index c57fb6c2c..fd7a31607 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ langchain==0.0.231 loguru==0.6.0 meilisearch==0.21.0 numpy==1.24.3 -openai~=1.3 +openai==1.6.0 openpyxl beautifulsoup4==4.12.2 pandas==2.0.3