Hi Mark Smith,
Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!
I understand that you are facing some issues with your Azure OpenAI integration. I wanted to provide some guidance to help you resolve this.
Here are some troubleshoot steps:
- Try Clear browser cache and cookies and also try using a different browser.
- Sometimes, the service may experience downtime, or other issues please retry once.
Here’s the updated code for your reference:
from openai import AzureOpenAI
def get_openai_response(user_prompt):
# Initialize Azure OpenAI client using environment variables
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT") # Your Azure OpenAI endpoint
api_key = os.getenv("AZURE_OPENAI_API_KEY") # Your Azure OpenAI API key
client = AzureOpenAI(
azure_endpoint=azure_endpoint,
api_key=api_key,
api_version="2024-02-01",
)
# Prepare the chat prompt
chat_prompt = [
{
"role": "system",
"content": "You are an AI assistant that helps people find information."
},
{
"role": "user",
"content": user_prompt # Use the user_prompt argument here
}
]
# Generate the completion
completion = client.chat.completions.create(
model="gpt-4", # Replace with your actual deployment name if different
messages=chat_prompt,
max_tokens=800,
temperature=0.7,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None,
stream=False
)
return completion.to_json()
# Example usage
response = get_openai_response("What is the capital of France?")
print(response)
Here is the screenshot of my results for your reference:
I believe this issue is not related to your quota; however, if you continue to experience difficulties, please feel free to reach out and will escalate the issue to the appropriate team to ensure it is resolved promptly.
I hope this information helps.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful.