pub async fn select_provider(
llm: &LlmConfig,
) -> Result<Box<dyn LlmProvider>, LlmError>Expand description
Probe every configured provider, pick the first reachable one whose
preferred_models intersects the live model list, and return it.
When llm.providers is empty we synthesise a single entry from the
legacy llm.provider/model/base_url/api_key fields — so existing
configs keep working unchanged.
Fail-safe: if no provider answers list_models, we still return the
first entry as a best effort rather than erroring out (the underlying
generate call will surface the real problem when used).