POML 组件综述(基于官方 Components 页面)
基于官方文档页面:microsoft.github.io/poml/stable…
本文对 POML 的组件体系做结构化梳理,仅总结该页面已给出的信息,不做超出原文的推断或扩展。为便于查阅,全文按类别分节,并在文末整理了页面中多处出现的“通用参数”。
目录
- 基础组件(Basic Components)
- 意图组件(Intentions)
- 数据展示(Data Displays)
- 实用工具(Utilities)
- 常见参数汇总(页面多处出现)
- 总结
基础组件(Basic Components)
以下组件主要面向文本与排版(含少量多媒体):
-
【Audio
<audio>】在内容中嵌入音频。- 典型用法:
<Audio src="path/to/audio.mp3" /> - 主要参数(页面列示):
src(文件路径)、base64、type(MIME)、alt、position(top/bottom/here)、syntax(含 multimedia)。
- 典型用法:
-
【Bold
<b>】在标记语法中加粗强调。- 典型用法:
<p><b>Task:</b> Do something.</p>
- 典型用法:
-
【CaptionedParagraph
<cp>】带自定义标题的段落。- 典型用法:
<cp caption="Constraints"> <list> <item>Do not exceed 1000 tokens.</item> <item>Please use simple words.</item> </list> </cp>
- 典型用法:
-
【Code】代码片段或行内代码。
- 典型用法:
<code inline="true">const x = 42;</code> <code lang="javascript"> const x = 42; </code>
- 典型用法:
-
【Header
<h>】标题(自动计算层级)。如需嵌套配合SubContent <section>。- 典型用法:
<Header syntax="markdown">Section Title</Header>
- 典型用法:
-
【Inline
<span>】行内容器。序列化语法下不建议单独使用。- 典型用法:
<p>I'm listening to <span>music</span> right now.</p>
- 典型用法:
-
【Italic
<i>】斜体强调。- 典型用法:
Your <i>italicized</i> text.
- 典型用法:
-
【List
<list>】与【ListItem<item>】列表与列表项。- 典型用法:
<list listStyle="decimal"> <item>Item 1</item> <item>Item 2</item> </list> listStyle可选:star/dash/plus/decimal/latin。
- 典型用法:
-
【Newline
<br>】显式换行(序列化语法忽略)。- 典型用法:
<br /> - 参数:
newLineCount(换行数)。
- 典型用法:
-
【Paragraph
<p>】独立段落(前后有空行)。- 典型用法:
<p>Contents of the paragraph.</p>
- 典型用法:
-
【Strikethrough
<s>,<strike>】删除线。- 典型用法:
<s>This messages is removed.</s>
- 典型用法:
-
【SubContent
<section>】嵌套内容区块,内部标题会自动下降一级。- 典型用法:
<h>Section Title</h> <section> <h>Sub-section Title</h> <p>Sub-section details</p> </section>
- 典型用法:
-
【Text
<text>,<poml>】包裹任意内容的根级容器。- 行为要点:默认
markdown;若未显式提供根元素,会根据首元素类型自动补充:- 首元素为纯文本 → 自动补
<poml syntax="text"> - 首元素为组件 → 自动补
<poml syntax="markdown">
- 首元素为纯文本 → 自动补
- 典型用法:
<poml syntax="text"> Contents of the whole prompt. </poml> <poml syntax="markdown" speaker="human"> <p>You are a helpful assistant.</p> <p>What is the capital of France?</p> </poml> <!-- 实验性限制与优先级示例 --> <poml syntax="markdown" tokenLimit="10"> <p priority="1">This has lower priority and may be truncated first.</p> <p priority="3">This has higher priority and will be preserved longer.</p> </poml>
- 行为要点:默认
-
【Underline
<u>】下划线。- 典型用法:
This text is <u>underlined</u>.
- 典型用法:
意图组件(Intentions)
围绕“表达意图/任务/格式”的指令型组件:
-
【Example】示例上下文,帮助模型理解期望的输入输出或风格。
- 典型用法:
<example> <input>What is the capital of France?</input> <output>Paris</output> </example>
- 典型用法:
-
【ExampleInput
<input>】示例输入(默认在 chat 上下文为 human 说话者,可手动指定)。 -
【ExampleOutput
<output>】示例输出(默认在 chat 上下文为 ai 说话者,可手动指定)。 -
【ExampleSet
<examples>】示例集,可统一标题与 chat 格式,支持可选introducer。- 典型用法:
<examples chat={{true}}> <example> <input>What is the capital of France?</input> <output>Paris</output> </example> <example> <input>What is the capital of Germany?</input> <output>Berlin</output> </example> </examples>
- 典型用法:
-
【Hint】给出简短提示/解释,引导模型。
- 典型用法:
<hint>Alice first purchased 4 apples and then 3 more, so she has 7 apples in total.</hint>
- 典型用法:
-
【Introducer】位于长段落(常为示例/步骤/指令列表)之前的引入语。
-
【OutputFormat
<output-format>】约束输出格式(如 JSON、XML、CSV,或“故事/图表/步骤”等一般格式)。 -
【Question
<qa>】问答组合,通常置于末尾;问题后附“Answer:”提示以引导回答。 -
【Role】指定模型角色(如 data scientist 等)。
-
【StepwiseInstructions】逐步说明/指令列表容器。
- 典型用法:
<stepwise-instructions> <list> <item>Interpret and rewrite user's query.</item> <item>Think of a plan to solve the query.</item> <item>Generate a response based on the plan.</item> </list> </stepwise-instructions>
- 典型用法:
-
【Task】简洁明确的任务说明,必要时可包含步骤列表。
数据展示(Data Displays)
呈现外部文档、图片、对象数据与表格:
-
【Document】显示外部文档(PDF/TXT/DOCX)。
- 要点:
src/buffer/base64;parser(auto/pdf/docx/txt);multimedia(是否展示真实多媒体,默认 true);PDF 可用selectedPages(如2或2:4)。 - 典型用法:
<Document src="sample.docx" multimedia="false"/>
- 要点:
-
【Image
<img>】显示图片;若非syntax="multimedia"则显示alt文本。- 要点:
src/base64/type、alt、position(top/bottom/here)、尺寸与缩放(maxWidth/maxHeight/resize)、syntax(multimedia 才显示图片)。 - 典型用法:
<Image src="path/to/image.jpg" alt="Image description" position="bottom" />
- 要点:
-
【Object
<obj>/<dataObj>】外部数据或对象内容;序列化模式下按syntax序列化(默认 json)。- 典型用法:
<Object syntax="json" data="{ key: 'value' }" />
- 典型用法:
-
【Table】以表格显示数据记录与列。
- 要点:
syntax(markdown/html/json/text/csv/tsv/xml)、records/columns、或通过src+parser(auto/csv/tsv/excel/json/jsonl)导入;支持selectedColumns/selectedRecords、maxRecords/maxColumns;可用特殊列index/+index与切片选择(如2:4)。 - 典型用法:
<table src="data.xlsx" parser="excel" maxRecords="10" syntax="csv" />
- 要点:
实用工具(Utilities)
对话消息包装、树/目录展示、网页抓取、工具调用请求/响应等:
-
【AiMessage
<ai-msg>】包装为 AI 消息。 -
【HumanMessage
<user-msg>】包装为用户消息。 -
【SystemMessage
<system-msg>】包装为系统消息。 -
【MessageContent
<msg-content>】显示消息内容(字符串或数组/多媒体内容)。 -
【Conversation】显示由 system/human/ai 构成的对话。
- 要点:
messages(含speaker与content);selectedMessages支持单个索引、区间(如2:4)或类似-6:的选择。
- 要点:
-
【Folder】以树形显示目录结构。
- 要点:
src或直接传入data;filter(正则,作用于目录/文件名);maxDepth默认 3;showContent可选。
- 要点:
-
【ToolRequest】表示 AI 生成的工具请求(含
id、name、parameters,默认说话者ai)。 -
【ToolResponse】展示工具执行结果。
- 要点:其本身“始终为 multimedia”;
syntax用于内部内容的渲染;speaker默认tool。
- 要点:其本身“始终为 multimedia”;
-
【Tree】渲染树结构(
items,可选showContent)。 -
【Webpage】展示网页或本地 HTML 内容。
- 要点:
url/src/buffer/base64;extractText(true 为纯文本,false 转为结构化 POML,默认 false);selector(默认 body)。
- 要点:
常见参数汇总(页面多处出现)
以下参数在页面的多个组件条目中反复出现:
- 【syntax】输出语法/序列化器。常见取值包含:markdown、html、json、yaml、xml、text,亦有 csv/tsv/multimedia(依具体组件而定)。
- 【className】用于样式表快速应用类名。
- 【speaker】human/ai/system(或 tool,用于工具响应)。
- 【name / type】序列化时使用的名称与类型(出现于若干组件)。
- 【writerOptions】可选 JSON,用于定制 Markdown 头、JSON 缩进等(实验性)。
- 【whiteSpace】pre/filter/trim(实验性)。
- pre:保留空白(当 syntax 为 text 时默认)
- filter:去除首尾空白并规范化内部空白(当 syntax 非 text 时默认)
- trim:仅裁剪首尾空白
- 【charLimit】字符软上限(实验性),超出将被截断并加标记。
- 【tokenLimit】令牌软上限(实验性),超出将被截断并加标记。
- 【priority】全局截断时的优先级(实验性),数值更低者更先被丢弃。
(注:上述为对页面原文反复出现之通用参数的汇总。具体是否支持、默认值与取值范围以对应组件条目为准。)
总结
- 本文按“基础组件 / 意图组件 / 数据展示 / 实用工具”四大类,对官方 Components 页面罗列的组件进行分节梳理,并保留了页面中的典型用法与要点参数。
- 页面在多组件条目中统一出现的通用参数(syntax/className/speaker/whiteSpace/charLimit/tokenLimit/priority 等)已集中整理,便于在实际编写 POML 时参考。
- 所有内容均严格来源于上述官方页面;若需更细节或最新信息,请以原文为准。