fix: llm_backend reads fallback_order, logs tee'd to data/.streamlit.log in Docker

This commit is contained in:
pyr0ball 2026-03-03 15:04:18 -08:00
parent 483ca00f1a
commit e9b389feb6
2 changed files with 13 additions and 3 deletions

View file

@ -4,6 +4,12 @@ services:
app: app:
build: . build: .
command: >
bash -c "streamlit run app/app.py
--server.port=8501
--server.headless=true
--server.fileWatcherType=none
2>&1 | tee /app/data/.streamlit.log"
ports: ports:
- "${STREAMLIT_PORT:-8501}:8501" - "${STREAMLIT_PORT:-8501}:8501"
volumes: volumes:

View file

@ -45,11 +45,15 @@ def collect_context(page: str) -> dict:
except Exception: except Exception:
pass pass
# LLM backend from llm.yaml # LLM backend from llm.yaml — report first entry in fallback_order that's enabled
llm_backend = "unknown" llm_backend = "unknown"
try: try:
llm = yaml.safe_load((_ROOT / "config" / "llm.yaml").read_text()) or {} llm = yaml.safe_load((_ROOT / "config" / "llm.yaml").read_text()) or {}
llm_backend = llm.get("provider", "unknown") backends = llm.get("backends", {})
for name in llm.get("fallback_order", []):
if backends.get(name, {}).get("enabled", False):
llm_backend = name
break
except Exception: except Exception:
pass pass
@ -65,7 +69,7 @@ def collect_context(page: str) -> dict:
def collect_logs(n: int = 100, log_path: Path | None = None) -> str: def collect_logs(n: int = 100, log_path: Path | None = None) -> str:
"""Return last n lines of the Streamlit log, with PII masked.""" """Return last n lines of the Streamlit log, with PII masked."""
path = log_path or (_ROOT / ".streamlit.log") path = log_path or (_ROOT / "data" / ".streamlit.log")
if not path.exists(): if not path.exists():
return "(no log file found)" return "(no log file found)"
lines = path.read_text(errors="replace").splitlines() lines = path.read_text(errors="replace").splitlines()