-
Notifications
You must be signed in to change notification settings - Fork 15.7k
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
Issue: Request timeout #10443
Comments
🤖 Hello, Thank you for reaching out with your issue. Based on the error message you provided, it seems like the request to the OpenAI API is timing out. This could be due to a number of reasons such as network issues, the server being down, or the server taking too long to respond. Here are a few solutions that have worked for similar issues in the past:
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
session = requests.Session()
retry = Retry(total=5, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ])
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)
response = session.get(url) This will retry the request 5 times with a delay between retries that increases each time (0.1, 0.2, 0.4, 0.8, 1.6 seconds).
import openai
openai.proxy = {
"http": "http://127.0.0.1:7890",
"https": "http://127.0.0.1:7890"
}
TIMEOUT = 60 # <= timeout in seconds. default is 600 (set by OpenAI)
llm = OpenAI(temperature=0, openai_api_key=OPENAI_API_KEY, request_timeout=TIMEOUT) Please try these solutions and let me know if any of them work for you. If you continue to experience issues, please provide more details about your setup and the exact steps you're taking when you encounter the error. Best, 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. |
Hi, I see the same error in my project, but in my case it takes up to 10 minutes before I get the timeout error. It doesn't happen all the time, but I would like to know if it is possible that a hotfix could be made to fix this from Langchain or if it actually comes from OpenAI. According to our trace, the error is from a request through aiohttp. |
Hi, @Hamza091, I'm helping the LangChain team manage their backlog and am marking this issue as stale. The issue you reported is about a request timeout error that occurs after a period of inactivity and resolves itself when the server is restarted. Dosubot provided potential solutions, including checking the internet connection, increasing timeout, and using a proxy. GilbertGomez94 also reported a similar timeout error in their project and inquired about a potential hotfix from Langchain or if the issue originates from OpenAI. Jennylihan showed agreement with GilbertGomez94's comment. 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! |
Issue you'd like to raise.
I am getting following error after a period of inactivity, However, the issue resolves itself when I restart the server and run the same query.
Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600).
How can I fix this issue?
Suggestion:
No response
The text was updated successfully, but these errors were encountered: