Fast model falls back to regular (#4375)

This commit is contained in:
David Katz
2025-08-28 10:56:16 -04:00
committed by GitHub
parent 861c6890bf
commit 7879445c4b
+20 -1
View File
@@ -348,8 +348,27 @@ pub trait Provider: Send + Sync {
) -> Result<(Message, ProviderUsage), ProviderError> {
let model_config = self.get_model_config();
let fast_config = model_config.use_fast_model();
self.complete_with_model(&fast_config, system, messages, tools)
match self
.complete_with_model(&fast_config, system, messages, tools)
.await
{
Ok(result) => Ok(result),
Err(e) => {
if fast_config.model_name != model_config.model_name {
tracing::warn!(
"Fast model {} failed with error: {}. Falling back to regular model {}",
fast_config.model_name,
e,
model_config.model_name
);
self.complete_with_model(&model_config, system, messages, tools)
.await
} else {
Err(e)
}
}
}
}
/// Get the model config from the provider