mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 19:04:19 +00:00
provider_type -> provider_id ... less confusing
This commit is contained in:
parent
ce6c868499
commit
6f5d9a3df8
11 changed files with 25 additions and 33 deletions
|
@ -13,7 +13,7 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
return [
|
return [
|
||||||
InlineProviderSpec(
|
InlineProviderSpec(
|
||||||
api=Api.agentic_system,
|
api=Api.agentic_system,
|
||||||
provider_type="meta-reference",
|
provider_id="meta-reference",
|
||||||
pip_packages=[
|
pip_packages=[
|
||||||
"codeshield",
|
"codeshield",
|
||||||
"matplotlib",
|
"matplotlib",
|
||||||
|
|
|
@ -11,16 +11,15 @@ from pathlib import Path
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from termcolor import cprint
|
||||||
|
|
||||||
from llama_toolchain.cli.subcommand import Subcommand
|
from llama_toolchain.cli.subcommand import Subcommand
|
||||||
from llama_toolchain.common.config_dirs import BUILDS_BASE_DIR
|
from llama_toolchain.common.config_dirs import BUILDS_BASE_DIR
|
||||||
|
|
||||||
from llama_toolchain.common.exec import run_with_pty
|
from llama_toolchain.common.exec import run_with_pty
|
||||||
from termcolor import cprint
|
|
||||||
from llama_toolchain.core.datatypes import * # noqa: F403
|
from llama_toolchain.core.datatypes import * # noqa: F403
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from termcolor import cprint
|
|
||||||
|
|
||||||
|
|
||||||
class StackConfigure(Subcommand):
|
class StackConfigure(Subcommand):
|
||||||
"""Llama cli for configuring llama toolchain configs"""
|
"""Llama cli for configuring llama toolchain configs"""
|
||||||
|
@ -109,7 +108,7 @@ class StackConfigure(Subcommand):
|
||||||
api2providers = build_config.distribution_spec.providers
|
api2providers = build_config.distribution_spec.providers
|
||||||
|
|
||||||
stub_config = {
|
stub_config = {
|
||||||
api_str: {"provider_type": provider}
|
api_str: {"provider_id": provider}
|
||||||
for api_str, provider in api2providers.items()
|
for api_str, provider in api2providers.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class StackListProviders(Subcommand):
|
||||||
for spec in providers_for_api.values():
|
for spec in providers_for_api.values():
|
||||||
rows.append(
|
rows.append(
|
||||||
[
|
[
|
||||||
spec.provider_type,
|
spec.provider_id,
|
||||||
",".join(spec.pip_packages),
|
",".join(spec.pip_packages),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,14 +21,14 @@ def configure_api_providers(existing_configs: Dict[str, Any]) -> None:
|
||||||
for api_str, stub_config in existing_configs.items():
|
for api_str, stub_config in existing_configs.items():
|
||||||
api = Api(api_str)
|
api = Api(api_str)
|
||||||
providers = all_providers[api]
|
providers = all_providers[api]
|
||||||
provider_type = stub_config["provider_type"]
|
provider_id = stub_config["provider_id"]
|
||||||
if provider_type not in providers:
|
if provider_id not in providers:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Unknown provider `{provider_type}` is not available for API `{api_str}`"
|
f"Unknown provider `{provider_id}` is not available for API `{api_str}`"
|
||||||
)
|
)
|
||||||
|
|
||||||
provider_spec = providers[provider_type]
|
provider_spec = providers[provider_id]
|
||||||
cprint(f"Configuring API: {api_str} ({provider_type})", "white", attrs=["bold"])
|
cprint(f"Configuring API: {api_str} ({provider_id})", "white", attrs=["bold"])
|
||||||
config_type = instantiate_class_type(provider_spec.config_class)
|
config_type = instantiate_class_type(provider_spec.config_class)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -43,7 +43,7 @@ def configure_api_providers(existing_configs: Dict[str, Any]) -> None:
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
provider_configs[api_str] = {
|
provider_configs[api_str] = {
|
||||||
"provider_type": provider_type,
|
"provider_id": provider_id,
|
||||||
**provider_config.dict(),
|
**provider_config.dict(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ApiEndpoint(BaseModel):
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class ProviderSpec(BaseModel):
|
class ProviderSpec(BaseModel):
|
||||||
api: Api
|
api: Api
|
||||||
provider_type: str
|
provider_id: str
|
||||||
config_class: str = Field(
|
config_class: str = Field(
|
||||||
...,
|
...,
|
||||||
description="Fully-qualified classname of the config for this provider",
|
description="Fully-qualified classname of the config for this provider",
|
||||||
|
@ -101,7 +101,7 @@ class RemoteProviderConfig(BaseModel):
|
||||||
return url.rstrip("/")
|
return url.rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
def remote_provider_type(adapter_id: str) -> str:
|
def remote_provider_id(adapter_id: str) -> str:
|
||||||
return f"remote::{adapter_id}"
|
return f"remote::{adapter_id}"
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,10 +142,10 @@ def remote_provider_spec(
|
||||||
if adapter and adapter.config_class
|
if adapter and adapter.config_class
|
||||||
else "llama_toolchain.core.datatypes.RemoteProviderConfig"
|
else "llama_toolchain.core.datatypes.RemoteProviderConfig"
|
||||||
)
|
)
|
||||||
provider_type = remote_provider_type(adapter.adapter_id) if adapter else "remote"
|
provider_id = remote_provider_id(adapter.adapter_id) if adapter else "remote"
|
||||||
|
|
||||||
return RemoteProviderSpec(
|
return RemoteProviderSpec(
|
||||||
api=api, provider_type=provider_type, config_class=config_class, adapter=adapter
|
api=api, provider_id=provider_id, config_class=config_class, adapter=adapter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,7 @@ from llama_toolchain.memory.api import Memory
|
||||||
from llama_toolchain.safety.api import Safety
|
from llama_toolchain.safety.api import Safety
|
||||||
from llama_toolchain.telemetry.api import Telemetry
|
from llama_toolchain.telemetry.api import Telemetry
|
||||||
|
|
||||||
from .datatypes import (
|
from .datatypes import Api, ApiEndpoint, ProviderSpec, remote_provider_spec
|
||||||
Api,
|
|
||||||
ApiEndpoint,
|
|
||||||
DistributionSpec,
|
|
||||||
InlineProviderSpec,
|
|
||||||
ProviderSpec,
|
|
||||||
remote_provider_spec,
|
|
||||||
)
|
|
||||||
|
|
||||||
# These are the dependencies needed by the distribution server.
|
# These are the dependencies needed by the distribution server.
|
||||||
# `llama-toolchain` is automatically installed by the installation script.
|
# `llama-toolchain` is automatically installed by the installation script.
|
||||||
|
@ -77,7 +70,7 @@ def api_providers() -> Dict[Api, Dict[str, ProviderSpec]]:
|
||||||
module = importlib.import_module(f"llama_toolchain.{name}.providers")
|
module = importlib.import_module(f"llama_toolchain.{name}.providers")
|
||||||
ret[api] = {
|
ret[api] = {
|
||||||
"remote": remote_provider_spec(api),
|
"remote": remote_provider_spec(api),
|
||||||
**{a.provider_type: a for a in module.available_providers()},
|
**{a.provider_id: a for a in module.available_providers()},
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -309,13 +309,13 @@ def main(yaml_config: str, port: int = 5000, disable_ipv6: bool = False):
|
||||||
for api_str, provider_config in config["providers"].items():
|
for api_str, provider_config in config["providers"].items():
|
||||||
api = Api(api_str)
|
api = Api(api_str)
|
||||||
providers = all_providers[api]
|
providers = all_providers[api]
|
||||||
provider_type = provider_config["provider_type"]
|
provider_id = provider_config["provider_id"]
|
||||||
if provider_type not in providers:
|
if provider_id not in providers:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Unknown provider `{provider_type}` is not available for API `{api}`"
|
f"Unknown provider `{provider_id}` is not available for API `{api}`"
|
||||||
)
|
)
|
||||||
|
|
||||||
provider_specs[api] = providers[provider_type]
|
provider_specs[api] = providers[provider_id]
|
||||||
|
|
||||||
impls = resolve_impls(provider_specs, config)
|
impls = resolve_impls(provider_specs, config)
|
||||||
if Api.telemetry in impls:
|
if Api.telemetry in impls:
|
||||||
|
|
|
@ -13,7 +13,7 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
return [
|
return [
|
||||||
InlineProviderSpec(
|
InlineProviderSpec(
|
||||||
api=Api.inference,
|
api=Api.inference,
|
||||||
provider_type="meta-reference",
|
provider_id="meta-reference",
|
||||||
pip_packages=[
|
pip_packages=[
|
||||||
"accelerate",
|
"accelerate",
|
||||||
"blobfile",
|
"blobfile",
|
||||||
|
|
|
@ -20,7 +20,7 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
return [
|
return [
|
||||||
InlineProviderSpec(
|
InlineProviderSpec(
|
||||||
api=Api.memory,
|
api=Api.memory,
|
||||||
provider_type="meta-reference-faiss",
|
provider_id="meta-reference-faiss",
|
||||||
pip_packages=EMBEDDING_DEPS + ["faiss-cpu"],
|
pip_packages=EMBEDDING_DEPS + ["faiss-cpu"],
|
||||||
module="llama_toolchain.memory.meta_reference.faiss",
|
module="llama_toolchain.memory.meta_reference.faiss",
|
||||||
config_class="llama_toolchain.memory.meta_reference.faiss.FaissImplConfig",
|
config_class="llama_toolchain.memory.meta_reference.faiss.FaissImplConfig",
|
||||||
|
|
|
@ -13,7 +13,7 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
return [
|
return [
|
||||||
InlineProviderSpec(
|
InlineProviderSpec(
|
||||||
api=Api.safety,
|
api=Api.safety,
|
||||||
provider_type="meta-reference",
|
provider_id="meta-reference",
|
||||||
pip_packages=[
|
pip_packages=[
|
||||||
"accelerate",
|
"accelerate",
|
||||||
"codeshield",
|
"codeshield",
|
||||||
|
|
|
@ -13,7 +13,7 @@ def available_providers() -> List[ProviderSpec]:
|
||||||
return [
|
return [
|
||||||
InlineProviderSpec(
|
InlineProviderSpec(
|
||||||
api=Api.telemetry,
|
api=Api.telemetry,
|
||||||
provider_type="console",
|
provider_id="console",
|
||||||
pip_packages=[],
|
pip_packages=[],
|
||||||
module="llama_toolchain.telemetry.console",
|
module="llama_toolchain.telemetry.console",
|
||||||
config_class="llama_toolchain.telemetry.console.ConsoleConfig",
|
config_class="llama_toolchain.telemetry.console.ConsoleConfig",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue