mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
chore: clarify function and log about which router
It's FastAPI Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
3770963130
commit
9a2b4efabd
5 changed files with 11 additions and 11 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue