-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
48 lines (39 loc) · 1.51 KB
/
config.py
File metadata and controls
48 lines (39 loc) · 1.51 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
from dotenv import load_dotenv
import os
# Load .env from project root (if present). This populates os.environ.
load_dotenv(".env")
def _int_env(name, default):
v = os.getenv(name)
try:
return int(v) if v is not None else default
except Exception:
return default
def _bool_env(name, default):
v = os.getenv(name)
if v is None:
return default
return v.lower() in ("1", "true", "yes")
# Expose a CFG dictionary for the rest of the app
CFG = {
"local_path": os.getenv("LOCAL_PATH"),
"venv_path": os.getenv("VENV_PATH"),
"api_url": os.getenv("API_URL"),
"api_key": os.getenv("API_KEY"),
"database_path": os.getenv("DATABASE_PATH", "codebase.db"),
"max_file_size": int(os.getenv("MAX_FILE_SIZE", "200000")),
# model names for external APIs (optional)
"embedding_model": os.getenv("EMBEDDING_MODEL"),
"coding_model": os.getenv("CODING_MODEL"),
# chunking parameters configurable via env
"chunk_size": _int_env("CHUNK_SIZE", 800),
"chunk_overlap": _int_env("CHUNK_OVERLAP", 100),
# uvicorn host/port (from .env)
"uvicorn_host": os.getenv("UVICORN_HOST", "127.0.0.1"),
"uvicorn_port": int(os.getenv("UVICORN_PORT", "8080")),
# FileWatcher configuration
"file_watcher_enabled": _bool_env("FILE_WATCHER_ENABLED", True),
"file_watcher_interval": _int_env("FILE_WATCHER_INTERVAL", 10),
"file_watcher_debounce": _int_env("FILE_WATCHER_DEBOUNCE", 5),
# Debug configuration
"debug": _bool_env("DEBUG", False),
}