mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
Add support for fallback models
This commit is contained in:
@ -203,8 +203,10 @@ async def retry_with_fallback_models(f: Callable):
|
|||||||
if not isinstance(fallback_models, list):
|
if not isinstance(fallback_models, list):
|
||||||
fallback_models = [fallback_models]
|
fallback_models = [fallback_models]
|
||||||
all_models = [model] + fallback_models
|
all_models = [model] + fallback_models
|
||||||
for model in all_models:
|
for i, model in enumerate(all_models):
|
||||||
try:
|
try:
|
||||||
return await f(model)
|
return await f(model)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f"Failed to generate prediction with {model}: {e}")
|
logging.warning(f"Failed to generate prediction with {model}: {e}")
|
||||||
|
if i == len(all_models) - 1: # If it's the last iteration
|
||||||
|
raise # Re-raise the last exception
|
||||||
|
Reference in New Issue
Block a user