Add an AI assistant that answers from platform data #124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
gpt-oss:120bon Purdue RCAC GenAI Studio, which is free for us and has native tool calling. The model chooses from 44 read-only tools.dtCallas the signed-in user, so FastAPI and RLS enforce access as usual. Admin-only tools are offered only to admins.analyze_driftcompares recent runs with earlier ones per equipment, recipe or unit experiment, and definition version. It reportsconditions_changedwhen 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.get_download_linkbuilds links that download through/api/dt./api/mcpand/api/toolsstill expose exactly the original 12 tools.web/lib/assistant/genai.ts):nullrate-limit reply, a 429, a rejected key or a timeout, the request fails over to the other provider.ANVILGPT_ALLOW_PLATFORM_DATA=true, because RCAC authorizes it for public data only.web/lib/assistant/limits.ts): one question at a time, 10 per 5 minutes, 100 per day. All are adjustable by environment variables.Config
The new
dt-web-secretkeys are documented ingeddes/k8s/01-secrets.yaml.example. OnlyGENAI_API_KEYis required; everything else has defaults. If no key is set, the page shows "not configured".Testing
node --test web/lib/assistant/analysis.test.mjs);tsc,eslintandnext buildpass.nullreplies;gpt-oss:120bon GenAI Studio, run against mock platform data:Not in this PR
[MCP_AUDIT].🤖 Generated with Claude Code