mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
feat(embedding): add get_embed_status() for API-only mode
This commit is contained in:
parent
755fcf2cd1
commit
32d5622ff7
1 changed files with 39 additions and 0 deletions
39
paperforge/embedding/status.py
Normal file
39
paperforge/embedding/status.py
Normal 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,
|
||||
}
|
||||
Loading…
Reference in a new issue