From b6c69f23adbb60b52f9b6a895440fa2a3e8012ad Mon Sep 17 00:00:00 2001 From: skamenan7 Date: Fri, 25 Jul 2025 17:06:43 -0400 Subject: [PATCH] feat(vector-io): implement global default embedding model configuration (Issue #2729) - Add VectorStoreConfig with global default_embedding_model and default_embedding_dimension - Support environment variables LLAMA_STACK_DEFAULT_EMBEDDING_MODEL and LLAMA_STACK_DEFAULT_EMBEDDING_DIMENSION - Implement precedence: explicit model > global default > clear error (no fallback) - Update VectorIORouter with _resolve_embedding_model() precedence logic - Remove non-deterministic 'first model in run.yaml' fallback behavior - Add vector_store_config to StackRunConfig and all distribution templates - Include comprehensive unit tests for config loading and router precedence - Update documentation with configuration examples and usage patterns - Fix error messages to include 'Failed to' prefix per coding standards Resolves deterministic vector store creation by eliminating unpredictable fallbacks and providing clear configuration options at the stack level. --- tests/integration/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 4735264c3..7fba6e8e0 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -94,6 +94,19 @@ def pytest_configure(config): if not current: setattr(config.option, dest, value) + # After processing CLI --env overrides, ensure global default embedding model is set for vector-store operations + embedding_model_opt = config.getoption("--embedding-model") or "sentence-transformers/all-MiniLM-L6-v2" + if embedding_model_opt and not os.getenv("LLAMA_STACK_DEFAULT_EMBEDDING_MODEL"): + # Use first value in comma-separated list (if any) + default_model = embedding_model_opt.split(",")[0].strip() + os.environ["LLAMA_STACK_DEFAULT_EMBEDDING_MODEL"] = default_model + logger.info(f"Setting LLAMA_STACK_DEFAULT_EMBEDDING_MODEL={default_model}") + + embedding_dim_opt = config.getoption("--embedding-dimension") or 384 + if not os.getenv("LLAMA_STACK_DEFAULT_EMBEDDING_DIMENSION") and embedding_dim_opt: + os.environ["LLAMA_STACK_DEFAULT_EMBEDDING_DIMENSION"] = str(embedding_dim_opt) + logger.info(f"Setting LLAMA_STACK_DEFAULT_EMBEDDING_DIMENSION={embedding_dim_opt}") + def pytest_addoption(parser): parser.addoption(