mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-02 03:15:11 +00:00
Fix openai proxy error (#5914)
Fixes proxy error.
Since openai does not parse proxy parameters and uses openai.proxy
directly, the proxy method needs to be modified.
7610c5adfa/openai/api_requestor.py (LL90)
#### Who can review?
@hwchase17 - project lead
Models
- @hwchase17
- @agola11
---------
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
parent
2791a753bf
commit
63fcf41bea
@ -387,9 +387,9 @@ class ChatOpenAI(BaseChatModel):
|
||||
"model": self.model_name,
|
||||
}
|
||||
if self.openai_proxy:
|
||||
openai_creds["proxy"] = (
|
||||
{"http": self.openai_proxy, "https": self.openai_proxy},
|
||||
)
|
||||
import openai
|
||||
|
||||
openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] # noqa: E501
|
||||
return {**openai_creds, **self._default_params}
|
||||
|
||||
@property
|
||||
|
@ -197,10 +197,12 @@ class OpenAIEmbeddings(BaseModel, Embeddings):
|
||||
"api_version": self.openai_api_version,
|
||||
}
|
||||
if self.openai_proxy:
|
||||
openai_args["proxy"] = {
|
||||
import openai
|
||||
|
||||
openai.proxy = {
|
||||
"http": self.openai_proxy,
|
||||
"https": self.openai_proxy,
|
||||
}
|
||||
} # type: ignore[assignment] # noqa: E501
|
||||
return openai_args
|
||||
|
||||
# please refer to
|
||||
|
@ -451,10 +451,9 @@ class BaseOpenAI(BaseLLM):
|
||||
"organization": self.openai_organization,
|
||||
}
|
||||
if self.openai_proxy:
|
||||
openai_creds["proxy"] = {
|
||||
"http": self.openai_proxy,
|
||||
"https": self.openai_proxy,
|
||||
}
|
||||
import openai
|
||||
|
||||
openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] # noqa: E501
|
||||
return {**openai_creds, **self._default_params}
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user