Home · Docs · AI · AI Author

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

MethodWhat happens
Click AI in the doc toolbarSide panel opens on the right
Press ⌘⇧ASame panel, same shortcut anywhere in the app
Close: click the × in the panel headerPanel 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:

ChipWhat 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:

You don’t need to copy text into the prompt — the AI already has it. Useful patterns:

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:

ToolWhat it does
str_replaceFind a span of text, replace it
insert_afterInsert content after a found anchor
insert_beforeInsert content before a found anchor
appendAdd content at the end of the doc
prependAdd content at the start of the doc
set_titleChange the document title
full_rewriteReplace 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:

Below the diff, two buttons:

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:

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:

MessageMeans
Quota / rate-limitYou’ve hit the monthly AI quota for your plan (see Plans)
Document is too largeThe doc exceeded the model’s context for a single request — try splitting it
Network / server errorTransient — 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)

MissingNotes
Per-section selection promptsThe 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 editsNot in v1
Multi-doc context (cross-doc queries)The AI only sees the active doc
Custom system prompts / per-doc personasNot configurable in v1
Streaming the diff as it generatesDiff appears as a single block when the AI finishes