diff --git a/llama_stack/distribution/datatypes.py b/llama_stack/distribution/datatypes.py index 3a60a057d..619b5b078 100644 --- a/llama_stack/distribution/datatypes.py +++ b/llama_stack/distribution/datatypes.py @@ -59,6 +59,12 @@ class GenericProviderConfig(BaseModel): config: Dict[str, Any] +class PlaceholderProviderConfig(BaseModel): + """Placeholder provider config for API whose provider are defined in routing_table""" + + providers: List[str] + + class RoutableProviderConfig(GenericProviderConfig): routing_key: str @@ -263,7 +269,9 @@ this could be just a hash The list of APIs to serve. If not specified, all APIs specified in the provider_map will be served""", ) - api_providers: Dict[str, GenericProviderConfig] = Field( + api_providers: Dict[ + str, Union[GenericProviderConfig, PlaceholderProviderConfig] + ] = Field( description=""" Provider configurations for each of the APIs provided by this package. """, diff --git a/llama_stack/distribution/server/server.py b/llama_stack/distribution/server/server.py index 4f9ef7ea6..098beb502 100644 --- a/llama_stack/distribution/server/server.py +++ b/llama_stack/distribution/server/server.py @@ -307,6 +307,10 @@ async def resolve_impls_with_routing(run_config: StackRunConfig) -> Dict[Api, An # TODO: check that these APIs are not in the routing table part of the config providers = all_providers[api] + # skip checks for API whose provider config is specified in routing_table + if isinstance(config, PlaceholderProviderConfig): + continue + if config.provider_id not in providers: raise ValueError( f"Unknown provider `{config.provider_id}` is not available for API `{api}`" diff --git a/tests/examples/router-local-run.yaml b/tests/examples/router-local-run.yaml index 774b4c266..589566cd2 100644 --- a/tests/examples/router-local-run.yaml +++ b/tests/examples/router-local-run.yaml @@ -10,6 +10,17 @@ apis_to_serve: - safety - models api_providers: + inference: + providers: + - meta-reference + - remote::ollama + memory: + providers: + - meta-reference + - remote::pgvector + safety: + providers: + - meta-reference telemetry: provider_id: meta-reference config: {}