Skip to main content

Module assistant

Module assistant 

Source
Expand description

Runs the built-in assistant for a user and records the run in the audit log (who, which action, question length, tools, tokens – never the question or the answer). See crate::assistant for the tool loop.

Structs§

ContextNote
The resolved page context of a question: what the chip and the thread show.
Run
The result of a run as the web UI and the API return it.

Constants§

MAX_LIMITS_CHARS
Longest “use as limits” note of the Fill with AI box, in characters.

Functions§

admin_overview
What Admin → AI shows: the local-agent switch (TEAMCRAFT_LOCAL_AGENTS) and the server-side assistant (provider, model, host, limits). Never the API key or the URL path – only whether a key is set. Pure, for tests.
ask
Asks the assistant. The tools run with the rights of me; the draft tools are only offered when question.allow_drafts is set and me may edit.
ask_with_page
A question in the user’s conversation (or, with thread false, a single question that sees the page but is not stored): resolves the page with the user’s rights, quotes the earlier messages of the conversation, runs the assistant with the user’s current rights and stores the new question and answer. page is what the client sent, unresolved.
chat
A request of the web sidebar or the REST API: validates the raw fields and the page context the client sent (context, see crate::pagecontext), then asks.
enabled
Whether the assistant is configured on this server.
fill_result_values
Fill with AI… on the Results card: asks the assistant to propose result values of a simulation revision from its reports, as drafts (never as results). wanted names the values to extract (empty = every key number), limits is the user’s own note on limits, files the report files to read (empty = all). Returns the run and the number of proposals it created.
is_report_file
Whether a file of a simulation can be a report the assistant reads (PDF, HTML or text; the extraction is textindex / htmltext / pdftext).
resolve_context
Resolves a page context that a client sent. The client’s identifiers are hints: every one of them goes through the read guards of services::access with the rights of me, and only what me may read stays. An identifier of a restricted group that me cannot see is dropped exactly like one that does not exist: the same queries run, the result looks the same and carries no trace of it. Texts typed on the page (query, filter values) are the user’s own and pass through.
switches
The interface switches the assistant runs under: its own, and external_llm unless the provider’s base URL is on the administrator’s internal list (TEAMCRAFT_ASSISTANT_INTERNAL_URLS).