Closed notedit closed 1 year ago
I got same error when i upgrade langchain = 0.0.158
openai.error.InvalidRequestError: Unsupported OpenAI-Version header provided: 2022-12-01.
(HINT: you can provide any of the following supported versions: 2020-10-01, 2020-11-07.
Alternatively, you can simply omit this header to use the default version associated with your account.)
I find a commit https://github.com/hwchase17/langchain/pull/3942/commits/e2e05235ddf60dafe949c523c9f5d42ff589d098 to add this line to langchain to support for Azure OpenAI Service custom endpoint
openai_api_version: str = "2022-12-01"
maybe, this is only support for Azure OpenAI Service.
I add version when i init OpenAIEmbeddings : OpenAIEmbeddings(openai_api_version='2020-11-07')
or, can set openai_api_version
in env.
I had the same problem when I deployed on streamlit, then I restricted langchain == 0.0.157
and added in the code
openai.api_version = '2020-11-07'
os.environ["OPENAI_API_VERSION"] = '2020-11-07'
But it doesn't solve the problem
Here is a temporary solution: placing openai.api_version = '2020-11-07'
just before openai.ChatCompletion.create
like this:
messages = [{"role": "user", "content": prompt}]
openai.api_version = '2020-11-07'
response = openai.ChatCompletion.create(
model=model,
messages=messages, # temperature=temperature, # this is the model,
temperature=temperature,
)
Hi, @notedit! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, the issue you reported is related to the OpenAIEmbeddings script throwing an error due to an unsupported OpenAI-Version header provided. Users have tried different solutions such as downgrading the langchain version or setting the openai_api_version in the code or environment variables, but these solutions did not solve the problem. However, a temporary solution suggested by a user is to place openai.api_version = '2020-11-07'
just before openai.ChatCompletion.create
in the code, which seems to have resolved the error caused by the unsupported OpenAI-Version header.
Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!
System Info
langchain-0.0.158 Python 3.11.2 macos
Who can help?
@hwchase17
Information
Related Components
Reproduction
Expected behavior
I got this error: