openai.error.InvalidRequestError: Unrecognized request argument supplied: dataSources
I am trying to replicate the the add your own data feature for Azure Open AI following the instruction found here: Quickstart: Chat with Azure OpenAI models using your own data
import os
import openai
import dotenv
dotenv.load_dotenv()
endpoint = os.environ.get("AOAIEndpoint")
api_key = os.environ.get("AOAIKey")
deployment = "gpt-4-32k"
client = openai.AzureOpenAI(
# base_url=f"{endpoint}/openai/deployments/{deployment}/extensions",
azure_endpoint=endpoint,
api_key=api_key,
api_version="2023-08-01-preview",
)
completion = client.chat.completions.create(
model=deployment,
messages=[
{
"role": "user",
"content": "My user query",
},
],
extra_body={
"dataSources": [
{
"type": "AzureCognitiveSearch",
"parameters": {
"endpoint": os.environ["SearchEndpoint"],
"key": os.environ["SearchKey"],
"indexName": os.environ["SearchIndex"]
}
}
]
}
)
print(f"{completion.choices[0].message.role}: {completion.choices[0].message.content}")
However, I was not able to use the 'dataSources' parameter in the API call. I would get the following error: BadRequestError: Error code: 400 - {'error': {'message': 'Unrecognized request argument supplied: dataSources', 'type': 'invalid_request_error', 'param': None, 'code': None}}.
If I were to use the base_url
like the example, I would get an error: InternalServerError: upstream request timeout.
Running the code with without the extra_body parameter would work just fine.
I am currently using the newest openai
python library. I have also tried the example with openai==0.28.1
and I got the error: InvalidRequestError: Unrecognized request argument supplied: dataSources
I have look into the official github for OpenAI Python API library and it is not clear how I should implement the add your own data feature.