mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
fix: FastAPI built-in paths bypass custom routing (Docs) and update requirements document
This commit is contained in:
parent
3a2314dcef
commit
de60fb571f
2 changed files with 83 additions and 15 deletions
|
@ -229,15 +229,34 @@ class TracingMiddleware:
|
||||||
def __init__(self, app, impls):
|
def __init__(self, app, impls):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.impls = impls
|
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):
|
async def __call__(self, scope, receive, send):
|
||||||
if scope.get("type") == "lifespan":
|
if scope.get("type") == "lifespan":
|
||||||
return await self.app(scope, receive, send)
|
return await self.app(scope, receive, send)
|
||||||
|
|
||||||
path = scope.get("path", "")
|
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"):
|
if not hasattr(self, "endpoint_impls"):
|
||||||
self.endpoint_impls = initialize_endpoint_impls(self.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})
|
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())
|
safe_config = redact_sensitive_fields(config.model_dump())
|
||||||
logger.info(yaml.dump(safe_config, indent=2))
|
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"):
|
if not os.environ.get("LLAMA_STACK_DISABLE_VERSION_CHECK"):
|
||||||
app.add_middleware(ClientVersionMiddleware)
|
app.add_middleware(ClientVersionMiddleware)
|
||||||
|
|
||||||
|
|
|
@ -1,45 +1,79 @@
|
||||||
# This file was autogenerated by uv via the following command:
|
aiohappyeyeballs==2.6.1
|
||||||
# uv export --frozen --no-hashes --no-emit-project --output-file=requirements.txt
|
aiohttp==3.11.14
|
||||||
|
aiosignal==1.3.2
|
||||||
|
aiosqlite==0.21.0
|
||||||
annotated-types==0.7.0
|
annotated-types==0.7.0
|
||||||
anyio==4.8.0
|
anyio==4.8.0
|
||||||
attrs==25.1.0
|
attrs==25.1.0
|
||||||
|
autoevals==0.0.126
|
||||||
blobfile==3.0.0
|
blobfile==3.0.0
|
||||||
|
braintrust_core==0.0.58
|
||||||
certifi==2025.1.31
|
certifi==2025.1.31
|
||||||
charset-normalizer==3.4.1
|
charset-normalizer==3.4.1
|
||||||
|
chevron==0.14.0
|
||||||
click==8.1.8
|
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
|
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
|
filelock==3.17.0
|
||||||
fire==0.7.0
|
fire==0.7.0
|
||||||
|
frozenlist==1.5.0
|
||||||
fsspec==2024.12.0
|
fsspec==2024.12.0
|
||||||
|
googleapis-common-protos==1.69.2
|
||||||
|
grpcio==1.71.0
|
||||||
h11==0.14.0
|
h11==0.14.0
|
||||||
httpcore==1.0.7
|
httpcore==1.0.7
|
||||||
httpx==0.28.1
|
httpx==0.28.1
|
||||||
|
httpx-sse==0.4.0
|
||||||
huggingface-hub==0.29.0
|
huggingface-hub==0.29.0
|
||||||
idna==3.10
|
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==4.23.0
|
||||||
jsonschema-specifications==2024.10.1
|
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
|
lxml==5.3.1
|
||||||
markdown-it-py==3.0.0
|
markdown-it-py==3.0.0
|
||||||
markupsafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
|
mcp==1.6.0
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
|
multidict==6.2.0
|
||||||
|
multiprocess==0.70.16
|
||||||
numpy==2.2.3
|
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
|
packaging==24.2
|
||||||
pandas==2.2.3
|
pandas==2.2.3
|
||||||
pillow==11.1.0
|
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
|
pyaml==25.1.0
|
||||||
|
pyarrow==19.0.1
|
||||||
pycryptodomex==3.21.0
|
pycryptodomex==3.21.0
|
||||||
pydantic==2.10.6
|
pydantic==2.10.6
|
||||||
pydantic-core==2.27.2
|
pydantic-settings==2.8.1
|
||||||
pygments==2.19.1
|
pydantic_core==2.27.2
|
||||||
|
Pygments==2.19.1
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
pytz==2025.1
|
pytz==2025.1
|
||||||
pyyaml==6.0.2
|
PyYAML==6.0.2
|
||||||
referencing==0.36.2
|
referencing==0.36.2
|
||||||
regex==2024.11.6
|
regex==2024.11.6
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
|
@ -48,10 +82,17 @@ rpds-py==0.22.3
|
||||||
setuptools==75.8.0
|
setuptools==75.8.0
|
||||||
six==1.17.0
|
six==1.17.0
|
||||||
sniffio==1.3.1
|
sniffio==1.3.1
|
||||||
|
sse-starlette==2.2.1
|
||||||
|
starlette==0.46.1
|
||||||
termcolor==2.5.0
|
termcolor==2.5.0
|
||||||
tiktoken==0.9.0
|
tiktoken==0.9.0
|
||||||
tqdm==4.67.1
|
tqdm==4.67.1
|
||||||
typing-extensions==4.12.2
|
typing_extensions==4.12.2
|
||||||
tzdata==2025.1
|
tzdata==2025.1
|
||||||
urllib3==2.3.0
|
urllib3==2.3.0
|
||||||
|
uvicorn==0.34.0
|
||||||
wcwidth==0.2.13
|
wcwidth==0.2.13
|
||||||
|
wrapt==1.17.2
|
||||||
|
xxhash==3.5.0
|
||||||
|
yarl==1.18.3
|
||||||
|
zipp==3.21.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue