An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
I was able to run the request successfully using the code below, without any errors. However, the model’s responses still differ from the outputs I see in the Azure AI Playground when using the same prompt and data source.
from openai import AzureOpenAI
# Get an Azure OpenAI chat client
chat_client = AzureOpenAI(
api_version = "2024-12-01-preview",
azure_endpoint = "",
api_key = ""
)
# Initialize prompt with system message
prompt = [
{"role": "system", "content": "You are a helpful AI assistant."}
]
# Add a user input message to the prompt
input_text = input("Enter a question: ")
prompt.append({"role": "user", "content": input_text})
# Additional parameters to apply RAG pattern using the AI Search index
rag_params = {
"data_sources": [
{
"type": "azure_search",
"parameters": {
"endpoint": "",
"index_name": "",
"authentication": {
"type": "api_key",
"key": "",
}
}
}
],
}
# Submit the prompt with the index information
response = chat_client.chat.completions.create(
model="",
messages=prompt,
extra_body=rag_params
)
# Print the contextualized response
completion = response.choices[0].message.content
print(completion)
Is there any additional parameter or configuration required in the Python API to replicate the exact behavior of the Playground (e.g., strictness, document retrieval settings, or “limit responses to your data content”)?