Dan Flower commited on
Commit
d42f795
·
1 Parent(s): 53d10a6

WIP: local edits before pulling main

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. utils/.gitignore +1 -0
  3. utils/flags.py +33 -0
Dockerfile CHANGED
@@ -21,7 +21,7 @@ COPY requirements.txt ./
21
  RUN pip3 install --no-cache-dir -r requirements.txt huggingface_hub
22
 
23
  # Download model securely using huggingface_hub and HF_TOKEN
24
- COPY model/download_model.py model/download_model.py
25
  # RUN python3 model/download_model.py
26
 
27
  # Copy rest of app
 
21
  RUN pip3 install --no-cache-dir -r requirements.txt huggingface_hub
22
 
23
  # Download model securely using huggingface_hub and HF_TOKEN
24
+ COPY /Users/dan/AI-threat-labs/model/download_model.py /Users/dan/AI-threat-labs/model/download_model.py
25
  # RUN python3 model/download_model.py
26
 
27
  # Copy rest of app
utils/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  # .gitignore
2
  logs/
 
 
1
  # .gitignore
2
  logs/
3
+ labsold/
utils/flags.py CHANGED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # utils/flags.py
2
+ import os
3
+ from typing import Optional, Dict
4
+
5
+ # Optional: load .env if python-dotenv is available (local dev convenience)
6
+ try:
7
+ from dotenv import load_dotenv # type: ignore
8
+ load_dotenv()
9
+ except Exception:
10
+ pass # fine on HF Spaces; variables come from the environment
11
+
12
+ def _as_bool(val: Optional[str], default: bool) -> bool:
13
+ if val is None:
14
+ return default
15
+ return val.strip().lower() in {"1", "true", "yes", "on", "y", "t"}
16
+
17
+ # Public flags (read once at import time)
18
+ # Set SANITIZE_ENABLED default to False to avoid any behavior change unless enabled via env
19
+ SANITIZE_ENABLED = _as_bool(os.getenv("LAB_SANITIZE_ENABLED"), False)
20
+ STOPSEQ_ENABLED = _as_bool(os.getenv("LAB_STOPSEQ_ENABLED"), False)
21
+ CRITIC_ENABLED = _as_bool(os.getenv("LAB_CRITIC_ENABLED"), False)
22
+ JSON_MODE = _as_bool(os.getenv("LAB_JSON_MODE"), False)
23
+ EVIDENCE_GATE = _as_bool(os.getenv("LAB_EVIDENCE_GATE"), False)
24
+
25
+ def snapshot() -> Dict[str, bool]:
26
+ """Convenience for logging/diagnostics."""
27
+ return {
28
+ "LAB_SANITIZE_ENABLED": SANITIZE_ENABLED,
29
+ "LAB_STOPSEQ_ENABLED": STOPSEQ_ENABLED,
30
+ "LAB_CRITIC_ENABLED": CRITIC_ENABLED,
31
+ "LAB_JSON_MODE": JSON_MODE,
32
+ "LAB_EVIDENCE_GATE": EVIDENCE_GATE,
33
+ }