AI4SIDS-Gov · AI Systems / LLM / RAG Integration · Month 1
The LLM layer of the AI4SIDS-Gov platform architecture: how it works, how it connects to the platform and data services, what it depends on, and how K2–K7 will build it.
Summary. K1 specifies a single LLM layer for AI4SIDS-Gov, sitting inside the platform architecture already presented by the Engineer [R1]. It is assembled from components that already work in the project — the weather.ai.tt assistant, the staging-gov login and role model, and the DMU Reports checked-figures pipeline — so that it answers from approved documents and live data, shows where every number came from, and issues nothing without a person signing off.
TOR, Appendix I, §4: “Approved LLM/RAG/agentic architecture, interfaces, dependencies and implementation plan.”
| Required output | Where in this document | Status |
|---|---|---|
| LLM/RAG/agentic architecture | §3 Architecture, §4 Components reused, §5 Decisions D1–D8 | Delivered — decisions for approval |
| Interfaces | §6 Interfaces I1–I8 | Delivered |
| Dependencies | §7 Dependency register | Delivered |
| Implementation plan | §8 Plan K2–K7, §9 Risks | Delivered |
| Approval | §11 Sign-off; open items in §10 | Awaiting Technical Supervisor |
The Engineer has presented the overall AI4SIDS-Gov platform architecture [R1]. K1 is its LLM chapter: it does not choose the platform base, hosting or login system — those belong to the platform architecture — and it plugs into whichever base that architecture selects.
Responsibilities follow one layer each, so the backend is built once:
| Platform (Engineer) | logins, roles, audit trail, web app, releases |
| Data (Research Assistant) | ingestion, data services, backups |
| LLM (LLM Specialist) | assistant, RAG, tools, guardrails, evaluation |
From the DMCU AI use case & data requirements assessment [R4]:
Click any box for the decision or interface behind it.
Existing project code bases were reviewed [R7]. K1 reuses the strongest part of each and retires the rest.
The Government assistant: one agent, seven read-only tools over live river and weather data plus a document library, and charts built straight from the data.
Kept:
gpt-4.1; Qdrant with text-embedding-3-large.Gaps: logins and roles, a record of each request, streaming, document approval, document metadata, keyword search, and an evaluation that scores correctness on the production model. Topic and personal-data checks exist but are off by default.
A small, tested login and permissions layer: organisations, three roles, invite-only accounts, forced password change.
require_role check per route — an approver role for sign-off (I7) is one addition.Situation reports where every number is computed in code, cited and machine-checked before a person issues it.
member · dmu · admin.Research prototype: a router sends questions to five specialist prompts, whose functions already exist as weather.ai.tt tools.
| K1 item | Reuse | Adapt | Build new |
|---|---|---|---|
| Agent, tools, framework (D1, D3) | weather.ai.tt agent + 7 tools | per-role tool lists | — |
| Figures and citations (D5) | source/time on every figure; data-built charts | — | citation checker (port from DMU Reports) |
| Models (D2, I8) | Azure + local switch | registry | migration plan |
| Documents (D4, I6) | Qdrant ingestion | seed library of 12 | metadata, approval, keyword search, retrieval tests |
| Misuse controls (D6) | topic + personal-data checks | switch on, every channel | rate limits, cost alerts |
| Who is asking (I2) | staging-gov roles | merge with DMU Reports roles | pass into the LLM layer |
| Request record (I5), sign-off (I7) | — | — | both |
Each card states the proposed decision; options and evidence are behind the toggle.
| Candidate base | Brings | Lacks |
|---|---|---|
| weather.ai.tt | LLM core, live river/weather data, documents, deployment | Logins, request record |
| staging-gov | Logins, organisations, roles, tests | Live data, usable LLM code |
| DMU Reports | Real users, checked reports, logins | Live river/weather data, document search |
If DMU Reports remains a separate app, both reach the same LLM layer and each other's data through one defined interface; the DMU Reports data-module interface is the leading candidate.
| Model | Status | Note |
|---|---|---|
| Azure gpt-4.1 | In production | Roadmap item: move off it; data residency to confirm |
| AWS Bedrock nova-pro | Only Bedrock model tested that completes the full tool loop | Cheaper options (nova-lite, llama4-maverick) failed |
| Local model (llamafile) | On hold | Reported 8–10 minute replies and malformed output; needs GPU |
| Ollama / NVIDIA NIM | Used by DMU Reports | Included in the same registry |
Changing the embedding model requires re-indexing every document, so it is planned with the chat-model move. If no approved model is available, the app falls back to data-only mode (readings and alerts without AI wording).
Prompts move out of the code into versioned files, so wording changes are reviewed and re-tested.
Directly serves the Ministry's stated goal of AI-assisted SitReps from the 14 corporations, and its most time-critical, ~2-hour task [R4].
| Option | For | Against |
|---|---|---|
| Hydro-met + procedures in the ministerial SitRep (proposed) | Combines documents and live data as the TOR requires; builds on a workflow with real users; new capability; a path to ODPM. | Needs DMU Reports access and interface agreement. |
| New national briefing | Clear value. | DMU Reports already produces ministerial reports and hour briefings. |
| Corporation SitRep drafting | Clear need. | Already exists in DMU Reports. |
| River exceedance note | Simple. | Little document use; weaker TOR fit. |
RAG gives current, auditable answers with sources. Training a model is outside the TOR's role boundaries and would need a Clause 8 amendment.
Agreements between the LLM layer, the platform and the data services. Shapes are draft contracts; endpoint names are illustrative.
Extends today's response (reply, sources, charts, observations, provider used) with structured figures, a trace id, streaming and a request time limit.
POST /api/v1/assistant/chat
{ "conversation_id": "uuid", "message": "Is the Caroni rising?", "channel": "web" }
200 (streamed: token · fact · citation · done)
{ "answer": "markdown",
"facts": [ { "label": "Caroni at Piarco", "value": 3.42, "unit": "m",
"observed_at": "…-04:00", "source": "wra:station/…",
"status": "provisional" } ],
"citations": [ { "source_id": "doc-017", "title": "…", "version": "…",
"page": 12, "chunk_id": "…" } ],
"tools_used": ["get_wra_station_history"], "provider": "azure:gpt-4.1",
"refused": false, "trace_id": "…" }Every request carries the user's identity and role, read from the database on each request (staging-gov pattern); DMU Reports roles fold into the same list.
{ "user_id": "…", "org_id": "…",
"role": "admin | dmu | org_admin | member | approver", "session_id": "…" }Read-only endpoints for the LLM tools. Every response states when the data was observed, where it came from and its status.
GET /api/v1/data/river/stations
GET /api/v1/data/river/readings?station=…&from=…&to=…
GET /api/v1/data/weather/alerts/latest
GET /api/v1/data/weather/forecast
GET /api/v1/data/sitreps/{id}/facts?status=validated
every response: { "data": …, "as_of": "…", "source": "…", "status": "…" }Typed inputs, a time limit, one retry, a cache matched to the data's refresh rate (river 30 min, weather 2 h), and a structured error the model can explain instead of guessing.
ok: { "data": …, "as_of": "…", "source": "…", "status": "…" }
error: { "code": "timeout | unavailable | stale | forbidden",
"retry_after_s": 30, "message": "No river data since 14:30" }New. One record per request: who asked, which model answered, what the checks decided, which tools ran, what was cited, how long it took. Serves auditing (K4) and monitoring (K5).
{ "trace_id", "user_id", "role", "channel", "provider",
"topic_check": "pass|block", "personal_data": "none|found→local|found→refused",
"tools": [ { "name", "ms", "status" } ], "citations": [ "chunk_id" ],
"tokens_in", "tokens_out", "latency_ms", "cost_estimate", "prompt_version" }Documents arrive through the existing S3 → SQS → Dagu path; nothing is searchable until it carries these fields and is approved.
required: source_id, title, owner, version, effective_date,
supersedes (optional), approval_status, data_classNew. Fixed states; only an approver can approve or issue; every step goes to the request record with the draft-to-final changes. Mirrors DMU Reports' “needs review”.
draft → in_review | needs_review → approved | rejected → issued approve/issue: role = approver · issued = read-only
Replaces today's fixed two-option setting with one list of every model the system may use and what data it may receive.
{ "id": "azure:gpt-4.1", "max_context": …, "tool_calling": true,
"data_classes": ["public", "internal"] }
{ "id": "local:<model>", "tool_calling": true,
"data_classes": ["public", "internal", "personal"], "enabled": false }Registered under TOR §4A; any slippage is notified in writing to the Technical AI Lead and Project Manager.
| Needed | From | By | Unblocks |
|---|---|---|---|
| Model hosting approved for Government data; data residency | PI / Ministry | Month 2 | K2 |
| Approved knowledge sources (SOPs, policies, sample reports) | Supervisor / DMCU | Month 2 | K2 |
| Data-sharing agreement for Ministry data | PI / Ministry (ODPM & CEDMA approve access) | Month 3 | K3, K4 |
| Data services contract v1 (I3) | Research Assistant | mid-Month 2 | K3 |
| Test environment + automated checks | Engineer | Month 2 | K2 demo |
| Logins, roles and audit trail (I2, I5) | Engineer | mid-Month 3 | K4 |
| DMU Reports code access and data-module interface | DMU Reports developer | Month 2 | D5, K4 |
| Model migration target and embedding plan | Technical AI Lead / PI | Month 2 | D2, K2 |
| Local model: revive or drop | Technical team | Month 2 | personal-data routing |
| Deliverable | Timing | Output |
|---|---|---|
| K1 | Month 1 | This specification — submitted |
| K2 | Month 2 | Retrieval test set; document metadata and approval; RAG answers with citations; evaluation report against the adopted pass marks |
| K3 | Month 3 | LLM tools over the data services (I3, I4) with validation, failure handling and freshness rules |
| K4 | Month 4 | Ministerial SitRep enriched with live data and procedures; citation check; sign-off (I7); request record (I5) |
| K5 | Months 5–6 | Quality, guardrail, failure/security and observability evidence across releases |
| K6 | Month 7 | Integrated code, documentation and runbooks; handover to the Research Assistant, who continues to Month 18 |
| K7 | Month 8 | Capacity-building workshop, run jointly with the platform workshop |
Figures from data (D5), citation checker on every answer, refusal past a staleness threshold, figure checks on every release.
Retrieval test set first (D4); no quality claims until it passes on the approved library.
Approval before indexing (D6), read-only tools, attack documents in every test run.
Detection before the model; refusal while the local model is on hold; tested in both configurations.
Development uses fictional or exported test data until the agreement exists; registered as a dependency (§7).
Model registry (I8) keeps providers swappable; data-only fallback.
Rate and per-user limits, budget alert, bounded data per request.
One layer per role as set out in the platform architecture [R1]; one application, one database, one migration history.
Submitted as Deliverable K1 under the Terms of Reference, Appendix I, for technical acceptance and certification for payment.