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

Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')). #11767

Closed
2 of 14 tasks
mahsirat-atiye opened this issue Oct 13, 2023 · 2 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: embeddings Related to text embedding models module

Comments

@mahsirat-atiye
Copy link

System Info

llm = ChatOpenAI(model_name="gpt-4", temperature=0.5, request_timeout=300)

qa_chain = ConversationalRetrievalChain.from_llm(
verbose=True,
llm=llm,
retriever=retriever,
return_source_documents=True,
combine_docs_chain_kwargs={"prompt": prompt},
rephrase_question=False,
)

given code I get error:
Retrying langchain.embeddings.openai.embed_with_retry.._embed_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

llm = ChatOpenAI(model_name="gpt-4", temperature=0.5, request_timeout=300)

qa_chain = ConversationalRetrievalChain.from_llm(
verbose=True,
llm=llm,
retriever=retriever,
return_source_documents=True,
combine_docs_chain_kwargs={"prompt": prompt},
rephrase_question=False,
)

Expected behavior

successfully call OpenAI embedding api

@dosubot dosubot bot added Ɑ: embeddings Related to text embedding models module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Oct 13, 2023
@dosubot
Copy link

dosubot bot commented Oct 13, 2023

🤖

Hello,

The error message you're encountering indicates that the connection to the OpenAI server was abruptly closed by the server itself without sending any response back. This could be due to several reasons such as network issues, server issues at OpenAI, or issues with the request you're sending.

The LangChain framework has implemented retry logic for several types of exceptions, including openai.error.APIConnectionError, which is the type of error you're experiencing. This means that if an APIConnectionError occurs, the framework will automatically retry the request up to a maximum number of times specified by llm.max_retries. However, if the error persists even after all retry attempts, it means that the issue is likely not transient and needs to be investigated further.

Here are a few steps you can take to troubleshoot this issue:

  1. Check your network connectivity: Ensure that your server has a stable internet connection and is able to reach the OpenAI server.

  2. Verify your OpenAI API keys and endpoint URLs: The LangChain framework retrieves the OpenAI API key, base URL, API type, proxy, API version, and organization from either the provided values or the environment variables. If any of these values are incorrect, it could cause the request to fail.

  3. Contact OpenAI support: If you've checked your network connectivity and verified your API keys and endpoint URLs, and the issue still persists, you might need to contact OpenAI support for assistance.

In the past, similar issues have been resolved in the LangChain repository. For instance, Issue #8462 was resolved by a fix in Pull Request #8659. Users experiencing the original error were advised to test on version v0.0.252 or later. Since you're using version 0.0.313, this fix should already be included in your version.

I hope this helps! If you have any further questions or if the issue persists, please provide more details so we can assist you better.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Copy link

dosubot bot commented Feb 4, 2024

Hi, @mahsirat-atiye,

I'm helping the LangChain team manage their backlog and am marking this issue as stale. From what I understand, you encountered an error when calling the OpenAI embedding API, resulting in a "Connection aborted" message. You attempted to modify your scripts but did not receive a response for help. I provided troubleshooting steps, including checking network connectivity, verifying OpenAI API keys and endpoint URLs, and contacting OpenAI support if the issue persists. Additionally, I referenced a resolved similar issue in the LangChain repository and advised testing on a specific version.

Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 4, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature Ɑ: embeddings Related to text embedding models module
Projects
None yet
Development

No branches or pull requests

1 participant