Elffuss BraidHub

kikocis/llama-stack public

provider_type -> provider_id ... less confusing
Changeset6ff26f2ab7245a99574c9d44a74177d4aa5b548298f35ef486aad76506009bed
AuthorAshwin Bharambe <ashwin@meta.com> · 2024-09-16 12:09 -07:00
CommitterAshwin Bharambe <ashwin@meta.com> · 2024-09-16 12:10 -07:00
Parents50b1e5278a6f

Browse the files at this changeset

11 files changed

modified llama_toolchain/agentic_system/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.agentic_system,
16- provider_type="meta-reference",
16+ provider_id="meta-reference",
1717 pip_packages=[
1818 "codeshield",
1919 "matplotlib",
modified llama_toolchain/cli/stack/configure.py +3 −4
@@ -11,16 +11,15 @@
1111 import pkg_resources
1212
1313 import yaml
14+from termcolor import cprint
15+
1416 from llama_toolchain.cli.subcommand import Subcommand
1517 from llama_toolchain.common.config_dirs import BUILDS_BASE_DIR
1618
1719 from llama_toolchain.common.exec import run_with_pty
18-from termcolor import cprint
1920 from llama_toolchain.core.datatypes import * # noqa: F403
2021 import os
2122
22-from termcolor import cprint
23-
2423
2524 class StackConfigure(Subcommand):
2625 """Llama cli for configuring llama toolchain configs"""
@@ -109,7 +108,7 @@
109108 api2providers = build_config.distribution_spec.providers
110109
111110 stub_config = {
112- api_str: {"provider_type": provider}
111+ api_str: {"provider_id": provider}
113112 for api_str, provider in api2providers.items()
114113 }
115114
modified llama_toolchain/cli/stack/list_providers.py +1 −1
@@ -49,7 +49,7 @@
4949 for spec in providers_for_api.values():
5050 rows.append(
5151 [
52- spec.provider_type,
52+ spec.provider_id,
5353 ",".join(spec.pip_packages),
5454 ]
5555 )
modified llama_toolchain/core/configure.py +6 −6
@@ -21,14 +21,14 @@
2121 for api_str, stub_config in existing_configs.items():
2222 api = Api(api_str)
2323 providers = all_providers[api]
24- provider_type = stub_config["provider_type"]
25- if provider_type not in providers:
24+ provider_id = stub_config["provider_id"]
25+ if provider_id not in providers:
2626 raise ValueError(
27- f"Unknown provider `{provider_type}` is not available for API `{api_str}`"
27+ f"Unknown provider `{provider_id}` is not available for API `{api_str}`"
2828 )
2929
30- provider_spec = providers[provider_type]
31- cprint(f"Configuring API: {api_str} ({provider_type})", "white", attrs=["bold"])
30+ provider_spec = providers[provider_id]
31+ cprint(f"Configuring API: {api_str} ({provider_id})", "white", attrs=["bold"])
3232 config_type = instantiate_class_type(provider_spec.config_class)
3333
3434 try:
@@ -43,7 +43,7 @@
4343 print("")
4444
4545 provider_configs[api_str] = {
46- "provider_type": provider_type,
46+ "provider_id": provider_id,
4747 **provider_config.dict(),
4848 }
4949
modified llama_toolchain/core/datatypes.py +4 −4
@@ -32,7 +32,7 @@
3232 @json_schema_type
3333 class ProviderSpec(BaseModel):
3434 api: Api
35- provider_type: str
35+ provider_id: str
3636 config_class: str = Field(
3737 ...,
3838 description="Fully-qualified classname of the config for this provider",
@@ -101,7 +101,7 @@
101101 return url.rstrip("/")
102102
103103
104-def remote_provider_type(adapter_id: str) -> str:
104+def remote_provider_id(adapter_id: str) -> str:
105105 return f"remote::{adapter_id}"
106106
107107
@@ -142,10 +142,10 @@
142142 if adapter and adapter.config_class
143143 else "llama_toolchain.core.datatypes.RemoteProviderConfig"
144144 )
145- provider_type = remote_provider_type(adapter.adapter_id) if adapter else "remote"
145+ provider_id = remote_provider_id(adapter.adapter_id) if adapter else "remote"
146146
147147 return RemoteProviderSpec(
148- api=api, provider_type=provider_type, config_class=config_class, adapter=adapter
148+ api=api, provider_id=provider_id, config_class=config_class, adapter=adapter
149149 )
150150
151151
modified llama_toolchain/core/distribution.py +2 −9
@@ -14,14 +14,7 @@
1414 from llama_toolchain.safety.api import Safety
1515 from llama_toolchain.telemetry.api import Telemetry
1616
17-from .datatypes import (
18- Api,
19- ApiEndpoint,
20- DistributionSpec,
21- InlineProviderSpec,
22- ProviderSpec,
23- remote_provider_spec,
24-)
17+from .datatypes import Api, ApiEndpoint, ProviderSpec, remote_provider_spec
2518
2619 # These are the dependencies needed by the distribution server.
2720 # `llama-toolchain` is automatically installed by the installation script.
@@ -77,7 +70,7 @@
7770 module = importlib.import_module(f"llama_toolchain.{name}.providers")
7871 ret[api] = {
7972 "remote": remote_provider_spec(api),
80- **{a.provider_type: a for a in module.available_providers()},
73+ **{a.provider_id: a for a in module.available_providers()},
8174 }
8275
8376 return ret
modified llama_toolchain/core/server.py +4 −4
@@ -309,13 +309,13 @@
309309 for api_str, provider_config in config["providers"].items():
310310 api = Api(api_str)
311311 providers = all_providers[api]
312- provider_type = provider_config["provider_type"]
313- if provider_type not in providers:
312+ provider_id = provider_config["provider_id"]
313+ if provider_id not in providers:
314314 raise ValueError(
315- f"Unknown provider `{provider_type}` is not available for API `{api}`"
315+ f"Unknown provider `{provider_id}` is not available for API `{api}`"
316316 )
317317
318- provider_specs[api] = providers[provider_type]
318+ provider_specs[api] = providers[provider_id]
319319
320320 impls = resolve_impls(provider_specs, config)
321321 if Api.telemetry in impls:
modified llama_toolchain/inference/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.inference,
16- provider_type="meta-reference",
16+ provider_id="meta-reference",
1717 pip_packages=[
1818 "accelerate",
1919 "blobfile",
modified llama_toolchain/memory/providers.py +1 −1
@@ -20,7 +20,7 @@
2020 return [
2121 InlineProviderSpec(
2222 api=Api.memory,
23- provider_type="meta-reference-faiss",
23+ provider_id="meta-reference-faiss",
2424 pip_packages=EMBEDDING_DEPS + ["faiss-cpu"],
2525 module="llama_toolchain.memory.meta_reference.faiss",
2626 config_class="llama_toolchain.memory.meta_reference.faiss.FaissImplConfig",
modified llama_toolchain/safety/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.safety,
16- provider_type="meta-reference",
16+ provider_id="meta-reference",
1717 pip_packages=[
1818 "accelerate",
1919 "codeshield",
modified llama_toolchain/telemetry/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.telemetry,
16- provider_type="console",
16+ provider_id="console",
1717 pip_packages=[],
1818 module="llama_toolchain.telemetry.console",
1919 config_class="llama_toolchain.telemetry.console.ConsoleConfig",