Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
When accessing to Azure Open AI Service with openai==1.61 from Microsoft Fabric notebook, I get the error below.
ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
APIConnectionError: Connection error.
You can reproduce the issue with the code below.
%pip install -U openai
from pyspark.sql import Row
from synapse.ml.services.openai import OpenAIChatCompletion
from openai import AzureOpenAI
def get_response(question):
prompt = f"""
Please answer the questions based on the following information.
"""
messages = [{'role': 'system', 'content': prompt}, {'role': 'user', 'content': question}]
aoai_client = AzureOpenAI(
api_key = "<api_key>",
api_version = "2024-02-01",
azure_endpoint = "https://<azure_open_ai_service>.openai.azure.com/"
)
result = aoai_client.chat.completions.create(messages=messages, model="gpt-4o-mini").choices[0].message.content
return result
question = "Please tell me how to reserve the restaurant."
response = get_response(question)
print(response)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.