You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: (<ErrorCodes.ServiceError: 6>, 'OpenAI service failed to complete the prompt', APIConnectionError(message='Error communicating with OpenAI', http_status=None, request_id=None))
#1692
Closed
bhanu2507 opened this issue
Jun 23, 2023
· 4 comments
Hi @bhanu2507 , please make sure that you have either an OpenAI or an Azure OpenAI key, and that you have enough credits to be able to run the prompt. Also note that you only need to use the kernel.add_text_completion_service call once depending on if you have an API key from OpenAI, or from Azure OpenAI service.
This seems like an error coming from the OpenAI API, and not an issue with semantic kernel. According to the Error Guide, if you encounter an APIConnectionError, please try the following steps:
Check your network settings and make sure you have a stable and fast internet connection. You may need to switch to a different network, use a wired connection, or reduce the number of devices or applications using your bandwidth.
Check your proxy configuration and make sure it is compatible with our services. You may need to update your proxy settings, use a different proxy, or bypass the proxy altogether.
Check your SSL certificates and make sure they are valid and up-to-date. You may need to install or renew your certificates, use a different certificate authority, or disable SSL verification.
Check your firewall rules and make sure they are not blocking or filtering our services. You may need to modify your firewall settings.
If appropriate, check that your container has the correct permissions to send and receive traffic.
Describe the bug
Getting the below on the executing simple OpenAI code.
import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import OpenAITextCompletion, AzureTextCompletion
kernel = sk.Kernel()
Prepare OpenAI service using credentials stored in the
.env
fileapi_key, org_id = sk.openai_settings_from_dot_env()
kernel.add_text_completion_service("dv", OpenAITextCompletion("text-davinci-003", api_key, org_id), True)
Alternative using Azure:
deployment, api_key, endpoint = sk.azure_openai_settings_from_dot_env()
kernel.add_text_completion_service("dv", AzureTextCompletion(deployment, endpoint, api_key))
Wrap your prompt in a function
prompt = kernel.create_semantic_function("""
A robot may not injure a human being or, through inaction,
allow a human being to come to harm.
A robot must obey orders given it by human beings except where
such orders would conflict with the First Law.
A robot must protect its own existence as long as such protection
does not conflict with the First or Second Law.
Give me the TLDR in exactly 5 words.""")
Run your prompt
print(prompt()) # => Robots must not harm humans.
Expected behavior
Supposed to print the text in comments in last line
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: