mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-30 11:50:14 +00:00
fix
This commit is contained in:
parent
fb47cc0931
commit
414642b092
8 changed files with 46 additions and 29 deletions
|
@ -241,6 +241,7 @@ def run_stack_build_command(args: argparse.Namespace) -> None:
|
||||||
image_name=image_name,
|
image_name=image_name,
|
||||||
config_path=args.config,
|
config_path=args.config,
|
||||||
template_name=args.template,
|
template_name=args.template,
|
||||||
|
exit_after_containerfile=args.exit_after_containerfile,
|
||||||
)
|
)
|
||||||
|
|
||||||
except (Exception, RuntimeError) as exc:
|
except (Exception, RuntimeError) as exc:
|
||||||
|
@ -354,6 +355,7 @@ def _run_stack_build_command_from_build_config(
|
||||||
image_name: str | None = None,
|
image_name: str | None = None,
|
||||||
template_name: str | None = None,
|
template_name: str | None = None,
|
||||||
config_path: str | None = None,
|
config_path: str | None = None,
|
||||||
|
exit_after_containerfile: bool = False,
|
||||||
) -> Path | Traversable:
|
) -> Path | Traversable:
|
||||||
image_name = image_name or build_config.image_name
|
image_name = image_name or build_config.image_name
|
||||||
if build_config.image_type == LlamaStackImageType.CONTAINER.value:
|
if build_config.image_type == LlamaStackImageType.CONTAINER.value:
|
||||||
|
@ -396,6 +398,7 @@ def _run_stack_build_command_from_build_config(
|
||||||
image_name,
|
image_name,
|
||||||
template_or_config=template_name or config_path or str(build_file_path),
|
template_or_config=template_name or config_path or str(build_file_path),
|
||||||
run_config=run_config_file,
|
run_config=run_config_file,
|
||||||
|
exit_after_containerfile=exit_after_containerfile,
|
||||||
)
|
)
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
raise RuntimeError(f"Failed to build image {image_name}")
|
raise RuntimeError(f"Failed to build image {image_name}")
|
||||||
|
|
|
@ -82,6 +82,13 @@ the build. If not specified, currently active environment will be used if found.
|
||||||
help="Build a config for a list of providers and only those providers. This list is formatted like: api1=provider1,api2=provider2. Where there can be multiple providers per API.",
|
help="Build a config for a list of providers and only those providers. This list is formatted like: api1=provider1,api2=provider2. Where there can be multiple providers per API.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.parser.add_argument(
|
||||||
|
"--exit-after-containerfile",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="For container builds, exit after creating the Containerfile without building the image",
|
||||||
|
)
|
||||||
|
|
||||||
def _run_stack_build_command(self, args: argparse.Namespace) -> None:
|
def _run_stack_build_command(self, args: argparse.Namespace) -> None:
|
||||||
# always keep implementation completely silo-ed away from CLI so CLI
|
# always keep implementation completely silo-ed away from CLI so CLI
|
||||||
# can be fast to load and reduces dependencies
|
# can be fast to load and reduces dependencies
|
||||||
|
|
|
@ -110,6 +110,7 @@ def build_image(
|
||||||
image_name: str,
|
image_name: str,
|
||||||
template_or_config: str,
|
template_or_config: str,
|
||||||
run_config: str | None = None,
|
run_config: str | None = None,
|
||||||
|
exit_after_containerfile: bool = False,
|
||||||
):
|
):
|
||||||
container_base = build_config.distribution_spec.container_image or "python:3.10-slim"
|
container_base = build_config.distribution_spec.container_image or "python:3.10-slim"
|
||||||
|
|
||||||
|
@ -130,6 +131,10 @@ def build_image(
|
||||||
# build arguments
|
# build arguments
|
||||||
if run_config is not None:
|
if run_config is not None:
|
||||||
args.append(run_config)
|
args.append(run_config)
|
||||||
|
|
||||||
|
# Add exit_after_containerfile flag if specified
|
||||||
|
if exit_after_containerfile:
|
||||||
|
args.append("--exit-after-containerfile")
|
||||||
elif build_config.image_type == LlamaStackImageType.CONDA.value:
|
elif build_config.image_type == LlamaStackImageType.CONDA.value:
|
||||||
script = str(importlib.resources.files("llama_stack") / "distribution/build_conda_env.sh")
|
script = str(importlib.resources.files("llama_stack") / "distribution/build_conda_env.sh")
|
||||||
args = [
|
args = [
|
||||||
|
|
|
@ -43,6 +43,7 @@ shift
|
||||||
# Handle optional arguments
|
# Handle optional arguments
|
||||||
run_config=""
|
run_config=""
|
||||||
special_pip_deps=""
|
special_pip_deps=""
|
||||||
|
exit_after_containerfile=false
|
||||||
|
|
||||||
# Check if there are more arguments
|
# Check if there are more arguments
|
||||||
# The logics is becoming cumbersom, we should refactor it if we can do better
|
# The logics is becoming cumbersom, we should refactor it if we can do better
|
||||||
|
@ -53,11 +54,19 @@ if [ $# -gt 0 ]; then
|
||||||
shift
|
shift
|
||||||
# If there's another argument after .yaml, it must be special_pip_deps
|
# If there's another argument after .yaml, it must be special_pip_deps
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
special_pip_deps="$1"
|
if [[ "$1" == "--exit-after-containerfile" ]]; then
|
||||||
|
exit_after_containerfile=true
|
||||||
|
else
|
||||||
|
special_pip_deps="$1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# If it's not .yaml, it must be special_pip_deps
|
# If it's not .yaml, check if it's the exit flag
|
||||||
special_pip_deps="$1"
|
if [[ "$1" == "--exit-after-containerfile" ]]; then
|
||||||
|
exit_after_containerfile=true
|
||||||
|
else
|
||||||
|
special_pip_deps="$1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -270,6 +279,15 @@ printf "Containerfile created successfully in %s/Containerfile\n\n" "$TEMP_DIR"
|
||||||
cat "$TEMP_DIR"/Containerfile
|
cat "$TEMP_DIR"/Containerfile
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
|
# Exit after creating Containerfile if requested
|
||||||
|
if [ "$exit_after_containerfile" = true ]; then
|
||||||
|
# Copy Containerfile to current directory
|
||||||
|
cp "$TEMP_DIR/Containerfile" "$BUILD_CONTEXT_DIR/Containerfile"
|
||||||
|
echo "Containerfile has been copied to $(pwd)/Containerfile"
|
||||||
|
echo "Exiting after Containerfile creation as requested"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Start building the CLI arguments
|
# Start building the CLI arguments
|
||||||
CLI_ARGS=()
|
CLI_ARGS=()
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class RedisKVStoreConfig(CommonConfig):
|
||||||
|
|
||||||
|
|
||||||
class SqliteKVStoreConfig(CommonConfig):
|
class SqliteKVStoreConfig(CommonConfig):
|
||||||
type: Literal[KVStoreType.sqlite.value] = KVStoreType.sqlite.value
|
type: Literal[KVStoreType.sqlite] = KVStoreType.sqlite.value
|
||||||
db_path: str = Field(
|
db_path: str = Field(
|
||||||
default=(RUNTIME_BASE_DIR / "kvstore.db").as_posix(),
|
default=(RUNTIME_BASE_DIR / "kvstore.db").as_posix(),
|
||||||
description="File path for the sqlite database",
|
description="File path for the sqlite database",
|
||||||
|
@ -63,7 +63,7 @@ class SqliteKVStoreConfig(CommonConfig):
|
||||||
|
|
||||||
|
|
||||||
class PostgresKVStoreConfig(CommonConfig):
|
class PostgresKVStoreConfig(CommonConfig):
|
||||||
type: Literal[KVStoreType.postgres.value] = KVStoreType.postgres.value
|
type: Literal[KVStoreType.postgres] = KVStoreType.postgres.value
|
||||||
host: str = "localhost"
|
host: str = "localhost"
|
||||||
port: int = 5432
|
port: int = 5432
|
||||||
db: str = "llamastack"
|
db: str = "llamastack"
|
||||||
|
@ -102,7 +102,7 @@ class PostgresKVStoreConfig(CommonConfig):
|
||||||
|
|
||||||
|
|
||||||
class MongoDBKVStoreConfig(CommonConfig):
|
class MongoDBKVStoreConfig(CommonConfig):
|
||||||
type: Literal[KVStoreType.mongodb.value] = KVStoreType.mongodb.value
|
type: Literal[KVStoreType.mongodb] = KVStoreType.mongodb.value
|
||||||
host: str = "localhost"
|
host: str = "localhost"
|
||||||
port: int = 27017
|
port: int = 27017
|
||||||
db: str = "llamastack"
|
db: str = "llamastack"
|
||||||
|
@ -125,6 +125,6 @@ class MongoDBKVStoreConfig(CommonConfig):
|
||||||
|
|
||||||
|
|
||||||
KVStoreConfig = Annotated[
|
KVStoreConfig = Annotated[
|
||||||
RedisKVStoreConfig | SqliteKVStoreConfig | PostgresKVStoreConfig | MongoDBKVStoreConfig,
|
PostgresKVStoreConfig,
|
||||||
Field(discriminator="type", default=KVStoreType.sqlite.value),
|
Field(discriminator="type", default=KVStoreType.postgres.value),
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,7 +10,7 @@ from .config import KVStoreConfig, KVStoreType
|
||||||
|
|
||||||
|
|
||||||
def kvstore_dependencies():
|
def kvstore_dependencies():
|
||||||
return ["aiosqlite", "psycopg2-binary", "redis", "pymongo"]
|
return ["aiosqlite", "psycopg2-binary"]
|
||||||
|
|
||||||
|
|
||||||
class InmemoryKVStoreImpl(KVStore):
|
class InmemoryKVStoreImpl(KVStore):
|
||||||
|
|
|
@ -22,14 +22,13 @@ from llama_stack.templates.template import DistributionTemplate, RunConfigSettin
|
||||||
def get_distribution_template() -> DistributionTemplate:
|
def get_distribution_template() -> DistributionTemplate:
|
||||||
providers = {
|
providers = {
|
||||||
"inference": ["remote::ollama"],
|
"inference": ["remote::ollama"],
|
||||||
"vector_io": ["inline::faiss", "remote::chromadb", "remote::pgvector"],
|
"vector_io": ["remote::chromadb"],
|
||||||
"safety": ["inline::llama-guard"],
|
"safety": ["inline::llama-guard"],
|
||||||
"agents": ["inline::meta-reference"],
|
"agents": ["inline::meta-reference"],
|
||||||
"telemetry": ["inline::meta-reference"],
|
"telemetry": ["inline::meta-reference"],
|
||||||
"eval": ["inline::meta-reference"],
|
"eval": ["inline::meta-reference"],
|
||||||
"datasetio": ["remote::huggingface", "inline::localfs"],
|
"datasetio": ["inline::localfs"],
|
||||||
"scoring": ["inline::basic", "inline::llm-as-judge", "inline::braintrust"],
|
"scoring": ["inline::basic", "inline::llm-as-judge"],
|
||||||
"post_training": ["inline::huggingface"],
|
|
||||||
"tool_runtime": [
|
"tool_runtime": [
|
||||||
"remote::brave-search",
|
"remote::brave-search",
|
||||||
"remote::tavily-search",
|
"remote::tavily-search",
|
||||||
|
@ -49,11 +48,6 @@ def get_distribution_template() -> DistributionTemplate:
|
||||||
provider_type="inline::faiss",
|
provider_type="inline::faiss",
|
||||||
config=FaissVectorIOConfig.sample_run_config(f"~/.llama/distributions/{name}"),
|
config=FaissVectorIOConfig.sample_run_config(f"~/.llama/distributions/{name}"),
|
||||||
)
|
)
|
||||||
posttraining_provider = Provider(
|
|
||||||
provider_id="huggingface",
|
|
||||||
provider_type="inline::huggingface",
|
|
||||||
config=HuggingFacePostTrainingConfig.sample_run_config(f"~/.llama/distributions/{name}"),
|
|
||||||
)
|
|
||||||
inference_model = ModelInput(
|
inference_model = ModelInput(
|
||||||
model_id="${env.INFERENCE_MODEL}",
|
model_id="${env.INFERENCE_MODEL}",
|
||||||
provider_id="ollama",
|
provider_id="ollama",
|
||||||
|
@ -98,7 +92,6 @@ def get_distribution_template() -> DistributionTemplate:
|
||||||
provider_overrides={
|
provider_overrides={
|
||||||
"inference": [inference_provider],
|
"inference": [inference_provider],
|
||||||
"vector_io": [vector_io_provider_faiss],
|
"vector_io": [vector_io_provider_faiss],
|
||||||
"post_training": [posttraining_provider],
|
|
||||||
},
|
},
|
||||||
default_models=[inference_model, embedding_model],
|
default_models=[inference_model, embedding_model],
|
||||||
default_tool_groups=default_tool_groups,
|
default_tool_groups=default_tool_groups,
|
||||||
|
@ -106,8 +99,7 @@ def get_distribution_template() -> DistributionTemplate:
|
||||||
"run-with-safety.yaml": RunConfigSettings(
|
"run-with-safety.yaml": RunConfigSettings(
|
||||||
provider_overrides={
|
provider_overrides={
|
||||||
"inference": [inference_provider],
|
"inference": [inference_provider],
|
||||||
"vector_io": [vector_io_provider_faiss],
|
"vector_io": [vector_io_provider_faiss]
|
||||||
"post_training": [posttraining_provider],
|
|
||||||
"safety": [
|
"safety": [
|
||||||
Provider(
|
Provider(
|
||||||
provider_id="llama-guard",
|
provider_id="llama-guard",
|
||||||
|
|
|
@ -5,7 +5,6 @@ apis:
|
||||||
- datasetio
|
- datasetio
|
||||||
- eval
|
- eval
|
||||||
- inference
|
- inference
|
||||||
- post_training
|
|
||||||
- safety
|
- safety
|
||||||
- scoring
|
- scoring
|
||||||
- telemetry
|
- telemetry
|
||||||
|
@ -82,13 +81,6 @@ providers:
|
||||||
provider_type: inline::braintrust
|
provider_type: inline::braintrust
|
||||||
config:
|
config:
|
||||||
openai_api_key: ${env.OPENAI_API_KEY:}
|
openai_api_key: ${env.OPENAI_API_KEY:}
|
||||||
post_training:
|
|
||||||
- provider_id: huggingface
|
|
||||||
provider_type: inline::huggingface
|
|
||||||
config:
|
|
||||||
checkpoint_format: huggingface
|
|
||||||
distributed_backend: null
|
|
||||||
device: cpu
|
|
||||||
tool_runtime:
|
tool_runtime:
|
||||||
- provider_id: brave-search
|
- provider_id: brave-search
|
||||||
provider_type: remote::brave-search
|
provider_type: remote::brave-search
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue