mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 04:04:14 +00:00
chore: Improve error message for missing provider dependencies (#3315)
Generated with CC: Replace cryptic KeyError with clear, actionable error message that shows: - Which API the failing provider belongs to - The provider ID and type that's failing - Which dependency is missing - Clear instructions on how to fix the issue ## Test plan Use a run config with Agents API and no safety provider Before: KeyError: <Api.safety: 'safety'> After: Failed to resolve 'agents' provider 'meta-reference' of type 'inline::meta-reference': required dependency 'safety' is not available. Please add a 'safety' provider to your configuration or check if the provider is properly configured.
This commit is contained in:
parent
ccaf6aaa51
commit
d948e63340
1 changed files with 9 additions and 1 deletions
|
@ -284,7 +284,15 @@ async def instantiate_providers(
|
||||||
if provider.provider_id is None:
|
if provider.provider_id is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
deps = {a: impls[a] for a in provider.spec.api_dependencies}
|
try:
|
||||||
|
deps = {a: impls[a] for a in provider.spec.api_dependencies}
|
||||||
|
except KeyError as e:
|
||||||
|
missing_api = e.args[0]
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Failed to resolve '{provider.spec.api.value}' provider '{provider.provider_id}' of type '{provider.spec.provider_type}': "
|
||||||
|
f"required dependency '{missing_api.value}' is not available. "
|
||||||
|
f"Please add a '{missing_api.value}' provider to your configuration or check if the provider is properly configured."
|
||||||
|
) from e
|
||||||
for a in provider.spec.optional_api_dependencies:
|
for a in provider.spec.optional_api_dependencies:
|
||||||
if a in impls:
|
if a in impls:
|
||||||
deps[a] = impls[a]
|
deps[a] = impls[a]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue