AI assistant
Ask Stater questions about sales, stock and your own documents in plain words, with your own OpenAI-compatible provider and token.
See it in the tour: Ask Stater, the AI assistant
On this page
Ask Stater lets owners, managers and finance staff ask questions about the business in plain words: "How did sales this month compare with last month?", "What needs reordering at Main Street?", "What do the supplier terms say about late deliveries?". Answers come from the same data the person can already open, and from documents an owner uploaded, with numbered sources that link to the report, the page or the excerpt.
It is optional and off until an owner sets it up. Stater ships no token: each company brings its own from an OpenAI-compatible provider.
- Licence: Business and Enterprise (
ai_assistant). Without it, Insight › Ask Stater and Admin › AI assistant show what the plan includes. Documents already uploaded can still be listed and removed, and the assistant can be switched off. - Who asks: owners, store managers and finance staff (the
insight.assistantpermission). Sales assistants, the stockroom and viewers do not see it. - Who sets it up: owners (
admin.integrations, every store), in Admin › AI assistant.
Setting it up#
- Admin › AI assistant › Provider. The API address is pre-filled with
https://cloud.tuas.ai/v1; any OpenAI-compatible API works (it usually ends in/v1). - Paste your API token. It is saved encrypted under the server's secret key (see Secrets) and never shown again; the form only says that one is saved. Remove clears it.
- Load models lists what the provider offers (its
/models). Choose a chat model, which must support tool calling to look up sales and stock, and optionally an embeddings model for finding documents by meaning. A model the provider does not list can be typed in instead. - Under Privacy and limits, switch Assistant on and tick the box confirming that questions, and the business data needed to answer them, are sent to the provider's host. Save.
- Test connection checks the saved settings: it lists the models, asks the chat model for one word (with a tool offered, to see whether it can use lookups) and embeds one line when an embeddings model is chosen.
A saved token is only ever sent to the host it was saved for. Changing the address to another host needs the token typed again (or removed), and needs the privacy confirmation again before the assistant can stay on. Changing the token, testing the connection and turning on "On my own network" need someone signed in to the web app; API tokens are refused.
Providers#
Any API that speaks the OpenAI chat completions, models and embeddings endpoints: TUAS (the default), OpenAI, or a server on your own network such as vLLM or Ollama. For a server on your own network, switch on On my own network (or set STATER_AI_ALLOW_PRIVATE=true); plain http:// is then allowed too. STATER_PRIVATE_CONNECTORS=false turns private addresses off for the whole server. Link-local and cloud metadata addresses are refused always, and redirects are never followed.
A chat model without tool calling still answers from documents; the connection test says so.
Deployment settings#
A deployment can pin the provider with environment variables instead (see .env.example). Each one that is set is shown as "Set by the deployment" and cannot be changed in the app. None of them switches the assistant on: an owner still does that, and confirms the privacy notice.
| Variable | What it pins |
|---|---|
STATER_AI_BASE_URL |
The API address. |
STATER_AI_TOKEN / STATER_AI_TOKEN_FILE |
The token. Read from the environment, never written to the database. It is only sent to STATER_AI_BASE_URL, or to https://cloud.tuas.ai/v1 when that is not set: the address is then pinned too. |
STATER_AI_CHAT_MODEL |
The chat model. |
STATER_AI_EMBED_MODEL |
The embeddings model. |
STATER_AI_ALLOW_PRIVATE |
Lets the provider be on a private or loopback address, over http too. |
stater serve warns when a token is set without a chat model or without an address, and when the address is http:// without STATER_AI_ALLOW_PRIVATE.
When the deployment changes STATER_AI_BASE_URL to another host, the assistant stops until an owner ticks the privacy confirmation again for the new host.
What it can read#
The model never writes queries. It can only call these read-only lookups, each run as the person asking, through the same code as the pages, with their role and their stores. A manager only ever sees their own store; cost and margin appear only for roles that see cost; on hand is hidden from blind counters during a stock count; advanced reports still need their plan.
| Lookup | What it returns | Who |
|---|---|---|
business_overview |
Dashboard figures for 7, 30 or 90 days or 12 months, against the period before | owner, manager |
run_report |
One of the Insight reports, at most 30 rows plus totals | owner, manager |
today |
Today's figures and the work waiting | owner, manager |
find_products |
Products by name, SKU, barcode or brand, with stock | owner, manager |
low_stock |
Products to reorder, low or out of stock | owner, manager |
orders |
Open, problem, ready, ageing or recent orders | owner, manager |
purchase_orders |
Open, late or draft purchase orders | owner, manager |
money_summary |
Payments by method, cash-ups over tolerance, payables and receivables by age | owner, manager, finance |
customers_summary |
Customer counts and loyalty totals, never individuals | owner, manager |
search_documents |
Excerpts from uploaded documents | everyone who may ask |
Finance staff get the finance lookups (money_summary here; the finance reports add their own) rather than the shop-floor ones. A store a lookup is asked about must be one of the asker's stores. Each result is capped at about 8 KB, and one question may run at most 8 lookups over 4 turns.
Privacy#
- What is sent to the provider: the question, the last few messages of the chat, the lookup results needed to answer, and matching document excerpts. Nothing is sent until someone asks.
- Leave out customer names and contact details is on by default: orders and invoices are sent with the customer's reference (such as C-0042) instead of their name, email and phone, and the reports that name customers are refused. Staff names (in sales by staff and today's shifts) are sent.
- Document text is sent as it is. Do not upload documents with customer or staff personal details. Every person who can ask gets answers from every document.
- The confirmation names the provider's host, and is recorded with who gave it and when.
- Chats are visible only to the person who asked, signed in to the web app: API tokens cannot list or read them. They are deleted once unused for the retention period (90 days by default, 7 to 730). Every question is in the audit log (
assistant.ask, with the first 500 characters), which is kept like all audit. - The token never appears in a response, an event, the audit log or the server log. Provider failures are logged with the request id and the HTTP status only.
Limits and cost#
- Daily token limits for the company (200,000 by default) and per person (50,000), counted from midnight on the company's clock. 0 means no limit. Indexing documents and connection tests do not count towards them.
- At most 10 questions per person in five minutes (counted from the audit log, so deleting chats does not reset it), and one answer at a time per chat.
- Tokens are counted for every answer, including one that was stopped, failed or timed out (estimated from the text sent when the provider did not say), and also when the chat was deleted while it was answering.
- Answers are capped at "Longest answer" tokens (800 by default), take at most two minutes, and are given up when the provider sends nothing for 45 seconds.
- Usage is in tokens as the provider reports them, or estimated from the length of the text when it does not.
Documents#
Owners upload documents in Admin › AI assistant › Documents: PDF, Word (.docx), text, Markdown and CSV, up to 10 MB each, 500 documents and 50 MB of text in all. The text is read at once (an unreadable file is refused with the reason) and the file itself is not kept. A PDF that is a scanned image has no text to read: upload a text version.
Each document is cut into excerpts of about 1,200 characters, overlapping a little, under their nearest heading and page. With an embeddings model chosen, each excerpt is embedded through the same provider; the vectors are stored in Postgres (no extension needed) and searched in memory on each server. Questions use full-text search and, with embeddings, cosine similarity, merged by reciprocal-rank fusion. Without an embeddings model, documents are found by keyword only. Changing the embeddings model reads every document again. With an embeddings model, nothing is sent to the provider until the assistant is on and the privacy confirmation is given for its host: until then, uploaded documents wait as "pending".
Memory: each server holds the vectors of one model, reloaded when a document is added, removed or read again. At the limits (about 10,000 excerpts at 1,536 numbers each) that is about 60 MB per server.
A background worker on every server reads queued documents, one at a time each. A document that fails five times is marked failed with the reason; Read again queues it once more.
Prompt injection#
Text inside a document or a record (a product name, an order note) may try to give the model instructions. Stater limits what that can do rather than trusting the model to ignore it:
- Document excerpts and lookup results only ever reach the model as tool results, wrapped as numbered
<source>elements that their content cannot close. The system prompt says they are data, never instructions. - A lookup runs only when the model's own turn asks for one the person was offered, with its arguments checked by the server. Every lookup is read-only and returns only what the asker could open anyway. There is nothing that writes, sends a message or fetches an address.
- Answers are shown without HTML or images, and links come only from the server's own sources, pointing inside the app.
Answers can still be wrong: the page says to check important figures against the report, and every answer shows its sources.
Licence changes#
When the licence no longer includes the assistant, asking and uploading stop and it cannot be switched on. Documents already uploaded are kept; the worker that reads them stops once the licence's grace period is over. Switching off, deleting chats and removing documents always work. Nothing else in Stater depends on the assistant.
API#
All endpoints are under the "Assistant" tag in /api/docs.
GET/PUT /api/v1/settings/assistant,POST /api/v1/settings/assistant/models,POST /api/v1/settings/assistant/test: the settings (owners). The token is write-only: sendapi_tokento set it andclear_api_tokento remove it; responses sayapi_token_set.GET/POST /api/v1/assistant/documents,POST …/{id}/reindex,DELETE …/{id}: documents (owners). Upload the raw file asapplication/octet-streamwith?filename=.GET /api/v1/assistant/status,GET/POST /api/v1/assistant/chats,GET/PATCH/DELETE /api/v1/assistant/chats/{id},GET /api/v1/assistant/sources/{chunk_id}. These are for people signed in to the web app; API tokens get 403.POST /api/v1/assistant/chats/{id}/askwith{question, store_id}answers astext/event-stream:meta {chat_id, message_id},tool {name, label}while a lookup runs,delta {text}as the answer is written,sources {items},error {detail, request_id}anddone {message_id, status, content, usage}. A: pingcomment is sent every 10 seconds. Only for people signed in to the web app; API tokens get 403.
A proxy in front of Stater must not buffer this response; Stater sends X-Accel-Buffering: no.
When something goes wrong#
| Message | What to do |
|---|---|
| The AI provider refused the token. | Paste a new token in Admin › AI assistant and save. |
| That address does not look like an OpenAI-compatible API. | Use the API address, which usually ends in /v1. |
| The AI provider does not know that model. | Load the models again and choose one. |
| The AI provider is limiting requests. | Wait a minute; check the plan with your provider. |
| … is on a private or internal network … | Switch on "On my own network" for a server in your own network, or use a public address. |
| You have reached today's limit for the assistant. | Wait until midnight, or ask an owner to raise the daily limits. |
| Wait for the answer to your last question in this chat. | One answer at a time per chat; start a new chat or wait. |
| This PDF has no text we can read. | It is a scanned image; upload a text or Word version. |