Hi,
I got it work based on this document
https://learn.microsoft.com/en-us/azure/ai-services/openai/use-your-data-quickstart?tabs=command-line&pivots=rest-api
deployment_id = 'deployment-gpt-3-5'
request.url = f"{openai.api_base}/openai/deployments/{deployment_id}/extensions/chat/completions?api-version={openai.api_version}"
#use the above URL in the setup_byod function
def setup_byod(deployment_id: str) -> None: ....
def completion(deployment_id: str, prompt_input: str):
completion = openai.ChatCompletion.create(
deployment_id=deployment_id,
dataSources=[
{ "type": "AzureCognitiveSearch",
"parameters": {
"endpoint": search_endpoint,
"key": search_key,
"indexName": search_index_name,
}
}
],
messages=[{"role": "user", "content": prompt_input}]
)
print(completion['choices'][0]['message']['content'])