Need help: HTTPSConnectionPool(host='api.openai.com', port=443)

Hi all, I am learning to use langchain with openai API. But when I use the following code, I get the error response.

import datetime
current_date = datetime.datetime.now().date()
if current_date < datetime.date(2023, 9, 2):
    llm_name = "gpt-3.5-turbo-0301"
else:
    llm_name = "gpt-3.5-turbo"
print(llm_name)

from langchain.vectorstores import Chroma
from langchain.embeddings.openai import OpenAIEmbeddings
persist_directory = 'docs/chroma/'
embedding = OpenAIEmbeddings()
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)

question = "What are major topics for this class?"
docs = vectordb.similarity_search(question,k=3)
len(docs)

The error response:

Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/engines/text-embedding-ada-002/embeddings (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))).

You are getting an SSL error trying to reach OpenAI. You likely need to update openssl or your certificates, but I’m not familiar with that aspect of python. Might have better luck asking on LangChain site or googling python SSL errors.

Hi buddy, Is this problem solved? I met the similiar problem with you.

downgrade openai to 0.28.1 and urllib3 to 1.25.11。 it works.