Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Labels
kernel Issues or pull requests impacting the core kernel python Pull requests for the Python Semantic Kernel

Comments

@bhanu2507
Copy link

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 file

api_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("""

  1. A robot may not injure a human being or, through inaction,
    allow a human being to come to harm.

  2. A robot must obey orders given it by human beings except where
    such orders would conflict with the First Law.

  3. 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):

  • OS: Mac
  • IDE: Vscode
  • Python: 3.11

Additional context
Add any other context about the problem here.

@craigomatic craigomatic added the python Pull requests for the Python Semantic Kernel label Jun 23, 2023
@Sailesh-2209
Copy link
Contributor

Sailesh-2209 commented Jun 24, 2023

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.

@evchaki evchaki added the kernel Issues or pull requests impacting the core kernel label Jun 26, 2023
@bhanu2507
Copy link
Author

image

@Sailesh-2209
Copy link
Contributor

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.

@bhanu2507
Copy link
Author

No the issue was running the code on a Mac. I resolved it by running below command on my mac.

bash /Applications/Python*/Install\ Certificates.command

Thank you!!

@github-project-automation github-project-automation bot moved this to Sprint: Done in Semantic Kernel Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel python Pull requests for the Python Semantic Kernel
Projects
Archived in project
Development

No branches or pull requests

4 participants