-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
60 lines (48 loc) · 2.22 KB
/
Copy pathconfig.py
File metadata and controls
60 lines (48 loc) · 2.22 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
"""
Config
======
Single source of truth for env-driven configuration. Everything the app
reads from the environment lives here so the rest of the codebase never
touches `os.environ` directly.
"""
from __future__ import annotations
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# ----------------------------------------------------------------------------
# Storage paths
# ----------------------------------------------------------------------------
DATA_DIR = Path(os.getenv("DATA_DIR", "./data"))
USER_DB_PATH = DATA_DIR / "users.json"
SESSION_DB_PATH = DATA_DIR / "sessions.json"
DOCUMENTS_DIR = DATA_DIR / "documents"
CHROMA_PERSIST_DIR = Path(os.getenv("CHROMA_PERSIST_DIR", "./chroma_db"))
DATA_DIR.mkdir(parents=True, exist_ok=True)
DOCUMENTS_DIR.mkdir(parents=True, exist_ok=True)
CHROMA_PERSIST_DIR.mkdir(parents=True, exist_ok=True)
# ----------------------------------------------------------------------------
# Roles
# ----------------------------------------------------------------------------
ROLES = ["finance", "engineering", "admin"]
# ----------------------------------------------------------------------------
# Auth
# ----------------------------------------------------------------------------
SESSION_EXPIRY_SECONDS = int(os.getenv("SESSION_EXPIRY_SECONDS", "3600"))
MAX_FAILED_ATTEMPTS = 5
LOCKOUT_MINUTES = 10
PBKDF2_ITERATIONS = 100_000
# ----------------------------------------------------------------------------
# Rate limiting
# ----------------------------------------------------------------------------
RATE_LIMIT_MAX_REQUESTS = int(os.getenv("RATE_LIMIT_MAX_REQUESTS", "10"))
RATE_LIMIT_WINDOW_SECONDS = int(os.getenv("RATE_LIMIT_WINDOW_SECONDS", "60"))
# ----------------------------------------------------------------------------
# Embeddings
# ----------------------------------------------------------------------------
EMBEDDING_MODEL = os.getenv("EMBEDDING_MODEL", "all-MiniLM-L6-v2")
# ----------------------------------------------------------------------------
# Server
# ----------------------------------------------------------------------------
GRADIO_SERVER_NAME = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
GRADIO_SERVER_PORT = int(os.getenv("GRADIO_SERVER_PORT", "7860"))