b5a203d2aa
- Add bulk delete, bulk tags, and bulk set-tags engine endpoints (POST /api/v1/bulk/delete, /bulk/tags, /bulk/set-tags) - Filter-based selection: by tags, doc_type, ID list, ID range - Safety threshold (KB_BULK_SAFETY_PERCENT, default 70%) prevents accidental mass operations unless force=true - Synchronous execution with audit trail via jobs table - Add kb_bulk_delete, kb_bulk_tags, kb_bulk_set_tags MCP tools - Add kb bulk-remove, bulk-tag, bulk-set-tags CLI commands - Remove collection abstraction from MCP server (use tags instead) - Remove kb_set_collection MCP tool - Update SKILL.md, MCP.md, README.md documentation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Engine configuration — all settings from environment variables."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
class Config:
|
|
data_dir: Path
|
|
model: str
|
|
device: str
|
|
ingest_device: str
|
|
api_key: str | None
|
|
host: str
|
|
port: int
|
|
|
|
def __init__(self):
|
|
self.data_dir = Path(os.environ.get("KB_DATA_DIR", "/data"))
|
|
self.model = os.environ.get("KB_MODEL", "all-MiniLM-L6-v2")
|
|
self.device = os.environ.get("KB_DEVICE", "auto")
|
|
self.ingest_device = os.environ.get("KB_INGEST_DEVICE", "auto")
|
|
self.api_key = os.environ.get("KB_API_KEY") or None
|
|
self.search_threshold = float(os.environ.get("KB_SEARCH_THRESHOLD", "0.01"))
|
|
self.bulk_safety_percent = int(os.environ.get("KB_BULK_SAFETY_PERCENT", "70"))
|
|
self.host = os.environ.get("KB_HOST", "0.0.0.0")
|
|
self.port = int(os.environ.get("KB_PORT", "8000"))
|
|
|
|
@property
|
|
def db_path(self) -> Path:
|
|
return self.data_dir / "kb.db"
|
|
|
|
@property
|
|
def hf_cache(self) -> Path:
|
|
return self.data_dir / "hf_cache"
|
|
|
|
@property
|
|
def staging_dir(self) -> Path:
|
|
return self.data_dir / "staging"
|
|
|
|
@property
|
|
def documents_dir(self) -> Path:
|
|
return self.data_dir / "documents"
|
|
|
|
def ensure_dirs(self):
|
|
self.data_dir.mkdir(parents=True, exist_ok=True)
|
|
self.hf_cache.mkdir(exist_ok=True)
|
|
self.staging_dir.mkdir(exist_ok=True)
|
|
self.documents_dir.mkdir(exist_ok=True)
|
|
|
|
|
|
cfg = Config()
|