codex-lens: harden CLI embedding errors and flags

This commit is contained in:
catlog22
2026-03-05 14:27:36 +08:00
parent 6341ed43e1
commit 60218f6bf3
3 changed files with 177 additions and 24 deletions

View File

@@ -55,6 +55,11 @@ except ImportError:
def is_embedding_backend_available(_backend: str): # type: ignore[no-redef]
return False, "codexlens.semantic not available"
try:
from codexlens.semantic.vector_store import VectorStore
except ImportError: # pragma: no cover
VectorStore = None # type: ignore[assignment]
try:
from codexlens.config import VECTORS_META_DB_NAME
except ImportError:
@@ -720,6 +725,11 @@ def generate_embeddings(
# effective_batch_size is calculated above (dynamic or EMBEDDING_BATCH_SIZE fallback)
try:
if VectorStore is None:
return {
"success": False,
"error": "Semantic search not available (VectorStore import failed). Install with: pip install codexlens[semantic]",
}
with VectorStore(index_path) as vector_store:
# Check model compatibility with existing embeddings
if not force: