3

when my project run this code it will return openai.error.APIConnectionError: Error communicating with OpenAI

async def embeddings_acreate(input: list[str]):
    
    return await openai.Embedding.acreate(
        api_key=await get_openai_api_key(),
        model='text-embedding-ada-002',
        input=input,
        timeout=60,
    )

but if I tried:

import openai
import logging


openai.api_key = 'secret'

input_list = [
    "tell me your name"
]

response = openai.Embedding.create(
    model="text-embedding-ada-002",
    input=input_list
)

embeddings = response["data"]
print(embeddings)

it worked......

I hope to use async and make it

Leon YAo
  • 31
  • 1
  • 3

2 Answers2

4

Faced the same issue. Apparently it is a mac specific issue which is discussed here: https://github.com/microsoft/semantic-kernel/issues/627

Basically you have to run the following command

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

Or just double click Certificates.command file in /Applications/Python/* folder on your mac. Hope this helps.

Rahul Sankrutyan
  • 73
  • 1
  • 2
  • 10
0

Faced the same issue.

My situation:

  • windows
  • intranet with proxy

try to:

  • setting\env add 「OPENAI_PROXY:http://user:password@proxy server ip:port」
  • restart system(important!!!)
Nick Kao
  • 65
  • 8