-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use of LiteLLM Router for load balancing and fallbacks #1570
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
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 |
@okhat any updates on this? Currently we are using litellm proxy in our product as a workaround while we wait on this. Any update on this would be appreciated as launching proxy server along with out service to communicate with the llms has become a bit of a bottleneck in our use case. |
any updates on this? this is definitely a useful feature. I think we can simplify the API even more and not even mention litellm or routing, to the user. I propose we add another argument to the for example: dspy.LM(
model='anthropic/claude-3-opus-20240229',
api_key='YOUR_ANTHROPIC_API_KEY',
fallback_models = [
{
# we can even make this name optional
'name': 'fallback 1',
'params': {
'model': 'anthropic/claude-3-opus-20240229',
'api_base': 'https://api.anthropic.com',
'api_key': 'YOUR_ANTHROPIC_API_KEY',
'temperature': 0.1,
}
},
{
'name': 'fallback 2',
'params': {
'model': "vertex_ai/claude-3-haiku@20240307",
'vertex_ai_project': vertex_ai_project,
'vertex_ai_location': vertex_ai_location,
'temperature': 1.0,
}
}]
) everything from |
Yes this would be a very useful feature, as google models tend to return errors rather frequently so fallback / routing /load balancing is an important aspect for moving it to production. I think we can simply support passing a liteLLM object like a router into |
PR opened: #8268 |
Uh oh!
There was an error while loading. Please reload this page.
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: