Sample Code: OpenAI service failed to complete the prompt, APIConnectionError issue with Python 3.10
See original GitHub issueDescribe the bug Unable to run the sample code here: https://github.com/microsoft/semantic-kernel/blob/main/python/README.md
To Reproduce Steps to reproduce the behavior:
- Create new virtual environment
python -m venv venv
python -m pip install --upgrade semantic-kernel
- Create a
.env
file following these instructions: https://github.com/microsoft/semantic-kernel/blob/main/python/README.md#openai--azure-openai-api-keys - Copy this code - https://github.com/microsoft/semantic-kernel/blob/main/python/README.md#running-a-prompt into a file named main.py
- Error:
Error: (<ErrorCodes.ServiceError: 6>, 'OpenAI service failed to complete the prompt', APIConnectionError(message='Error communicating with OpenAI', http_status=None, request_id=None))
Expected behavior
Expected to see output like Robots must not harm humans.
Desktop (please complete the following information):
- OS: Mac 12.6.1
- IDE: VS Code
- openai == 0.27.4
- semantic-kernel == 0.2.4.dev0
- numpy == 1.24.3
- python == 3.10.8
Additional context
Full error: Error: (<ErrorCodes.ServiceError: 6>, 'OpenAI service failed to complete the prompt', APIConnectionError(message='Error communicating with OpenAI', http_status=None, request_id=None))
No VPN enabled. New virtual environment. Tried with my personal account as well as my company account. Both had same result. Tried on a VPN, no luck.
Edit:
I was able to run the sample in an AWS ec2 instance with python 3.9. I then tested on my machine with a python:3.9 docker container which also worked. This appears to be an issue with python 3.10.
Issue Analytics
- State:
- Created 5 months ago
- Comments:22 (5 by maintainers)
Top GitHub Comments
I think I’ve run into the same SSL certificate something error on
macOS
.And found this solution on SO:
After restarting the Jupyter notebook kernel, things worked.
I got the same problem. I traced the error and found that it was not able to verify the local issuer certificate.
Cannot connect to host xxxxxx.openai.azure.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]
So I added a config setting in the source code(openai/api_requestor.py line 586): This will ignore the verification of SSL certificate, and this fixed my problem.