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

Align request_timeout Behavior in Async and Non-Async APIs #387

Closed
wants to merge 1 commit into from

Conversation

zzh1996
Copy link

@zzh1996 zzh1996 commented Apr 9, 2023

In the non-Async API, the requests library is employed. Per the requests library documentation, the timeout accepts either a single float value (representing both connect and read timeouts) or a tuple (specifying connect and read timeouts separately).

Conversely, in the Async API, a single float for request_timeout represents the total timeout (as documented here). When given as a tuple, it corresponds to the connect and total timeouts. This inconsistency exists between the Async and non-Async APIs.

Prior to this pull request, the Async API lacked the ability to set a read timeout as in the non-Async API. This limitation was problematic because:

  • A large total timeout value (e.g., 5 minutes) would force users to wait the entire time despite potentially not receiving new messages after the first 5 seconds (a very common issue in the GPT-4 API).
  • A small total timeout value (e.g., 15 seconds) might be inadequate for the server to generate a substantial response.

This issue can be remedied by setting the read timeout (i.e., the number of seconds the client waits between bytes received from the server) to a reasonable value like 15 seconds.

zzh1996 added a commit to zzh1996/chatgpt-telegram-bot that referenced this pull request Apr 27, 2023
@ShantanuNair
Copy link

@zzh1996 This would be great.

@ShantanuNair
Copy link

@jhallard What do you think about this?

@ShantanuNair
Copy link

@zzh1996 Apparently fixed in the v1.0.0 beta: #631 (comment)

@RobertCraigie RobertCraigie added the fixed in v1 Issues addressed by the v1 beta label Oct 6, 2023
@rattrayalex rattrayalex closed this Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in v1 Issues addressed by the v1 beta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants