feat(embedding): add get_embed_status() for API-only mode

This commit is contained in:
Research Assistant 2026-05-18 17:17:26 +08:00
parent 755fcf2cd1
commit 32d5622ff7

View file

@ -0,0 +1,39 @@
from __future__ import annotations
import logging
from pathlib import Path
from paperforge.embedding._chroma import get_collection, get_vector_db_path
from paperforge.embedding._config import get_api_model
logger = logging.getLogger(__name__)
def get_embed_status(vault: Path) -> dict:
"""Get vector DB status. API-only mode.
Returns dict with keys: db_exists, chunk_count, model, mode, healthy, error.
"""
db_path = get_vector_db_path(vault)
exists = db_path.exists()
chunk_count = 0
healthy = True
error = ""
if exists:
try:
collection = get_collection(vault)
chunk_count = collection.count()
except Exception as exc:
healthy = False
error = str(exc)
model = get_api_model(vault)
return {
"db_exists": exists,
"chunk_count": chunk_count,
"model": model,
"mode": "api",
"healthy": healthy,
"error": error,
}