Commit graph

10 commits

Author SHA1 Message Date
6ecc5d9df7 Mitigate prompt injection via user-message wrapping + explicit guard
None of the prompts that embed the raw user message (classify_intent,
direct_response, synthesize_response, and the RAG grade/rewrite/generate
steps) distinguished user-typed content from instructions to the model.

Wrap the user message in a <user_message> tag
(app/llm.py::wrap_user_input, added in the previous commit) and prepend
PROMPT_INJECTION_GUARD, an explicit instruction telling the model to
treat that block strictly as data, never as commands - even if it
claims system/developer/admin authority. wrap_user_input also strips
any literal occurrence of the tag from the input so a crafted message
can't fake a closing tag and escape the wrapper.

This is a meaningful mitigation, not a hard guarantee - documented as
such in the README's "Known limitations" section.

Refs #15
2026-11-09 22:01:10 +01:00
4956b401a3 Streamlit UI polish: native theming, multi-chat sessions, follow-ups
Fix the dark/brownish custom theme by dropping the custom [theme] config
entirely and relying on Streamlit's native light/dark switcher instead (a
custom theme block hides that switcher outright - confirmed by reading
the compiled frontend JS). Only the native "Deploy" toolbar button is
hidden now, via scoped CSS on its own test id.

Move the example questions above the chat input and auto-hide them once
a real message is sent in that session (rendered through
components.v1.html so its script can reach across to the chat input's
textarea directly and react live to theme switches via a
MutationObserver, instead of st.markdown which strips <script> tags).

Add per-session chat management in the sidebar: a "New chat" row at the
bottom of the session list with sessions listed above it, a delete icon
per session, and move the Config/connection info out of the main page
into a dialog. Removed emojis from the UI.

Also add a lightweight answer follow-up feature: after each answer, the
LLM suggests up to 3 clickable follow-up questions
(app/llm.py::generate_followups), rendered with the same clickable-card
component as the examples, plus a thumbs up/down st.feedback widget per
answer (display-only for now, not wired to anything yet).
generate_followups introduces wrap_user_input/PROMPT_INJECTION_GUARD in
app/llm.py, which the next commit reuses for the rest of the prompts.

Refs #14
2026-11-09 22:00:45 +01:00
77b5980fe2 Switch to qwen2.5:14b on GPU (RTX 5070 Ti), fix routing regression
Once a GPU became available, switched the default model from
llama3.2:3b (CPU) to qwen2.5:14b (GPU): added an NVIDIA GPU reservation
to the ollama service in docker-compose.yml and updated the default
OLLAMA_MODEL in config.py/.env.example.

Re-running the eval surfaced a new regression: the out-of-scope
"weather" question got classified as policy_question by the new model.
Fixed by adding an explicit negative example to _CLASSIFY_PROMPT.

Archived the llama3.2:3b eval/load-test reports under
eval/results/llama3.2-3b/ and re-ran both suites against qwen2.5:14b,
documenting the comparison in the README (accuracy 11/16 -> 12/16,
~4.3x latency improvement, see sections 5.1/6.1).

Refs #13
2026-11-08 22:09:55 +01:00
bebed6f0ee Fix prompt bugs found during live Ollama testing (llama3.2:3b)
Two real bugs surfaced only once tested against a real local model instead
of the stub LLM used in unit tests:

1. _CLASSIFY_PROMPT contained a literal "YYYY-MM-DD" placeholder in its
   JSON example, which the model echoed back verbatim, crashing the
   leave-balance calculator on a plain policy question. Fixed with a
   concrete sample date and an explicit restriction on when leave_balance
   applies.
2. _SYNTHESIZE_PROMPT didn't forbid inventing a source URL, so the model
   hallucinated a fake hyperlink for an internal filename citation. Fixed
   with an explicit instruction not to invent URLs.

Also stop ignoring eval/results reports and commit the real functional eval
+ load test results from the live Docker Compose + Ollama stack (11/16,
see README section 5-6).

Refs #12
2026-11-08 15:45:36 +01:00
951a72c88e Main agentic graph: intent classification and task routing
Refs #7
2026-11-06 16:22:20 +01:00
d957e6bcdf Corrective RAG subgraph
Refs #6
2026-11-06 13:00:16 +01:00
cf992cd45b RAG ingestion pipeline and FAISS vectorstore
Refs #5
2026-11-06 10:01:40 +01:00
27082c02d5 Deterministic tools: PTO calculator and support ticketing
Refs #4
2026-11-05 22:55:52 +01:00
568cc2572e Agent scaffolding: config, state schema, tracing
Refs #3
2026-11-05 22:02:14 +01:00
120301cb8d Add synthetic internal policy corpus for the RAG knowledge base
Refs #2
2026-11-05 18:01:48 +01:00