dspy icon indicating copy to clipboard operation
dspy copied to clipboard

Implement Exponential Backoff for ThrottlingException in InvokeModel Calls

Open aazizisoufiane opened this issue 4 months ago • 2 comments

Issue: Encountering botocore.errorfactory.ThrottlingException when using invoke_model due to rate limits. AWS recommends exponential backoff for API retries.

Current Function: def _call_model(self, body: str) -> str: return self.predictor.invoke_model(modelId=self._model_name, body=body, accept="application/json", contentType="application/json")

Question: Would a PR implementing exponential backoff with the backoff library for this operation be welcome? Keen to contribute a solution to improve request reliability.

aazizisoufiane avatar Apr 04 '24 09:04 aazizisoufiane

Hi @aazizisoufiane , a PR would definitely be welcome! Just curious though, which AWS model were you using for this? I'm assuming Anthropic since I only see that AWS LM configured with backoff but I know @drawal1 is working on a AWS LM refactor in #795 so feel free to check out if it's handled there or if it needs to be added.

arnavsinghvi11 avatar Apr 09 '24 22:04 arnavsinghvi11

@arnavsinghvi11 PR #795 does not implement any special code for exponential backoff so it would be welcome. @aazizisoufiane can implement once PR #795 is merged.

just noticed there is a dsp/modules/aws_lm.py file that will also be obsolete after PR #795. Deleting it so there's no confusion...

drawal1 avatar Apr 10 '24 01:04 drawal1