litellm icon indicating copy to clipboard operation
litellm copied to clipboard

completion call with `fallbacks` using Python SDK seems to be stuck in an infinite loop

Open achpalaman opened this issue 1 year ago • 1 comments

The below code snippet seems to result in an infinite loop of trying claude-3-5-sonnet-20241022, gpt-4o-2024-11-20, claude-3-5-sonnet-20241022, ...

Setting num_retries or max_fallbacks does not solve the issue.

from litellm import completion

resp = completion( model="claude-3-5-sonnet-20241022", messages=messages, api_key="wrong_api_key", fallbacks=[ { "model": "gpt-4o-2024-11-20", "api_key": "wrong_key_2", "organization": "some_org", } ] )

achpalaman avatar Dec 08 '24 04:12 achpalaman

Additionally, reading the code of completion_with_fallbacks:

if isinstance( model, dict ): # completion(model="gpt-4", fallbacks=[{"api_key": "", "api_base": ""}, {"api_key": "", "api_base": ""}]) kwargs["api_key"] = model.get("api_key", None) kwargs["api_base"] = model.get("api_base", None) model = model.get("model", original_model)

It looks like we are missing extracting organization and api_version. Does this mean falling back from claude -> openai (which requires organization) or from openai -> azure is not possible?

achpalaman avatar Dec 08 '24 05:12 achpalaman

@ishaan-jaff Any update on this bug?

achpalaman avatar Dec 30 '24 09:12 achpalaman

fixed here @achpalaman https://github.com/BerriAI/litellm/pull/7751

ishaan-jaff avatar Jan 14 '25 01:01 ishaan-jaff