Skip to content

Commit b569164

Browse files
franciscojavierarceoiamemilio
authored andcommitted
fix: Fixing prompts import warning (llamastack#3455)
# What does this PR do? Fixes this warning in llama stack build: ```bash WARNING 2025-09-15 15:29:02,197 llama_stack.core.distribution:149 core: Failed to import module prompts: No module named 'llama_stack.providers.registry.prompts'" ``` ## Test Plan Test added --------- Signed-off-by: Francisco Javier Arceo <[email protected]>
1 parent b9a5fc3 commit b569164

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

llama_stack/core/distribution.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
logger = get_logger(name=__name__, category="core")
2727

2828

29+
INTERNAL_APIS = {Api.inspect, Api.providers, Api.prompts}
30+
31+
2932
def stack_apis() -> list[Api]:
3033
return list(Api)
3134

@@ -70,7 +73,7 @@ def builtin_automatically_routed_apis() -> list[AutoRoutedApiInfo]:
7073

7174
def providable_apis() -> list[Api]:
7275
routing_table_apis = {x.routing_table_api for x in builtin_automatically_routed_apis()}
73-
return [api for api in Api if api not in routing_table_apis and api != Api.inspect and api != Api.providers]
76+
return [api for api in Api if api not in routing_table_apis and api not in INTERNAL_APIS]
7477

7578

7679
def _load_remote_provider_spec(spec_data: dict[str, Any], api: Api) -> ProviderSpec:

tests/unit/distribution/test_distribution.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pydantic import BaseModel, Field, ValidationError
1313

1414
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
1616
from llama_stack.providers.datatypes import ProviderSpec
1717

1818

@@ -152,6 +152,24 @@ def test_builtin_providers(self, mock_providers):
152152
assert registry[Api.inference]["test_provider"].provider_type == "test_provider"
153153
assert registry[Api.inference]["test_provider"].api == Api.inference
154154

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+
155173
def test_external_remote_providers(self, api_directories, mock_providers, base_config, provider_spec_yaml):
156174
"""Test loading external remote providers from YAML files."""
157175
remote_dir, _ = api_directories

0 commit comments

Comments
 (0)