Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions crates/forge_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,28 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ForgeAp
})
.collect();

// Execute all provider fetches concurrently.
futures::future::join_all(futures)
.await
.into_iter()
.collect::<anyhow::Result<Vec<_>>>()
// Execute all provider fetches concurrently, tolerating partial failures.
let mut first_error: Option<anyhow::Error> = None;
let mut successes = Vec::new();

for result in futures::future::join_all(futures).await {
match result {
Ok(provider_models) => successes.push(provider_models),
Err(err) => {
tracing::warn!(error = %err, "failed to fetch models from a configured provider");
if first_error.is_none() {
first_error = Some(err);
}
}
}
}

if successes.is_empty()
&& let Some(err) = first_error
{
return Err(err);
}

Ok(successes)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation was recently changed. The problem was when the API key was invalid and more than one provider was activated the user would not be able to view the models of the invalid provider.

One option that I propose is - we could return a Vec of Result of models and on the UI, first show the error and then print the model selector with the models.

:model
[**:**:**] Error: Something bad happened
MODEL  PROVIDER  CONTEXT WINDOW
...    ...       ...    
...    ...       ...    
...    ...       ...    

}
}
Loading