![]() I believe what you are doing is a little “hacky” - you’re changing a constant instead of having the library manage it for you. I didn’t intend to say that client-side timeouts are useless, I’ll try and be more clear in the future. I would still rather my own client-side library to handle and retry the request though, but it’s nice to have. That, and the codex are two things I didn’t know. Min(timeout + start - time.time(), MAX_TIMEOUT) Which is eventually added back into the request response, _, api_key = requestor.request( If timeout is not None and time.time() > start + timeout: They also use the (I believe same) timeout parameter in other sections while True: So the value that you are changing is the direct variable they use with this timeout parameter. They use aiohttp so the timeout mechanism can be found here: While it seems simple, sometimes this somewhat vague error message can make even advanced Python developers scratching their head for a few good hours. I just thought it was important to clarify for the OP and future readers that 1) it does make sense to have a working timeout argument in a client-side api library, and 2) it’s fine/reasonable to try using Codex for translation, there is evidence that it out-performs text-davinci-xxx on many NLP tasks. One of the most popular error messages that new developers encounter when using requests library in Python is the Max retries exceeded with URL (besides timeout errors ). (read - my last comment may have been a little too abrasive. I get a Traceback ending with Timeout: Request timed out: HTTPSConnectionPool(host='', port=443): Read timed out. Openai.api_requestor.TIMEOUT_SECS = 1 # set to 1 second just for demo, probably need it to be longerĬompletion = ( Openai.api_key = OPENAI_KEY # your api key It is absurdly long (10 minutes), but I don’t see any reason why you couldn’t shorten it. Open the given url (which can be a request object or a string), optionally passing the given data. The default client timeout in the openai library appears to be set here. OpenerDirector.open(url, dataNone, timeout) ¶. ![]() If a request exceeds the configured number of maximum redirections, a TooManyRedirects exception is raised. I don’t think that timeout argument actually makes its way into the calling function (which is a few layers of wrapping around urllib3). If a request times out, a Timeout exception is raised.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |