From 0eff77c73d815cfa85bc8d33a9955932e2833067 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 234d762ce..2bc3373a5 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -63,6 +63,19 @@ def pytest_configure(config): os.environ["DISABLE_CODE_SANDBOX"] = "1" logger.info("Setting DISABLE_CODE_SANDBOX=1 for macOS") + # 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(