-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Feature]: Support retry policies when calling completion() / text_completion() without requiring Router #6623
Comments
Hi @krrishdholakia, can you advise regarding how to support configuring retry policies without cc @okhat |
@ishaan-jaff do we still need openai/azure client init on router? iirc you implemented some sort of client caching logic on the .completion call already, right? |
i wonder how hard it would be to just move the async_function_with_retries outside the router, and use that inside the wrapper_async / wrapper functions |
Nope, we don't it's probably better to have this on completion level |
Hi @krrishdholakia @ishaan-jaff , thank you so much for the ideation here! What's best regarding next steps for getting this implemented? |
@krrishdholakia @ishaan-jaff I gave this a try based on your suggestion. Let me know how it looks - #6916. Happy to split this up for reviewability / adjust course as needed. |
The Feature
Support retry policies when calling completion() / text_completion() without requiring Router. Example:
Motivation, pitch
The DSPy library (https://github.com/stanfordnlp/dspy) depends on LiteLLM for issuing LLM calls. When these calls fail due to transient network errors or rate limiting, we want to retry with exponential backoff. However, when these calls fail due to user error (e.g. bad API keys, malformed requests), we want to fail fast.
DSPy users configure LLM keys and parameters using constructor arguments to the
dspy.LM
class (and optionally be setting environment variables like `OPENAI_API_KEY'), for example:DSPy currently wraps
litellm.completion()
andlitellm.text_completion()
to implement this interface. See https://github.com/stanfordnlp/dspy/blob/8bc3439052eb80ba4e5ba340c348a6e3b2c94d7c/dspy/clients/lm.py#L78-L87 / https://github.com/stanfordnlp/dspy/blob/8bc3439052eb80ba4e5ba340c348a6e3b2c94d7c/dspy/clients/lm.py#L166-L216. Currently, these interfaces don't support specifying a retry policy.We've attempted to work around this by constructing a
Router
internally, but Router construction requires us to fetch the api key and base and pass them to amodel_list
(due to OpenAI / Azure OpenAI initialization -litellm/litellm/router.py
Lines 3999 to 4001 in 45ff74a
Twitter / LinkedIn details
No response
The text was updated successfully, but these errors were encountered: