AI Author
Sweetdocs's built-in AI: ask for an edit in plain English, the AI proposes a diff, you accept or discard. Powered by Gemini with document-editing tools.
AI Author edits the document for you. You write a prompt, the AI proposes a change as a diff, and the doc only updates after you click Accept. The AI has tool-level access to your text — it can replace a span, insert at an anchor, change the title, or rewrite the whole thing — but it can’t bypass the diff preview.
Opening the panel
| Method | What happens |
|---|---|
| Click AI in the doc toolbar | Side panel opens on the right |
| Press ⌘⇧A | Same panel, same shortcut anywhere in the app |
| Close: click the × in the panel header | Panel closes; the conversation stays on the doc |
The panel is bound to the active document. Switching documents aborts any in-flight request and clears pending state, so you can never accept a diff from one doc onto another.
Empty state and quick actions
When the panel opens with no conversation yet, you see six quick action chips that prefill a prompt for the most common requests:
| Chip | What it asks the AI to do |
|---|---|
| Improve writing | ”Improve the writing quality and clarity of this document.” |
| Make shorter | ”Make this document more concise without losing key information.” |
| Fix grammar | ”Fix all grammar, spelling, and punctuation errors.” |
| Add conclusion | ”Add a strong conclusion to this document.” |
| Summarize | ”Add a brief executive summary at the top of this document.” |
| Suggest title | ”Suggest and set a sharper title for this document.” |
Clicking a chip sends the prompt immediately. After the first message, the chips disappear — type freely in the input.
Writing a prompt
Plain English. The AI sees:
- The full document content
- The current title
- The document’s type
- Your prompt
You don’t need to copy text into the prompt — the AI already has it. Useful patterns:
- “Tighten the second paragraph, keep the bullet list intact.”
- “Rewrite the intro for a non-technical audience.”
- “Insert a section called ‘Pricing’ after the ‘Features’ heading.”
- “Change the title to something more action-oriented.”
The input grows up to 120 px tall as you type. Enter sends; Shift+Enter inserts a new line.
How the AI edits
Under the hood the AI has access to a small set of document-editing tools — it picks the right one for each change:
| Tool | What it does |
|---|---|
str_replace | Find a span of text, replace it |
insert_after | Insert content after a found anchor |
insert_before | Insert content before a found anchor |
append | Add content at the end of the doc |
prepend | Add content at the start of the doc |
set_title | Change the document title |
full_rewrite | Replace the entire document body |
If a tool returns “not found” or “ambiguous” (e.g., the anchor matches multiple places), the AI retries with a more specific anchor or explains what it needs.
You don’t see tool names in the UI — you see the resulting diff.
The diff preview
When the AI proposes a body change, the panel shows:
- Title change (if any): the old title with strikethrough and the new title in green, in their own card labeled “Title”
- Body change: a line-by-line diff card labeled “Changes” — removed lines in red with strikethrough, added lines in green, context lines in muted text
Below the diff, two buttons:
- Accept — applies the change to the live document. The change merges into the active editor at the line level (which means your collaborators see it through the same Yjs document; see Real-time collaboration).
- Discard — drops the diff. The conversation stays so the AI can follow up.
The doc never changes until you click Accept.
Doc switching and safety
The panel watches for document changes. If you switch documents while a request is in flight:
- The in-flight request is aborted
- Pending diffs are cleared
- The conversation resets
If you switch back later, the conversation for that doc is restored from history.
This is what stops a diff computed against doc A from accidentally applying to doc B.
Clearing the conversation
The Clear button in the panel header wipes the conversation for the current doc. The next message starts a fresh context — useful when the AI is stuck in a thread you don’t want to continue.
Errors
If the API returns an error (quota, network, server), it shows as a red error card inline in the conversation with the message body. The most common ones:
| Message | Means |
|---|---|
| Quota / rate-limit | You’ve hit the monthly AI quota for your plan (see Plans) |
| Document is too large | The doc exceeded the model’s context for a single request — try splitting it |
| Network / server error | Transient — retry the prompt |
What model is used
AI Author uses Google Gemini 3.5 Flash for chat. The endpoint is /api/ai/chat on our backend, which proxies to Gemini with our system prompt and the document-editing tools above. Gemini does not train on the prompts we send.
Some import paths (RTF conversion, PDF text extraction) use the same Gemini infrastructure on different endpoints; the chat doc here is specifically the AI Author panel.
What it can’t do (yet)
| Missing | Notes |
|---|---|
| Per-section selection prompts | The AI sees the whole doc and decides where to act — there’s no “edit just this paragraph” selection-scoped mode in v1 |
| Image generation / image edits | Not in v1 |
| Multi-doc context (cross-doc queries) | The AI only sees the active doc |
| Custom system prompts / per-doc personas | Not configurable in v1 |
| Streaming the diff as it generates | Diff appears as a single block when the AI finishes |