top | item 41117730

(no title)

Crier1002 | 1 year ago

I use https://github.com/litl/backoff for configurable backoff + retry

context: OpenAI API used to be super flaky back in the early days, i needed to retry my requests quite frequently and i found this

discuss

order

networked|1 year ago

Backoff doesn't look bad.

I have used two libraries for retrying in Python: retry (https://github.com/invl/retry) and Tenacity (https://github.com/jd/tenacity). Tenacity actually helped me with a recent GPT-4o mini experiment, when OpenRouter gave me an error after a couple hundred requests. I can recommend Tenacity. A downside is that the API is fairly complex and verbose. You will probably look it up each time if you don't use it often (or rely on an IDE or LLM).

Backoff seems somewhat less flexible than Tenacity (https://github.com/litl/backoff/issues/125) but more concise. Basic use requires as little code as retry and should be easy to remember.

ddorian43|1 year ago

"stamina" is a wrapper for tenacity with nice defaults