Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentML AI Inference Provider Integration #810

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion distributions/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,37 @@
"uvicorn",
"sentence-transformers --no-deps",
"torch --index-url https://download.pytorch.org/whl/cpu"
]
],
"centml": [
"aiosqlite",
"autoevals",
"blobfile",
"chardet",
"chromadb-client",
"datasets",
"faiss-cpu",
"fastapi",
"fire",
"httpx",
"matplotlib",
"nltk",
"numpy",
"openai",
"opentelemetry-exporter-otlp-proto-http",
"opentelemetry-sdk",
"pandas",
"pillow",
"psycopg2-binary",
"pypdf",
"redis",
"requests",
"scikit-learn",
"scipy",
"sentencepiece",
"tqdm",
"transformers",
"uvicorn",
"sentence-transformers --no-deps",
"torch --index-url https://download.pytorch.org/whl/cpu"
]
}
12 changes: 12 additions & 0 deletions llama_stack/providers/registry/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,16 @@ def available_providers() -> List[ProviderSpec]:
config_class="llama_stack.providers.remote.inference.nvidia.NVIDIAConfig",
),
),
remote_provider_spec(
api=Api.inference,
adapter=AdapterSpec(
adapter_type="centml",
pip_packages=[
"openai",
],
module="llama_stack.providers.remote.inference.centml",
config_class="llama_stack.providers.remote.inference.centml.CentMLImplConfig",
provider_data_validator="llama_stack.providers.remote.inference.centml.CentMLProviderDataValidator",
),
),
]
33 changes: 33 additions & 0 deletions llama_stack/providers/remote/inference/centml/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 pydantic import BaseModel

from .config import CentMLImplConfig


class CentMLProviderDataValidator(BaseModel):
centml_api_key: str


async def get_adapter_impl(config: CentMLImplConfig, _deps):
"""
Factory function to construct and initialize the CentML adapter.

:param config: Instance of CentMLImplConfig, containing `url`, `api_key`, etc.
:param _deps: Additional dependencies provided by llama-stack (unused here).
"""
from .centml import CentMLInferenceAdapter

# Ensure the provided config is indeed a CentMLImplConfig
assert isinstance(config, CentMLImplConfig), (
f"Unexpected config type: {type(config)}"
)

# Instantiate and initialize the adapter
adapter = CentMLInferenceAdapter(config)
await adapter.initialize()
return adapter
Loading