feat(providers): add retry for model fetching (#6347)
Signed-off-by: rabi <ramishra@redhat.com>
This commit is contained in:
@@ -15,7 +15,9 @@ use goose::providers::auto_detect::detect_provider_from_api_key;
|
||||
use goose::providers::base::{ProviderMetadata, ProviderType};
|
||||
use goose::providers::canonical::maybe_get_canonical_model;
|
||||
use goose::providers::create_with_default_model;
|
||||
use goose::providers::errors::ProviderError;
|
||||
use goose::providers::providers as get_providers;
|
||||
use goose::providers::{retry_operation, RetryConfig};
|
||||
use goose::{
|
||||
agents::execute_commands, agents::ExtensionConfig, config::permission::PermissionLevel,
|
||||
slash_commands,
|
||||
@@ -399,13 +401,15 @@ pub async fn get_provider_models(
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
let models_result = provider.fetch_recommended_models().await;
|
||||
let models_result = retry_operation(&RetryConfig::default(), || async {
|
||||
provider.fetch_recommended_models().await
|
||||
})
|
||||
.await;
|
||||
|
||||
match models_result {
|
||||
Ok(Some(models)) => Ok(Json(models)),
|
||||
Ok(None) => Ok(Json(Vec::new())),
|
||||
Err(provider_error) => {
|
||||
use goose::providers::errors::ProviderError;
|
||||
let status_code = match provider_error {
|
||||
// Permanent misconfigurations - client should fix configuration
|
||||
ProviderError::Authentication(_) => StatusCode::BAD_REQUEST,
|
||||
|
||||
Reference in New Issue
Block a user