mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +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>
54 lines
1.9 KiB
Python
54 lines
1.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.
|
|
|
|
|
|
import yaml
|
|
|
|
from llama_stack.apis.datatypes import Api, ExternalApiSpec
|
|
from llama_stack.distribution.datatypes import BuildConfig, StackRunConfig
|
|
from llama_stack.log import get_logger
|
|
|
|
logger = get_logger(name=__name__, category="core")
|
|
|
|
|
|
def load_external_apis(config: StackRunConfig | BuildConfig | None) -> dict[Api, ExternalApiSpec]:
|
|
"""Load external API specifications from the configured directory.
|
|
|
|
Args:
|
|
config: StackRunConfig or BuildConfig containing the external APIs directory path
|
|
|
|
Returns:
|
|
A dictionary mapping API names to their specifications
|
|
"""
|
|
if not config or not config.external_apis_dir:
|
|
return {}
|
|
|
|
external_apis_dir = config.external_apis_dir.expanduser().resolve()
|
|
if not external_apis_dir.is_dir():
|
|
logger.error(f"External APIs directory is not a directory: {external_apis_dir}")
|
|
return {}
|
|
|
|
logger.info(f"Loading external APIs from {external_apis_dir}")
|
|
external_apis: dict[Api, ExternalApiSpec] = {}
|
|
|
|
# Look for YAML files in the external APIs directory
|
|
for yaml_path in external_apis_dir.glob("*.yaml"):
|
|
try:
|
|
with open(yaml_path) as f:
|
|
spec_data = yaml.safe_load(f)
|
|
|
|
spec = ExternalApiSpec(**spec_data)
|
|
api = Api.add(spec.name)
|
|
logger.info(f"Loaded external API spec for {spec.name} from {yaml_path}")
|
|
external_apis[api] = spec
|
|
except yaml.YAMLError as yaml_err:
|
|
logger.error(f"Failed to parse YAML file {yaml_path}: {yaml_err}")
|
|
raise
|
|
except Exception:
|
|
logger.exception(f"Failed to load external API spec from {yaml_path}")
|
|
raise
|
|
|
|
return external_apis
|