Elffuss BraidHub

kikocis/llama-stack public

Update distribution_id -> distribution_type, provider_id -> provider_type
Changesetfb896ea47ba7ea1ef68bf37f23b257a89f877685bff21a79cda8322c659ba3eb
AuthorAshwin Bharambe <ashwin.bharambe@gmail.com> · 2024-09-07 08:42 -07:00
CommitterAshwin Bharambe <ashwin.bharambe@gmail.com> · 2024-09-07 08:42 -07:00
Parentsfec971db3fc6

Browse the files at this changeset

18 files changed

modified docs/cli_reference.md +2 −2
@@ -248,8 +248,8 @@
248248 ```
249249
250250 <pre style="font-family: monospace;">
251-i+--------------------------------+---------------------------------------+----------------------------------------------------------------------+
252-| Distribution ID | Providers | Description |
251+i+-------------------------------+---------------------------------------+----------------------------------------------------------------------+
252+| Distribution Type | Providers | Description |
253253 +--------------------------------+---------------------------------------+----------------------------------------------------------------------+
254254 | local | { | Use code from `llama_toolchain` itself to serve all llama stack APIs |
255255 | | "inference": "meta-reference", | |
modified llama_toolchain/agentic_system/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.agentic_system,
16- provider_id="meta-reference",
16+ provider_type="meta-reference",
1717 pip_packages=[
1818 "codeshield",
1919 "matplotlib",
modified llama_toolchain/cli/stack/build.py +5 −5
@@ -52,7 +52,7 @@
5252 BuildType,
5353 )
5454
55- allowed_ids = [d.distribution_id for d in available_distribution_specs()]
55+ allowed_ids = [d.distribution_type for d in available_distribution_specs()]
5656 self.parser.add_argument(
5757 "distribution",
5858 type=str,
@@ -101,7 +101,7 @@
101101 api_inputs.append(
102102 ApiInput(
103103 api=api,
104- provider=provider_spec.provider_id,
104+ provider=provider_spec.provider_type,
105105 )
106106 )
107107 docker_image = None
@@ -115,11 +115,11 @@
115115 self.parser.error(f"Could not find distribution {args.distribution}")
116116 return
117117
118- for api, provider_id in dist.providers.items():
118+ for api, provider_type in dist.providers.items():
119119 api_inputs.append(
120120 ApiInput(
121121 api=api,
122- provider=provider_id,
122+ provider=provider_type,
123123 )
124124 )
125125 docker_image = dist.docker_image
@@ -128,6 +128,6 @@
128128 api_inputs,
129129 build_type=BuildType(args.type),
130130 name=args.name,
131- distribution_id=args.distribution,
131+ distribution_type=args.distribution,
132132 docker_image=docker_image,
133133 )
modified llama_toolchain/cli/stack/configure.py +2 −2
@@ -36,7 +36,7 @@
3636 )
3737 from llama_toolchain.core.package import BuildType
3838
39- allowed_ids = [d.distribution_id for d in available_distribution_specs()]
39+ allowed_ids = [d.distribution_type for d in available_distribution_specs()]
4040 self.parser.add_argument(
4141 "distribution",
4242 type=str,
@@ -84,7 +84,7 @@
8484
8585 if config.providers:
8686 cprint(
87- f"Configuration already exists for {config.distribution_id}. Will overwrite...",
87+ f"Configuration already exists for {config.distribution_type}. Will overwrite...",
8888 "yellow",
8989 attrs=["bold"],
9090 )
modified llama_toolchain/cli/stack/list_distributions.py +2 −2
@@ -33,7 +33,7 @@
3333
3434 # eventually, this should query a registry at llama.meta.com/llamastack/distributions
3535 headers = [
36- "Distribution ID",
36+ "Distribution Type",
3737 "Providers",
3838 "Description",
3939 ]
@@ -43,7 +43,7 @@
4343 providers = {k.value: v for k, v in spec.providers.items()}
4444 rows.append(
4545 [
46- spec.distribution_id,
46+ spec.distribution_type,
4747 json.dumps(providers, indent=2),
4848 spec.description,
4949 ]
modified llama_toolchain/cli/stack/list_providers.py +2 −2
@@ -41,7 +41,7 @@
4141
4242 # eventually, this should query a registry at llama.meta.com/llamastack/distributions
4343 headers = [
44- "Provider ID",
44+ "Provider Type",
4545 "PIP Package Dependencies",
4646 ]
4747
@@ -49,7 +49,7 @@
4949 for spec in providers_for_api.values():
5050 rows.append(
5151 [
52- spec.provider_id,
52+ spec.provider_type,
5353 ",".join(spec.pip_packages),
5454 ]
5555 )
modified llama_toolchain/cli/stack/run.py +1 −1
@@ -80,7 +80,7 @@
8080 with open(config_file, "r") as f:
8181 config = PackageConfig(**yaml.safe_load(f))
8282
83- if not config.distribution_id:
83+ if not config.distribution_type:
8484 raise ValueError("Build config appears to be corrupt.")
8585
8686 if config.docker_image:
modified llama_toolchain/core/build_conda_env.sh +4 −4
@@ -20,12 +20,12 @@
2020 set -euo pipefail
2121
2222 if [ "$#" -ne 3 ]; then
23- echo "Usage: $0 <distribution_id> <build_name> <pip_dependencies>" >&2
24- echo "Example: $0 <distribution_id> mybuild 'numpy pandas scipy'" >&2
23+ echo "Usage: $0 <distribution_type> <build_name> <pip_dependencies>" >&2
24+ echo "Example: $0 <distribution_type> mybuild 'numpy pandas scipy'" >&2
2525 exit 1
2626 fi
2727
28-distribution_id="$1"
28+distribution_type="$1"
2929 build_name="$2"
3030 env_name="llamastack-$build_name"
3131 pip_dependencies="$3"
@@ -117,4 +117,4 @@
117117
118118 printf "${GREEN}Successfully setup conda environment. Configuring build...${NC}\n"
119119
120-$CONDA_PREFIX/bin/python3 -m llama_toolchain.cli.llama stack configure $distribution_id --name "$build_name" --type conda_env
120+$CONDA_PREFIX/bin/python3 -m llama_toolchain.cli.llama stack configure $distribution_type --name "$build_name" --type conda_env
modified llama_toolchain/core/build_container.sh +4 −4
@@ -5,12 +5,12 @@
55 TEST_PYPI_VERSION=${TEST_PYPI_VERSION:-}
66
77 if [ "$#" -ne 4 ]; then
8- echo "Usage: $0 <distribution_id> <build_name> <docker_base> <pip_dependencies>
9- echo "Example: $0 distribution_id my-fastapi-app python:3.9-slim 'fastapi uvicorn'
8+ echo "Usage: $0 <distribution_type> <build_name> <docker_base> <pip_dependencies>
9+ echo "Example: $0 distribution_type my-fastapi-app python:3.9-slim 'fastapi uvicorn'
1010 exit 1
1111 fi
1212
13-distribution_id=$1
13+distribution_type=$1
1414 build_name="$2"
1515 image_name="llamastack-$build_name"
1616 docker_base=$3
@@ -110,4 +110,4 @@
110110 printf "${GREEN}Succesfully setup Podman image. Configuring build...${NC}"
111111 echo "You can run it with: podman run -p 8000:8000 $image_name"
112112
113-$CONDA_PREFIX/bin/python3 -m llama_toolchain.cli.llama stack configure $distribution_id --name "$build_name" --type container
113+$CONDA_PREFIX/bin/python3 -m llama_toolchain.cli.llama stack configure $distribution_type --name "$build_name" --type container
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_id = stub_config["provider_id"]
25- if provider_id not in providers:
24+ provider_type = stub_config["provider_type"]
25+ if provider_type not in providers:
2626 raise ValueError(
27- f"Unknown provider `{provider_id}` is not available for API `{api_str}`"
27+ f"Unknown provider `{provider_type}` is not available for API `{api_str}`"
2828 )
2929
30- provider_spec = providers[provider_id]
31- cprint(f"Configuring API: {api_str} ({provider_id})", "white", attrs=["bold"])
30+ provider_spec = providers[provider_type]
31+ cprint(f"Configuring API: {api_str} ({provider_type})", "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_id": provider_id,
46+ "provider_type": provider_type,
4747 **provider_config.dict(),
4848 }
4949
modified llama_toolchain/core/datatypes.py +7 −7
@@ -31,7 +31,7 @@
3131 @json_schema_type
3232 class ProviderSpec(BaseModel):
3333 api: Api
34- provider_id: str
34+ provider_type: str
3535 config_class: str = Field(
3636 ...,
3737 description="Fully-qualified classname of the config for this provider",
@@ -100,7 +100,7 @@
100100 return url.rstrip("/")
101101
102102
103-def remote_provider_id(adapter_id: str) -> str:
103+def remote_provider_type(adapter_id: str) -> str:
104104 return f"remote::{adapter_id}"
105105
106106
@@ -141,22 +141,22 @@
141141 if adapter and adapter.config_class
142142 else "llama_toolchain.core.datatypes.RemoteProviderConfig"
143143 )
144- provider_id = remote_provider_id(adapter.adapter_id) if adapter else "remote"
144+ provider_type = remote_provider_type(adapter.adapter_id) if adapter else "remote"
145145
146146 return RemoteProviderSpec(
147- api=api, provider_id=provider_id, config_class=config_class, adapter=adapter
147+ api=api, provider_type=provider_type, config_class=config_class, adapter=adapter
148148 )
149149
150150
151151 @json_schema_type
152152 class DistributionSpec(BaseModel):
153- distribution_id: str
153+ distribution_type: str
154154 description: str
155155
156156 docker_image: Optional[str] = None
157157 providers: Dict[Api, str] = Field(
158158 default_factory=dict,
159- description="Provider IDs for each of the APIs provided by this distribution",
159+ description="Provider Types for each of the APIs provided by this distribution",
160160 )
161161
162162
@@ -171,7 +171,7 @@
171171 this could be just a hash
172172 """,
173173 )
174- distribution_id: Optional[str] = None
174+ distribution_type: Optional[str] = None
175175
176176 docker_image: Optional[str] = Field(
177177 default=None,
modified llama_toolchain/core/distribution.py +4 −4
@@ -83,18 +83,18 @@
8383
8484 def api_providers() -> Dict[Api, Dict[str, ProviderSpec]]:
8585 inference_providers_by_id = {
86- a.provider_id: a for a in available_inference_providers()
86+ a.provider_type: a for a in available_inference_providers()
8787 }
88- safety_providers_by_id = {a.provider_id: a for a in available_safety_providers()}
88+ safety_providers_by_id = {a.provider_type: a for a in available_safety_providers()}
8989 agentic_system_providers_by_id = {
90- a.provider_id: a for a in available_agentic_system_providers()
90+ a.provider_type: a for a in available_agentic_system_providers()
9191 }
9292
9393 ret = {
9494 Api.inference: inference_providers_by_id,
9595 Api.safety: safety_providers_by_id,
9696 Api.agentic_system: agentic_system_providers_by_id,
97- Api.memory: {a.provider_id: a for a in available_memory_providers()},
97+ Api.memory: {a.provider_type: a for a in available_memory_providers()},
9898 }
9999 for k, v in ret.items():
100100 v["remote"] = remote_provider_spec(k)
modified llama_toolchain/core/distribution_registry.py +10 −10
@@ -14,7 +14,7 @@
1414 def available_distribution_specs() -> List[DistributionSpec]:
1515 return [
1616 DistributionSpec(
17- distribution_id="local",
17+ distribution_type="local",
1818 description="Use code from `llama_toolchain` itself to serve all llama stack APIs",
1919 providers={
2020 Api.inference: "meta-reference",
@@ -24,35 +24,35 @@
2424 },
2525 ),
2626 DistributionSpec(
27- distribution_id="remote",
27+ distribution_type="remote",
2828 description="Point to remote services for all llama stack APIs",
2929 providers={x: "remote" for x in Api},
3030 ),
3131 DistributionSpec(
32- distribution_id="local-ollama",
32+ distribution_type="local-ollama",
3333 description="Like local, but use ollama for running LLM inference",
3434 providers={
35- Api.inference: remote_provider_id("ollama"),
35+ Api.inference: remote_provider_type("ollama"),
3636 Api.safety: "meta-reference",
3737 Api.agentic_system: "meta-reference",
3838 Api.memory: "meta-reference-faiss",
3939 },
4040 ),
4141 DistributionSpec(
42- distribution_id="local-plus-fireworks-inference",
42+ distribution_type="local-plus-fireworks-inference",
4343 description="Use Fireworks.ai for running LLM inference",
4444 providers={
45- Api.inference: remote_provider_id("fireworks"),
45+ Api.inference: remote_provider_type("fireworks"),
4646 Api.safety: "meta-reference",
4747 Api.agentic_system: "meta-reference",
4848 Api.memory: "meta-reference-faiss",
4949 },
5050 ),
5151 DistributionSpec(
52- distribution_id="local-plus-together-inference",
52+ distribution_type="local-plus-together-inference",
5353 description="Use Together.ai for running LLM inference",
5454 providers={
55- Api.inference: remote_provider_id("together"),
55+ Api.inference: remote_provider_type("together"),
5656 Api.safety: "meta-reference",
5757 Api.agentic_system: "meta-reference",
5858 Api.memory: "meta-reference-faiss",
@@ -62,8 +62,8 @@
6262
6363
6464 @lru_cache()
65-def resolve_distribution_spec(distribution_id: str) -> Optional[DistributionSpec]:
65+def resolve_distribution_spec(distribution_type: str) -> Optional[DistributionSpec]:
6666 for spec in available_distribution_specs():
67- if spec.distribution_id == distribution_id:
67+ if spec.distribution_type == distribution_type:
6868 return spec
6969 return None
modified llama_toolchain/core/package.py +9 −9
@@ -46,13 +46,13 @@
4646 api_inputs: List[ApiInput],
4747 build_type: BuildType,
4848 name: str,
49- distribution_id: Optional[str] = None,
49+ distribution_type: Optional[str] = None,
5050 docker_image: Optional[str] = None,
5151 ):
52- if not distribution_id:
53- distribution_id = "adhoc"
52+ if not distribution_type:
53+ distribution_type = "adhoc"
5454
55- build_dir = BUILDS_BASE_DIR / distribution_id / build_type.descriptor()
55+ build_dir = BUILDS_BASE_DIR / distribution_type / build_type.descriptor()
5656 os.makedirs(build_dir, exist_ok=True)
5757
5858 package_name = name.replace("::", "-")
@@ -79,7 +79,7 @@
7979 if provider.docker_image:
8080 raise ValueError("A stack's dependencies cannot have a docker image")
8181
82- stub_config[api.value] = {"provider_id": api_input.provider}
82+ stub_config[api.value] = {"provider_type": api_input.provider}
8383
8484 if package_file.exists():
8585 cprint(
@@ -92,7 +92,7 @@
9292 c.providers[api_str] = new_config
9393 else:
9494 existing_config = c.providers[api_str]
95- if existing_config["provider_id"] != new_config["provider_id"]:
95+ if existing_config["provider_type"] != new_config["provider_type"]:
9696 cprint(
9797 f"Provider `{api_str}` has changed from `{existing_config}` to `{new_config}`",
9898 color="yellow",
@@ -105,7 +105,7 @@
105105 providers=stub_config,
106106 )
107107
108- c.distribution_id = distribution_id
108+ c.distribution_type = distribution_type
109109 c.docker_image = package_name if build_type == BuildType.container else None
110110 c.conda_env = package_name if build_type == BuildType.conda_env else None
111111
@@ -119,7 +119,7 @@
119119 )
120120 args = [
121121 script,
122- distribution_id,
122+ distribution_type,
123123 package_name,
124124 package_deps.docker_image,
125125 " ".join(package_deps.pip_packages),
@@ -130,7 +130,7 @@
130130 )
131131 args = [
132132 script,
133- distribution_id,
133+ distribution_type,
134134 package_name,
135135 " ".join(package_deps.pip_packages),
136136 ]
modified llama_toolchain/core/server.py +4 −4
@@ -284,13 +284,13 @@
284284 for api_str, provider_config in config["providers"].items():
285285 api = Api(api_str)
286286 providers = all_providers[api]
287- provider_id = provider_config["provider_id"]
288- if provider_id not in providers:
287+ provider_type = provider_config["provider_type"]
288+ if provider_type not in providers:
289289 raise ValueError(
290- f"Unknown provider `{provider_id}` is not available for API `{api}`"
290+ f"Unknown provider `{provider_type}` is not available for API `{api}`"
291291 )
292292
293- provider_specs[api] = providers[provider_id]
293+ provider_specs[api] = providers[provider_type]
294294
295295 impls = resolve_impls(provider_specs, config)
296296
modified llama_toolchain/inference/providers.py +1 −1
@@ -13,7 +13,7 @@
1313 return [
1414 InlineProviderSpec(
1515 api=Api.inference,
16- provider_id="meta-reference",
16+ provider_type="meta-reference",
1717 pip_packages=[
1818 "accelerate",
1919 "blobfile",
modified llama_toolchain/memory/providers.py +1 −1
@@ -18,7 +18,7 @@
1818 return [
1919 InlineProviderSpec(
2020 api=Api.memory,
21- provider_id="meta-reference-faiss",
21+ provider_type="meta-reference-faiss",
2222 pip_packages=EMBEDDING_DEPS + ["faiss-cpu"],
2323 module="llama_toolchain.memory.meta_reference.faiss",
2424 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_id="meta-reference",
16+ provider_type="meta-reference",
1717 pip_packages=[
1818 "accelerate",
1919 "codeshield",