Skip to content

Conversation

@ngholiza
Copy link
Collaborator

What this adds

Signed-in users can chat on /assistant (linked in the sidebar) and ask about the things they can already see on the platform: projects, members and workflow, experiment requests, runs, drift, samples and lineage, equipment, unit experiments, processes, recipes, computations, ML results, uploads and publication requests. For bulk data the assistant gives download links.

The assistant is read-only. It can't create, change or delete anything. When asked to, it says so and names the page to use. Write actions, such as equipment registration with a preview-and-confirm step, are planned for a later phase.

How it works

  • Model: gpt-oss:120b on Purdue RCAC GenAI Studio, which is free for us and has native tool calling. The model chooses from 44 read-only tools.
  • Access: every tool call goes through dtCall as the signed-in user, so FastAPI and RLS enforce access as usual. Admin-only tools are offered only to admins.
  • New tools:
    • analyze_drift compares recent runs with earlier ones per equipment, recipe or unit experiment, and definition version. It reports conditions_changed when input settings moved, and keeps the platform's own outlier flags separate. When it finds nothing, it returns hints so the model can retry with the right names.
    • Run trace summaries.
    • get_download_link builds links that download through /api/dt.
  • External endpoints unchanged: /api/mcp and /api/tools still expose exactly the original 12 tools.
  • Provider pool (web/lib/assistant/genai.ts):
    • Calls are spread round-robin across providers.
    • Each provider is kept within its requests-per-minute limit (GenAI Studio 20, AnvilGPT 60), with at most 8 requests in flight.
    • On RCAC's null rate-limit reply, a 429, a rejected key or a timeout, the request fails over to the other provider.
    • AnvilGPT is off unless ANVILGPT_ALLOW_PLATFORM_DATA=true, because RCAC authorizes it for public data only.
  • Per-user limits (web/lib/assistant/limits.ts): one question at a time, 10 per 5 minutes, 100 per day. All are adjustable by environment variables.
  • Chat UI:
    • Answers are rendered with a safe markdown renderer that only allows in-app links and https links.
    • Chats are stored only in the browser tab.
    • A caveat under the input says the assistant can make mistakes and that chats aren't saved on the platform.

Config

The new dt-web-secret keys are documented in geddes/k8s/01-secrets.yaml.example. Only GENAI_API_KEY is required; everything else has defaults. If no key is set, the page shows "not configured".

Testing

  • 18 unit tests (node --test web/lib/assistant/analysis.test.mjs); tsc, eslint and next build pass.
  • End-to-end runs against mock providers and a mock DT API. These covered:
    • the round-robin spread with no rate-limit hits;
    • the "busy" reply when every provider is full;
    • failover on a rejected key;
    • recovery from rate-limit null replies;
    • per-user limits;
    • the external MCP surface staying at 12 tools.
  • The real gpt-oss:120b on GenAI Studio, run against mock platform data:
    • It used the right tools, and its drift numbers matched the analysis output.
    • It refused write requests and named the right page.
    • Some answers still describe UI steps it can't see, which the caveat covers.
  • Codex reviewed every round until it approved.

Not in this PR

  • Write tools.
  • A database audit table. Tool calls are only logged to stdout as [MCP_AUDIT].
  • Per-user tokens for the external MCP endpoint. Today it uses one shared bearer token mapped to a fixed identity; this is tracked separately.

🤖 Generated with Claude Code

Signed-in users can chat on /assistant (linked in the sidebar) and ask
about their projects, runs, drift, samples, equipment, recipes,
computations and ML results, and get download links for data. The
assistant is read-only: it can't change anything, and when asked to it
names the page to use.

- The model is gpt-oss:120b on Purdue RCAC GenAI Studio. AnvilGPT can
  join the pool, but only with ANVILGPT_ALLOW_PLATFORM_DATA=true,
  because it is authorized for public data only. Calls are spread
  round-robin, each provider is kept within its requests-per-minute
  limit, and a rate-limited provider or rejected key fails over.
- Every tool call runs through dtCall as the signed-in user, so answers
  only contain data that user can see; admin tools are offered by role.
- There are 44 read tools. They include analyze_drift (recent vs earlier
  runs per equipment, cohort and definition version, with
  conditions_changed when inputs moved), run trace summaries and
  download links. The external MCP/OpenAPI endpoints still expose only
  the original 12 tools.
- Per-user limits: one question at a time, 10 per 5 minutes and 100 per
  day, adjustable by environment variables.
- The chat shows that the assistant can make mistakes. Chats are kept
  only in the browser tab, and the server logs the data lookups.
- The keyword planner is replaced. The new settings are documented in
  01-secrets.yaml.example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant