import os
import openai
openai.api_type = "azure"
openai.api_version = os.getenv("AZURE_OPENAI_API_VERSION","").strip()
API_KEY = os.getenv("AZURE_OPENAI_API_KEY","").strip()
assert API_KEY, "ERROR: Azure OpenAI Key is missing"
openai.api_key = API_KEY
RESOURCE_ENDPOINT = os.getenv("OPENAI_API_BASE","").strip()
assert RESOURCE_ENDPOINT, "ERROR: Azure OpenAI Endpoint is missing"
assert "openai.azure.com" in RESOURCE_ENDPOINT.lower(), "ERROR: Azure OpenAI Endpoint should be in the form: \n\n\t<your unique endpoint identifier>.openai.azure.com"
openai.api_base = RESOURCE_ENDPOINT
deployment = "gpt-35-turbo" # replace with your deployment name
# Create your first prompt
text_prompt = " My foot hurts, what can be wrong?"
response = openai.ChatCompletion.create(
engine=deployment,
messages = [
{"role":"system", "content":"I'm a doctor, specialist on surgery"},
{"role":"user","content":text_prompt},])
response['choices'][0]['message']['content']