diff --git a/llama_stack/distribution/server/server.py b/llama_stack/distribution/server/server.py index 7d4ec2a2f..70107f45e 100644 --- a/llama_stack/distribution/server/server.py +++ b/llama_stack/distribution/server/server.py @@ -229,15 +229,34 @@ class TracingMiddleware: def __init__(self, app, impls): self.app = app self.impls = impls + # FastAPI built-in paths that should bypass custom routing + self.fastapi_paths = [ + "/docs", + "/redoc", + "/openapi.json", + "/favicon.ico", + "/static" + ] async def __call__(self, scope, receive, send): if scope.get("type") == "lifespan": return await self.app(scope, receive, send) path = scope.get("path", "") + + # Check if the path is a FastAPI built-in path + if any(path.startswith(fastapi_path) for fastapi_path in self.fastapi_paths): + # Pass through to FastAPI's built-in handlers + return await self.app(scope, receive, send) + if not hasattr(self, "endpoint_impls"): self.endpoint_impls = initialize_endpoint_impls(self.impls) - _, _, trace_path = find_matching_endpoint(scope.get("method", "GET"), path, self.endpoint_impls) + + try: + _, _, trace_path = find_matching_endpoint(scope.get("method", "GET"), path, self.endpoint_impls) + except ValueError: + # If no matching endpoint is found, pass through to FastAPI + return await self.app(scope, receive, send) trace_context = await start_trace(trace_path, {"__location__": "server", "raw_path": path}) @@ -388,7 +407,15 @@ def main(args: Optional[argparse.Namespace] = None): safe_config = redact_sensitive_fields(config.model_dump()) logger.info(yaml.dump(safe_config, indent=2)) - app = FastAPI(lifespan=lifespan) + app = FastAPI( + lifespan=lifespan, + docs_url="/docs", + redoc_url="/redoc", + openapi_url="/openapi.json", + title="Llama Stack API", + description="API for Llama Stack", + version="0.1.9" + ) if not os.environ.get("LLAMA_STACK_DISABLE_VERSION_CHECK"): app.add_middleware(ClientVersionMiddleware) @@ -499,4 +526,4 @@ def extract_path_params(route: str) -> List[str]: if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 466a6f2de..e2fd203d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,45 +1,79 @@ -# This file was autogenerated by uv via the following command: -# uv export --frozen --no-hashes --no-emit-project --output-file=requirements.txt +aiohappyeyeballs==2.6.1 +aiohttp==3.11.14 +aiosignal==1.3.2 +aiosqlite==0.21.0 annotated-types==0.7.0 anyio==4.8.0 attrs==25.1.0 +autoevals==0.0.126 blobfile==3.0.0 +braintrust_core==0.0.58 certifi==2025.1.31 charset-normalizer==3.4.1 +chevron==0.14.0 click==8.1.8 -colorama==0.4.6 ; sys_platform == 'win32' +colorama==0.4.6 +datasets==3.5.0 +Deprecated==1.2.18 +dill==0.3.8 distro==1.9.0 -exceptiongroup==1.2.2 ; python_full_version < '3.11' +faiss-cpu==1.10.0 +fastapi==0.115.12 filelock==3.17.0 fire==0.7.0 +frozenlist==1.5.0 fsspec==2024.12.0 +googleapis-common-protos==1.69.2 +grpcio==1.71.0 h11==0.14.0 httpcore==1.0.7 httpx==0.28.1 +httpx-sse==0.4.0 huggingface-hub==0.29.0 idna==3.10 -jinja2==3.1.6 +importlib_metadata==8.6.1 +Jinja2==3.1.6 +jiter==0.9.0 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 -llama-stack-client==0.1.19 +llama_stack @ file://./llama-stack +llama_stack_client==0.1.9 lxml==5.3.1 markdown-it-py==3.0.0 -markupsafe==3.0.2 +MarkupSafe==3.0.2 +mcp==1.6.0 mdurl==0.1.2 +multidict==6.2.0 +multiprocess==0.70.16 numpy==2.2.3 +ollama==0.4.7 +openai==1.69.0 +opentelemetry-api==1.31.1 +opentelemetry-exporter-otlp==1.31.1 +opentelemetry-exporter-otlp-proto-common==1.31.1 +opentelemetry-exporter-otlp-proto-grpc==1.31.1 +opentelemetry-exporter-otlp-proto-http==1.31.1 +opentelemetry-proto==1.31.1 +opentelemetry-sdk==1.31.1 +opentelemetry-semantic-conventions==0.52b1 packaging==24.2 pandas==2.2.3 pillow==11.1.0 -prompt-toolkit==3.0.50 +polyleven==0.9.0 +prompt_toolkit==3.0.50 +propcache==0.3.1 +protobuf==5.29.4 pyaml==25.1.0 +pyarrow==19.0.1 pycryptodomex==3.21.0 pydantic==2.10.6 -pydantic-core==2.27.2 -pygments==2.19.1 +pydantic-settings==2.8.1 +pydantic_core==2.27.2 +Pygments==2.19.1 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 pytz==2025.1 -pyyaml==6.0.2 +PyYAML==6.0.2 referencing==0.36.2 regex==2024.11.6 requests==2.32.3 @@ -48,10 +82,17 @@ rpds-py==0.22.3 setuptools==75.8.0 six==1.17.0 sniffio==1.3.1 +sse-starlette==2.2.1 +starlette==0.46.1 termcolor==2.5.0 tiktoken==0.9.0 tqdm==4.67.1 -typing-extensions==4.12.2 +typing_extensions==4.12.2 tzdata==2025.1 urllib3==2.3.0 +uvicorn==0.34.0 wcwidth==0.2.13 +wrapt==1.17.2 +xxhash==3.5.0 +yarl==1.18.3 +zipp==3.21.0