Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
74 lines (52 loc) · 2.33 KB
/
Copy pathconfig.py
File metadata and controls
74 lines (52 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Centralized runtime configuration for Devbase.
Secrets are optional by default.
"""
from dataclasses import dataclass
from pathlib import Path
import os
from dotenv import load_dotenv
load_dotenv()
@dataclass(frozen=True)
class Settings:
hf_token: str
hf_llm_model: str
hf_embedding_model: str
hf_provider: str
github_token: str
github_repo_list: list[str]
braintrust_api_key: str | None
lightrag_live_dir: Path
lightrag_staging_dir: Path
lightrag_backup_dir: Path
n8n_quality_gate_webhook_url: str
n8n_setup_status_path: Path
audit_log_path: Path
ingestion_manifest_path: Path
def _required(name: str) -> str:
value = os.getenv(name)
if not value:
raise RuntimeError(f"Missing required environment variable: {name}")
return value
def _optional(name: str, default: str | None = None) -> str | None:
return os.getenv(name, default)
def load_settings(require_secrets: bool = True) -> Settings:
hf_token = _required("HF_TOKEN") if require_secrets else os.getenv("HF_TOKEN", "")
repo_list = os.getenv("GITHUB_REPO_LIST", "mockoon/mockoon")
repos = [repo.strip() for repo in repo_list.split(",") if repo.strip()]
return Settings(
hf_token=hf_token,
hf_llm_model=os.getenv("HF_LLM_MODEL", "meta-llama/Llama-3.1-8B-Instruct"),
hf_embedding_model=os.getenv("HF_EMBEDDING_MODEL", "sentence-transformers/all-MiniLM-L6-v2"),
hf_provider=os.getenv("HF_PROVIDER", "auto"),
github_token=os.getenv("GITHUB_TOKEN", ""),
github_repo_list=repos,
braintrust_api_key=_optional("BRAINTRUST_API_KEY"),
lightrag_live_dir=Path(os.getenv("LIGHTRAG_LIVE_DIR", "./storage/live")),
lightrag_staging_dir=Path(os.getenv("LIGHTRAG_STAGING_DIR", "./storage/staging")),
lightrag_backup_dir=Path(os.getenv("LIGHTRAG_BACKUP_DIR", "./storage/live_backup")),
n8n_quality_gate_webhook_url=os.getenv("N8N_QUALITY_GATE_WEBHOOK_URL", "http://localhost:5678/webhook/kb-updated"),
n8n_setup_status_path=Path(os.getenv("N8N_SETUP_STATUS_PATH", "./.devbase/n8n_setup.json")),
audit_log_path=Path(os.getenv("AUDIT_LOG_PATH", "./audit.jsonl")),
ingestion_manifest_path=Path(os.getenv("INGESTION_MANIFEST_PATH", "./ingestion_manifest.json")),
)
settings = load_settings(require_secrets=False)