mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 14:38:49 +00:00
Some checks failed
Coverage Badge / unit-tests (push) Failing after 1s
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
Installer CI / lint (push) Failing after 3s
Integration Tests / discover-tests (push) Successful in 3s
Installer CI / smoke-test-on-dev (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.12, inline::faiss) (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.12, inline::sqlite-vec) (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.12, inline::milvus) (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.12, remote::chromadb) (push) Failing after 6s
Python Package Build Test / build (3.12) (push) Failing after 3s
Python Package Build Test / build (3.13) (push) Failing after 2s
Test Llama Stack Build / generate-matrix (push) Successful in 3s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 10s
Test Llama Stack Build / build-single-provider (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.13, inline::faiss) (push) Failing after 5s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 13s
Unit Tests / unit-tests (3.13) (push) Failing after 6s
Test External API and Providers / test-external (venv) (push) Failing after 5s
Test Llama Stack Build / build-ubi9-container-distribution (push) Failing after 6s
Test Llama Stack Build / build-custom-container-distribution (push) Failing after 5s
Unit Tests / unit-tests (3.12) (push) Failing after 7s
Vector IO Integration Tests / test-matrix (3.13, remote::pgvector) (push) Failing after 6s
Update ReadTheDocs / update-readthedocs (push) Failing after 8s
Integration Tests / test-matrix (push) Failing after 8s
Vector IO Integration Tests / test-matrix (3.13, remote::chromadb) (push) Failing after 5s
Vector IO Integration Tests / test-matrix (3.12, remote::pgvector) (push) Failing after 6s
Vector IO Integration Tests / test-matrix (3.13, inline::sqlite-vec) (push) Failing after 6s
Vector IO Integration Tests / test-matrix (3.13, inline::milvus) (push) Failing after 5s
Test Llama Stack Build / build (push) Failing after 6s
Pre-commit / pre-commit (push) Successful in 57s
# What does this PR do? Prototype on a new feature to allow new APIs to be plugged in Llama Stack. Opened for early feedback on the approach and test appetite on the functionality. @ashwinb @raghotham open for early feedback, thanks! --------- Signed-off-by: Sébastien Han <seb@redhat.com> Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
from importlib.metadata import version
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from llama_stack.apis.inspect import (
|
|
HealthInfo,
|
|
Inspect,
|
|
ListRoutesResponse,
|
|
RouteInfo,
|
|
VersionInfo,
|
|
)
|
|
from llama_stack.distribution.datatypes import StackRunConfig
|
|
from llama_stack.distribution.external import load_external_apis
|
|
from llama_stack.distribution.server.routes import get_all_api_routes
|
|
from llama_stack.providers.datatypes import HealthStatus
|
|
|
|
|
|
class DistributionInspectConfig(BaseModel):
|
|
run_config: StackRunConfig
|
|
|
|
|
|
async def get_provider_impl(config, deps):
|
|
impl = DistributionInspectImpl(config, deps)
|
|
await impl.initialize()
|
|
return impl
|
|
|
|
|
|
class DistributionInspectImpl(Inspect):
|
|
def __init__(self, config: DistributionInspectConfig, deps):
|
|
self.config = config
|
|
self.deps = deps
|
|
|
|
async def initialize(self) -> None:
|
|
pass
|
|
|
|
async def list_routes(self) -> ListRoutesResponse:
|
|
run_config: StackRunConfig = self.config.run_config
|
|
|
|
ret = []
|
|
external_apis = load_external_apis(run_config)
|
|
all_endpoints = get_all_api_routes(external_apis)
|
|
for api, endpoints in all_endpoints.items():
|
|
# Always include provider and inspect APIs, filter others based on run config
|
|
if api.value in ["providers", "inspect"]:
|
|
ret.extend(
|
|
[
|
|
RouteInfo(
|
|
route=e.path,
|
|
method=next(iter([m for m in e.methods if m != "HEAD"])),
|
|
provider_types=[], # These APIs don't have "real" providers - they're internal to the stack
|
|
)
|
|
for e, _ in endpoints
|
|
if e.methods is not None
|
|
]
|
|
)
|
|
else:
|
|
providers = run_config.providers.get(api.value, [])
|
|
if providers: # Only process if there are providers for this API
|
|
ret.extend(
|
|
[
|
|
RouteInfo(
|
|
route=e.path,
|
|
method=next(iter([m for m in e.methods if m != "HEAD"])),
|
|
provider_types=[p.provider_type for p in providers],
|
|
)
|
|
for e, _ in endpoints
|
|
if e.methods is not None
|
|
]
|
|
)
|
|
|
|
return ListRoutesResponse(data=ret)
|
|
|
|
async def health(self) -> HealthInfo:
|
|
return HealthInfo(status=HealthStatus.OK)
|
|
|
|
async def version(self) -> VersionInfo:
|
|
return VersionInfo(version=version("llama-stack"))
|
|
|
|
async def shutdown(self) -> None:
|
|
pass
|