mirror of
https://github.com/cocoindex-io/cocoindex-code.git
synced 2026-09-14 16:39:38 +08:00
5b6e3f5538
- Move `sentence-transformers` behind `[embeddings-local]` and `[default]` extras (via `cocoindex[sentence-transformers]`), so `pip install cocoindex-code` is LiteLLM-only. Closes #117. - `ccc init` is now interactive when global settings don't exist: pick provider (sentence-transformers / litellm) and model via a questionary TUI. New `--litellm-model MODEL` flag skips prompts and is the non-TTY escape hatch for LiteLLM. Closes #70. - Change the default sentence-transformers model from `all-MiniLM-L6-v2` to `Snowflake/snowflake-arctic-embed-xs` (lighter, better quality for code). - Generated `global_settings.yml` now includes a `ccc doctor` reminder and commented-out env-var examples (OPENAI_API_KEY, GEMINI_API_KEY, ANTHROPIC_API_KEY, VOYAGE_API_KEY). - Model test during init runs in the daemon via the existing `DoctorRequest` path; the daemon loads the model once and stays running, so the user's next `ccc index` starts warm. - Docker image now installs `cocoindex-code[default]` and pre-caches the new default model. The `COCOINDEX_CODE_EMBEDDING_MODEL` env var is no longer documented for Docker; users mount a `global_settings.yml` or pass `--litellm-model`. - Extract `check_embedding` + `EmbeddingCheckResult` into `shared.py`; refactor daemon `_check_model` to delegate. Error messages in doctor output now include the exception type name (strictly more informative). - Tests switch to a lighter `paraphrase-MiniLM-L3-v2` model via a new `make_test_user_settings()` helper in `conftest.py`, leaving CI cache costs unchanged.
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""Pytest configuration and fixtures."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING
|
|
|
|
import pytest
|
|
|
|
if TYPE_CHECKING:
|
|
from cocoindex_code.settings import UserSettings
|
|
|
|
# === Environment setup BEFORE any cocoindex_code imports ===
|
|
_TEST_DIR = Path(tempfile.mkdtemp(prefix="cocoindex_test_"))
|
|
os.environ["COCOINDEX_CODE_ROOT_PATH"] = str(_TEST_DIR)
|
|
|
|
|
|
# Lighter than the production default (Snowflake/snowflake-arctic-embed-xs)
|
|
# so tests keep CI cache costs low while still exercising the full embedder
|
|
# code path.
|
|
TEST_EMBEDDING_MODEL = "sentence-transformers/paraphrase-MiniLM-L3-v2"
|
|
|
|
|
|
# NOTE: deliberately NOT prefixed with `test_` — pytest auto-collects any
|
|
# top-level `test_*` function as a test case.
|
|
def make_test_user_settings() -> UserSettings:
|
|
"""Lightweight UserSettings for tests — uses a smaller model than the production default."""
|
|
from cocoindex_code.settings import EmbeddingSettings, UserSettings
|
|
|
|
return UserSettings(
|
|
embedding=EmbeddingSettings(
|
|
provider="sentence-transformers",
|
|
model=TEST_EMBEDDING_MODEL,
|
|
),
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def test_codebase_root() -> Path:
|
|
"""Session-scoped test codebase directory."""
|
|
return _TEST_DIR
|