陪读蛙

提示词变量

陪读蛙提示词能用的每一个变量,以及它们实际被替换成什么。

变量写成 {{name}} 的形式。在请求发出之前,陪读蛙会把每个已知变量替换成一个字符串。其他内容一概不动:像 {{url}} 这样它不认识的名称,会作为 {{url}} 这几个字符留在提示词里。

下面的样例都来自同一个页面——https://devblog.example.com/posts/timestamps 上的一篇英文文章,正在被翻译成简体中文。

哪些变量在哪里可用

变量网页提示词字幕提示词
{{targetLanguage}}可用可用
{{input}}可用可用
{{webTitle}}可用可用
{{webDescription}}可用可用
{{webContent}}可用
{{webSummary}}可用
{{videoSummary}}可用

网页提示词里写 {{videoSummary}}、字幕提示词里写 {{webContent}},留下的都会是字面文本。编辑器每个字段下方的变量按钮,只提供这个列表填得上值的那些。

{{targetLanguage}}

你要翻译成的那门语言的英文名称——不是语言代码,也不会跟着界面语言翻译。

Simplified Mandarin Chinese

其他例子:EnglishTraditional Mandarin ChineseJapaneseSpanish。所以写成 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}} 就是那个段落——空文本压根不会发起请求。

接下来会发生什么

替换完的文本并不是请求的全部:之后还会追加规则块和你的术语,最终成型的结果会成为翻译缓存的键。见一次请求是怎么拼出来的

On this page