chATLAS Frontend
Flask frontend for chATLAS, including Search mode, Assistant mode, streaming responses, usage logging, and intent-router enforcement.
- Production: https://chatlas-flask-chatlas.app.cern.ch
- Staging: https://chatlas-staging-chatlas.app.cern.ch
Router Architecture
The frontend includes an intent router that classifies every authenticated request before retrieval or answer generation. See Intent Router for the full reviewer-oriented design, function reference, rollout behavior, and test checklist.
At a high level, every routed request follows this sequence:
- Create one row in
queriesusingINSERT ... RETURNING id. - Load up to five previous query/response pairs for the thread.
- Call the LiteLLM router without passing the selected UI mode.
- Store one row in
router_decisionsfor the query. - Combine the returned intent with Search or Assistant mode.
- Run retrieval, return a terminal response, or fail open after a router error.
- Store sources and the response against the original query ID.
The active router intents are:
| Intent | Enforcement behavior |
|---|---|
hep_atlas |
Continue in the selected Search or Assistant mode |
person_lookup |
Return authoritative ATLAS directory guidance without retrieval |
dangerous |
Return a safety refusal without retrieval |
out_of_scope |
Explain the ATLAS/HEP scope without retrieval |
unknown |
Ask for clarification without retrieval |
MC-request routing is intentionally disabled until the dedicated MC workflow is
available. MC production and job-option prompts remain ordinary hep_atlas
requests and continue through the selected Search or Assistant mode.
Router errors are logged and fail open into the selected mode. Confidence is displayed and logged but is not used as a routing threshold. There is deliberately no separate router-demo application; local validation uses the real frontend so it exercises database logging, thread context, retrieval suppression, streaming, and the visible status experience.
Environment Variables
| Variable | Required | Purpose |
|---|---|---|
CHATLAS_DB_PASSWORD |
Yes | CERN DBOD vector-store and logging database password |
CHATLAS_EMBEDDING_MODEL_PATH |
Recommended locally | Local embedding-model directory; otherwise Hugging Face is used |
CHATLAS_OPENAI_KEY |
For the default Assistant model | OpenAI generation key |
CHATLAS_GROQ_KEY |
Only when selecting Groq | Groq generation key |
CHATLAS_GROQ_BASE_URL |
Only for the CERN Groq proxy | Groq-compatible endpoint |
CHATLAS_CHAINS_LITELLM_KEY |
Router on | CERN LiteLLM router key |
CHATLAS_CHAINS_LITELLM_PROXY |
Outside CERN network | SOCKS URL, normally socks5h://localhost:1080 |
CHATLAS_ROUTER_MODE |
No | off, shadow, or enforce; default off |
CHATLAS_ROUTER_MODEL |
No | Router model; default gpt-oss-20b |
CHATLAS_ROUTER_SHOW_STATUS |
No | Show router status text; default false |
FLASK_PORT |
No | Local HTTP port; default 8080 |
Never commit .env files or print secret values. GitLab variables and
OpenShift secrets are separate stores; configuring one does not configure the
other.
Local Full-Stack Test
These instructions run the actual frontend against CERN databases and
LiteLLM. Local mode bypasses OAuth and writes usage data to log_test, not
log_prod. Application startup creates or updates the logging tables,
including queries.thread_id and router_decisions.
You need a CERN account with LXPLUS access, the shared DBOD password, a CERN LiteLLM key, and a generation-model key. Ask the chATLAS developers through email or Mattermost if access is missing. Do not send secret values in issues, merge requests, or chat messages.
1. Install
From this directory:
uv sync --locked
2. Obtain the embedding model
On a machine with EOS access:
scp -r \
<USERNAME>@lxplus.cern.ch:/eos/atlas/atlascerngroupdisk/phys-mlf/Chatlas/multi-qa-mpnet-base-dot-v1-ATLAS-TALK \
/path/to/models/
Set CHATLAS_EMBEDDING_MODEL_PATH to the copied model directory.
3. Create a local .env
Create chATLAS_Frontend/.env locally:
CHATLAS_DB_PASSWORD=...
CHATLAS_EMBEDDING_MODEL_PATH=/absolute/path/to/multi-qa-mpnet-base-dot-v1-ATLAS-TALK
CHATLAS_OPENAI_KEY=...
CHATLAS_CHAINS_LITELLM_KEY=...
CHATLAS_ROUTER_MODE=shadow
CHATLAS_ROUTER_MODEL=gpt-oss-20b
CHATLAS_ROUTER_SHOW_STATUS=true
CHATLAS_CHAINS_LITELLM_PROXY=socks5h://localhost:1080
FLASK_PORT=8080
The repository .gitignore excludes .env.
CHATLAS_GROQ_KEY and CHATLAS_GROQ_BASE_URL are optional unless Groq is
selected in the UI.
4. Create CERN tunnels
Outside the CERN network, keep this command running:
ssh -N \
-L 6624:dbod-chatlas.cern.ch:6624 \
-L 6606:dbod-chatlas-cds.cern.ch:6606 \
-D 1080 \
<USERNAME>@lxplus.cern.ch
Port 6624 covers the main vector stores and log_test; port 6606 covers
CDS. The SOCKS proxy on 1080 carries LiteLLM traffic.
5. Launch
PYTHONPATH=.:../chATLAS_Chains:../chATLAS_Embed:../chATLAS_Scrape \
uv run --env-file .env python chATLAS_Frontend/launch.py \
--local-mode \
--db-host cern-prod \
--port-forwarding
Open http://127.0.0.1:8080.
The PYTHONPATH setting makes this source checkout use its sibling chATLAS
packages. Released deployments obtain those packages from their pinned
package dependencies.
If already on the CERN network, omit --port-forwarding, remove
CHATLAS_CHAINS_LITELLM_PROXY, and connect directly.
Local Test Plan
Start in shadow mode. Every request should still use the selected mode.
| Prompt | Expected router status |
|---|---|
How do I apply a GoodRunsList in Athena? |
ATLAS/HEP question |
Who is the current ATLAS spokesperson? |
Person lookup identified |
Draft an MC request for a ttbar sample. |
ATLAS/HEP question |
How do I bake sourdough bread? |
Out-of-scope request identified |
What about that? |
Clarification needed, unless prior context resolves it |
The grey status line summarizes the intent, selected mode when relevant,
confidence, and router availability. The response metadata and
router_decisions log contain the selected mode, effective workflow, status,
and rollout mode. Test the first prompt in both Search and Assistant modes.
Test context with:
How do I apply a GRL in Athena?What about Run 3?
Then change the local .env to:
CHATLAS_ROUTER_MODE=enforce
Restart the frontend so the environment-level setting is reloaded.
Verify that person_lookup, dangerous, out_of_scope, and unknown
produce terminal responses with no citations or retrieval results.
To test fail-open behavior without modifying a secret, temporarily set
CHATLAS_ROUTER_MODEL to a nonexistent model and restart. The UI should
report that the router is unavailable and continue in the selected mode.
Restore gpt-oss-20b after the test.
Automated Tests
Run the deterministic frontend routing tests:
PYTHONPATH=.:../chATLAS_Chains:../chATLAS_Embed:../chATLAS_Scrape \
uv run pytest tests/test_routing.py -q
Run the full frontend suite:
PYTHONPATH=.:../chATLAS_Chains:../chATLAS_Embed:../chATLAS_Scrape \
uv run pytest tests -q
The live LiteLLM smoke test is skipped unless explicitly enabled:
cd ../chATLAS_Chains
CHATLAS_RUN_LITELLM_SMOKE=1 \
uv run --env-file ../chATLAS_Frontend/.env \
pytest tests/test_router_litellm.py -q
The GitLab test_router_litellm job enables it automatically for merge
requests that change Chains or frontend backend code.
Reviewing Router Logs
Export routing decisions from the logging database:
uv run python chATLAS_Frontend/usage/execute_query.py \
--query router_decisions \
--db-host 127.0.0.1 \
--db-port 6624 \
--db-name log_test \
--output router_decisions.csv
Run this while the DBOD SSH tunnel is active. Omit the host and port overrides when connected directly from CERN.
The export includes query/thread IDs, intent, confidence, normalized query, reason, metadata, selected and effective workflows, model, prompt version, status, latency, error details, and rollout mode.
Updating Dependencies
Edit pyproject.toml, then update and verify the lockfile:
uv lock
uv sync --locked
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chatlas_frontend-1.1.0.tar.gz.
File metadata
- Download URL: chatlas_frontend-1.1.0.tar.gz
- Upload date:
- Size: 130.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abe84e2b0987224a5408f37dcbb0474caa96dcaad57ecac0688625ab0343fb53
|
|
| MD5 |
db7ce9a10b7f122ab868fd28991b5d51
|
|
| BLAKE2b-256 |
69d51573e5eedb9f357fd2220e6764a6308b72a6ad177c01f9d80361a49e5015
|
File details
Details for the file chatlas_frontend-1.1.0-py3-none-any.whl.
File metadata
- Download URL: chatlas_frontend-1.1.0-py3-none-any.whl
- Upload date:
- Size: 140.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbee931969f94c2276aa8118a524929cd7a98780872410cc71e1ea338e3a1bc7
|
|
| MD5 |
68e26192420d6b61516b469582c5a558
|
|
| BLAKE2b-256 |
eabec10ccb541767361d94006a1558b79fce9363ec6c4ab273cc63bf9101b3e9
|