|
12 | 12 | from pydantic import BaseModel, Field, ValidationError |
13 | 13 |
|
14 | 14 | from llama_stack.core.datatypes import Api, Provider, StackRunConfig |
15 | | -from llama_stack.core.distribution import get_provider_registry |
| 15 | +from llama_stack.core.distribution import INTERNAL_APIS, get_provider_registry, providable_apis |
16 | 16 | from llama_stack.providers.datatypes import ProviderSpec |
17 | 17 |
|
18 | 18 |
|
@@ -152,6 +152,24 @@ def test_builtin_providers(self, mock_providers): |
152 | 152 | assert registry[Api.inference]["test_provider"].provider_type == "test_provider" |
153 | 153 | assert registry[Api.inference]["test_provider"].api == Api.inference |
154 | 154 |
|
| 155 | + def test_internal_apis_excluded(self): |
| 156 | + """Test that internal APIs are excluded and APIs without provider registries are marked as internal.""" |
| 157 | + import importlib |
| 158 | + |
| 159 | + apis = providable_apis() |
| 160 | + |
| 161 | + for internal_api in INTERNAL_APIS: |
| 162 | + assert internal_api not in apis, f"Internal API {internal_api} should not be in providable_apis" |
| 163 | + |
| 164 | + for api in apis: |
| 165 | + module_name = f"llama_stack.providers.registry.{api.name.lower()}" |
| 166 | + try: |
| 167 | + importlib.import_module(module_name) |
| 168 | + except ImportError as err: |
| 169 | + raise AssertionError( |
| 170 | + f"API {api} is in providable_apis but has no provider registry module ({module_name})" |
| 171 | + ) from err |
| 172 | + |
155 | 173 | def test_external_remote_providers(self, api_directories, mock_providers, base_config, provider_spec_yaml): |
156 | 174 | """Test loading external remote providers from YAML files.""" |
157 | 175 | remote_dir, _ = api_directories |
|
0 commit comments