提示詞變數
陪讀蛙提示詞能用的每一個變數,以及它們實際被取代成什麼。
變數寫成 {{name}} 的形式。在請求送出之前,陪讀蛙會把每個已知變數取代成一個字串。其他內容一概不動:像 {{url}} 這樣它不認識的名稱,會作為 {{url}} 這幾個字元留在提示詞裡。
下面的範例都來自同一個頁面——https://devblog.example.com/posts/timestamps 上的一篇英文文章,正在被翻譯成簡體中文。
哪些變數在哪裡可用
| 變數 | 網頁提示詞 | 字幕提示詞 |
|---|---|---|
{{targetLanguage}} | 可用 | 可用 |
{{input}} | 可用 | 可用 |
{{webTitle}} | 可用 | 可用 |
{{webDescription}} | 可用 | 可用 |
{{webContent}} | 可用 | — |
{{webSummary}} | 可用 | — |
{{videoSummary}} | — | 可用 |
網頁提示詞裡寫 {{videoSummary}}、字幕提示詞裡寫 {{webContent}},留下的都會是字面文字。編輯器每個欄位下方的變數按鈕,只提供這個清單填得上值的那些。
{{targetLanguage}}
你要翻譯成的那門語言的英文名稱——不是語言代碼,也不會跟著介面語言翻譯。
Simplified Mandarin Chinese其他例子:English、Traditional Mandarin Chinese、Japanese、Spanish。所以寫成 Translate to {{targetLanguage}}: 的提示詞,到達模型時是 Translate to Simplified Mandarin Chinese:。
{{input}}
待翻譯的文字。這是唯一一個提示詞缺不了的變數。
一次一個段落——首尾空白已去除,不可見字元已剔除:
Every timestamp you store without a zone is a bug waiting for a plane ticket.一次多個段落,這是在 LLM 服務商上開啟批次翻譯後的實際情形。段落之間用一列只有 %% 的內容連接,兩側各留一個空行:
Every timestamp you store without a zone is a bug waiting for a plane ticket.
%%
The fix is boring: store UTC, render local, and never let the two meet in a database column.
%%
Ordering by a naive timestamp works until the clocks change, and then it works wrongly.模型需要按同樣的順序回傳同樣數量的段落,用同樣的方式分隔。陪讀蛙會按這些 %% 列把回覆重新切開。如果你改寫提示詞時換掉了分隔符號,或者要求模型給段落編號、把段落合併,切分就會失敗,整批會先重試、然後逐段重送。
帶 HTML 時,也就是段落裡含有行內標記的情況。必須保住的屬性會被摘出來,元素改掛一個 data-rf-attr 標記,於是模型看到的是一個記號而不是網址:
The fix is <a data-rf-attr="0">boring</a>: store <code data-rf-attr="1">UTC</code>, render local.帶公式或行內符號時,它會被換成一個帶編號的佔位符,翻譯回來之後再把原元素複製回對應位置:
Converting is just {{0}}, which is why nobody gets it wrong twice.寫提示詞的時候你一般看不到後面這兩種形態,但它們解釋了請求裡為什麼會多出一些規則區塊:只有當本次送出的文字裡真的含有
data-rf-attr 標記或帶編號的佔位符時,陪讀蛙才會追加對應的說明。
{{webTitle}}
頁面的 <title>,和瀏覽器分頁上顯示的一模一樣。
Why your timestamps are eight hours off — devblog在字幕提示詞裡,這裡換成影片的標題。
{{webDescription}}
頁面自己宣告的描述,按 <meta name="description">、<meta property="og:description">、<meta name="twitter:description"> 的順序取第一個有內容的。
A short tour of the three places a naive timestamp can go wrong, and the one rule that prevents all three.在字幕提示詞裡,這裡換成影片的描述。
{{webContent}}
頁面正文,先擷取成 Markdown,再截到前 2000 個字元。導覽、側欄和頁尾會被丟掉。沒有任何內建提示詞用到它——它是留給那些光有標題不夠用的提示詞的。
# Why your timestamps are eight hours off
Every timestamp you store without a zone is a bug waiting for a plane ticket.
It works on your laptop, it works in CI, and it fails the first time somebody
in another country opens the report.
## Three places it goes wrong
1. **At the boundary.** A form posts `2026-03-14 09:00` and the server decides
what that means.
2. **In the column.** `timestamp without time zone` is not a moment in time; it
is a picture of a wall clock.
3. **On the way out.** Formatting in UTC and labelling it local is the same bug
wearing a hat.
The fix is boring: store UTC, render local, and never let the tw截斷是純按字元數算的,不看句子或段落邊界,所以取值通常正好斷在詞的中間——上面這段就是。如果你的提示詞告訴模型這份正文是完整的,那麼在任何超過一兩螢幕的頁面上,這句話都是錯的。
{{webSummary}}
由你的 LLM 服務商寫出的網頁摘要——這是一次單獨的模型呼叫,按頁面快取,只產生一次,然後供這個頁面的每個段落重複使用。
A technical blog post arguing that timestamps should be stored in UTC and rendered in the reader's local zone. It identifies three failure points — form input, database column type, and output formatting — and recommends a single rule for all three. Written for backend developers; uses PostgreSQL column types as examples.它需要開啟 AI 智慧上下文翻譯(設定 → 網頁翻譯)。關閉時沒有摘要可插入,這個變數會變成下面那張表裡的備援字串。預設提示詞用到了 {{webSummary}},所以不開智慧上下文的話,預設系統提示詞裡永遠寫著 Webpage summary: No summary available。
{{videoSummary}}
字幕側的對應物:影片摘要,同樣需要 AI 智慧上下文,關閉時同樣是備援字串。
A conference talk on time zone handling in web applications. The speaker walks through a production incident caused by naive timestamps, then demonstrates a UTC-in, local-out pattern. Names mentioned: PostgreSQL, Temporal, Luxon.取不到值的時候
變數不會留空,也不會消失。如果值缺失、為空、或只有空白字元,陪讀蛙會取代成一句固定的英文:
| 變數 | 實際取代成的內容 |
|---|---|
{{webTitle}} | No title available |
{{webDescription}} | No description available |
{{webContent}} | No content available |
{{webSummary}}、{{videoSummary}} | No summary available |
所以在一個沒有任何中介資料、又關掉了智慧上下文的頁面上,預設系統提示詞到達模型時是這樣的:
## Document Metadata for Context Awareness
Webpage title: No title available
Webpage summary: No summary available這一點在你寫少樣本範例(few-shot)時影響最大。一個用網頁標題拼出範例的提示詞,在沒有標題的頁面上,展示給模型的會是一個叫 "No title available" 的頁面的範例——而模型會去翻譯或評論這句話。如果你的提示詞依賴某個中介資料變數,就在提示詞裡寫清楚:取值是 "No ... available" 時該怎麼辦。
{{input}} 和 {{targetLanguage}} 沒有備援值。{{targetLanguage}} 永遠有值,而 {{input}} 就是那個段落——空文字根本不會發起請求。
接下來會發生什麼
取代完的文字並不是請求的全部:之後還會追加規則區塊和你的術語,最終成型的結果會成為翻譯快取的鍵。見一次請求是怎麼拼出來的。
