From 9a2b4efabd2142c5512a3f52aaedf5cac1eb26ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 25 Nov 2025 10:51:52 +0100 Subject: [PATCH] chore: clarify function and log about which router MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's FastAPI Signed-off-by: Sébastien Han --- scripts/openapi_generator/app.py | 6 +++--- src/llama_stack/core/inspect.py | 6 +++--- src/llama_stack/core/server/fastapi_router_registry.py | 2 +- src/llama_stack/core/server/routes.py | 2 +- src/llama_stack/core/server/server.py | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/openapi_generator/app.py b/scripts/openapi_generator/app.py index 8495c0013..023a4c62e 100644 --- a/scripts/openapi_generator/app.py +++ b/scripts/openapi_generator/app.py @@ -14,7 +14,7 @@ from typing import Any from fastapi import FastAPI from llama_stack.core.resolver import api_protocol_map -from llama_stack.core.server.fastapi_router_registry import build_router +from llama_stack.core.server.fastapi_router_registry import build_fastapi_router from llama_stack_api import Api from .state import _protocol_methods_cache @@ -81,7 +81,7 @@ def create_llama_stack_app() -> FastAPI: protocols = api_protocol_map() for api in protocols.keys(): # For OpenAPI generation, we don't need a real implementation - router = build_router(api, None) + router = build_fastapi_router(api, None) if router: app.include_router(router) @@ -95,7 +95,7 @@ def create_llama_stack_app() -> FastAPI: for api, routes in api_routes.items(): # Skip APIs that have routers - they're already included above - if build_router(api, None) is not None: + if build_fastapi_router(api, None) is not None: continue for route, webmethod in routes: diff --git a/src/llama_stack/core/inspect.py b/src/llama_stack/core/inspect.py index dfc4281fb..fe185d433 100644 --- a/src/llama_stack/core/inspect.py +++ b/src/llama_stack/core/inspect.py @@ -10,7 +10,7 @@ from pydantic import BaseModel from llama_stack.core.datatypes import StackRunConfig from llama_stack.core.external import load_external_apis -from llama_stack.core.server.fastapi_router_registry import build_router +from llama_stack.core.server.fastapi_router_registry import build_fastapi_router from llama_stack.core.server.routes import get_all_api_routes from llama_stack_api import ( Api, @@ -70,7 +70,7 @@ class DistributionInspectImpl(Inspect): # Process webmethod-based routes (legacy) for api, endpoints in all_endpoints.items(): # Skip APIs that have routers - they'll be processed separately - if build_router(api, None) is not None: + if build_fastapi_router(api, None) is not None: continue provider_types = get_provider_types(api) @@ -114,7 +114,7 @@ class DistributionInspectImpl(Inspect): protocols = api_protocol_map(external_apis) for api in protocols.keys(): # For route inspection, we don't need a real implementation - router = build_router(api, None) + router = build_fastapi_router(api, None) if not router: continue diff --git a/src/llama_stack/core/server/fastapi_router_registry.py b/src/llama_stack/core/server/fastapi_router_registry.py index 1e340bb75..f097ac0a4 100644 --- a/src/llama_stack/core/server/fastapi_router_registry.py +++ b/src/llama_stack/core/server/fastapi_router_registry.py @@ -26,7 +26,7 @@ _ROUTER_FACTORIES: dict[str, Any] = { } -def build_router(api: "Api", impl: Any) -> APIRouter | None: +def build_fastapi_router(api: "Api", impl: Any) -> APIRouter | None: """Build a router for an API by combining its router factory with the implementation. Args: diff --git a/src/llama_stack/core/server/routes.py b/src/llama_stack/core/server/routes.py index b6508a7a4..9df9e4a60 100644 --- a/src/llama_stack/core/server/routes.py +++ b/src/llama_stack/core/server/routes.py @@ -30,7 +30,7 @@ def get_all_api_routes( This function only returns routes from APIs that use the legacy @webmethod decorator system. For APIs that have been migrated to FastAPI routers, - use the router registry (fastapi_router_registry.has_router() and fastapi_router_registry.build_router()). + use the router registry (fastapi_router_registry.has_router() and fastapi_router_registry.build_fastapi_router()). Args: external_apis: Optional dictionary of external API specifications diff --git a/src/llama_stack/core/server/server.py b/src/llama_stack/core/server/server.py index 84f724fdb..e316609c3 100644 --- a/src/llama_stack/core/server/server.py +++ b/src/llama_stack/core/server/server.py @@ -44,7 +44,7 @@ from llama_stack.core.request_headers import ( request_provider_data_context, user_from_scope, ) -from llama_stack.core.server.fastapi_router_registry import build_router +from llama_stack.core.server.fastapi_router_registry import build_fastapi_router from llama_stack.core.server.routes import get_all_api_routes from llama_stack.core.stack import ( Stack, @@ -470,10 +470,10 @@ def create_app() -> StackApp: # Try to discover and use a router factory from the API package impl = impls[api] - router = build_router(api, impl) + router = build_fastapi_router(api, impl) if router: app.include_router(router) - logger.debug(f"Registered router for {api} API") + logger.debug(f"Registered FastAPIrouter for {api} API") continue # Fall back to old webmethod-based route discovery until the migration is complete