TraceAvatar
Menu

Docs

AI suggestions

Captions, waits and titles through your backend.

The studio can ask an AI for captions, waits (for the texts the app showed after a step, such as “Saved”) and a title. Each suggestion shows as before → after with Accept and Reject; nothing changes until the author accepts. With no ai, nothing calls a model.

In the page: call your backend
mount({ guides: '/guides/index.json', record: { allowed, save, ai: (task, input, schema, o) =>
  fetch('/api/guide-ai', { method: 'POST', body: JSON.stringify({ task, input, schema, instructions: o.instructions }) })
    .then((r) => r.json()) } });

Providers, on the server

server.js
import { suggest, apply, openAiCompatible, gemini, gateway } from 'trace-avatar/assist';

const ai = openAiCompatible({ baseUrl: 'https://api.deepseek.com', key: process.env.DEEPSEEK_API_KEY,
                              model: 'deepseek-chat', visionModel: 'deepseek-flash' });
// any OpenAI-compatible server works: OpenAI, Ollama, OpenRouter, vLLM…
// gemini({ key, model: 'gemini-2.5-flash' }), or gateway({ url, key }): DeepSeek, then Gemini, then OpenAI

const { suggestions } = await suggest('captions', trace, { ai, tone: 'terse' });
const next = apply(trace, suggestions);   // or only the ones a person accepted

Failed calls are retried twice (a 429, a 5xx or no answer, following Retry-After). firstOf(a, b, …) tries providers in turn.

What is sent, and what never is

  • Sent: step types, the role and accessible name of each step’s element, page paths, existing captions and timing; for waits, the short texts that appeared after each step.
  • Never: what was typed (unless you pass sendTyped: true, and never a masked field’s), selectors, or text inside fields, masked areas and [data-trace-blur].
  • preview(task, trace) returns the exact payload; the studio shows it under “What’s sent”.
  • Answers are checked: a caption is at most 140 characters, a wait only uses a text the page really showed, and the trace must stay valid.

The full reference is in the README on GitHub.