-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use of LiteLLM Router for load balancing and fallbacks #1570
Comments
Thanks! Maybe just launch their server and connect to it via the client dspy.LM? i.e., DSPy doesn't need to be invovled |
Thank you, Omar! I think it makes sense to expose router of LiteLLM as well. Under some circumstances, one would not want to run a separate proxy server and prefer using the LiteLLM Router for fallbacks, load balancing, and request prioritization |
@denisergashbaev Sorry, I'm mistaken about the nature of the LiteLLM router. I assumed it was inherently a proxy. It's actually just a client-side thing, indeed: https://docs.litellm.ai/docs/routing |
Yes, I think we should support this. It seems like we should inherit dspy.LM and just accept a list of |
Down to work on this if needed. @okhat maybe another function in dspy.LM similar to litellm_completion? Can also do a router kwarg to pass in a litellm.Router object. |
@zhaohan-dong Thanks a lot! How do you envision the interface looking like? Let's agree on the right API before doing anything intensive :D |
Exactly what I hoped to ascertain I think litellm tries to have similar signature for Router as the plain generation methods. So I'm thinking it could be progressively do dependency injection as first step:
Otherwise could inherit LM with Happy to proceed either way or do something else you'd suggest. Fundamentally I see the plain |
Thanks a lot @zhaohan-dong ! I like the idea of a class that inherits from dspy.LM |
Awesome! Maybe RoutedLM as name? |
Thanks for the response and your willingness to help. Let me know if I could help as well. |
@denisergashbaev I tried a PR here: #1611. Dunno if you could collab? |
Hi! Checking in on this, I would love to leverage this if someone has on a branch somewhere. Would be happy to write some integration tests so that it can be merged eventually. |
@ryanh-ai Have a branch here https://github.com/zhaohan-dong/dspy/tree/litellm-router |
As DSPy is using LiteLLM internally, I wonder how to use the LiteLLM router. In particular, I would like to add load balancing and fallbacks via LiteLLM.
Another example. LiteLLM provides rate limit aware routing strategy that routes the call to the deployment with the lowest tokens per minute value (see BerriAI/litellm#4510, https://docs.litellm.ai/docs/routing#advanced---routing-strategies-%EF%B8%8F). I would want to use the router
Thank you
The text was updated successfully, but these errors were encountered: