Python POML Native Prompt¶
Estimated time to read: 1 minute
poml.prompt.Prompt
¶
Bases: _TagLib
Builds an XML structure using ElementTree, supporting context-managed tags.
Source code in python/poml/prompt.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
__enter__()
¶
Enter a context for building a prompt.
The Prompt instance can be reused across multiple with
blocks. On
each entry we simply reset the stack of currently open elements while
preserving any previously created root elements so that additional tags
can be appended in subsequent sessions.
Source code in python/poml/prompt.py
__exit__(exc_type, exc_val, exc_tb)
¶
Cleans up Prompt state upon exiting a 'with' block.
Source code in python/poml/prompt.py
ai_message(**kwargs)
¶
Wrap the contents in a AI message.
audio(src=None, base64=None, alt=None, type=None, position=None, syntax=None, **kwargs)
¶
Audio (<audio>
) embeds an audio file in the content.
Accepts either a file path (src
) or base64-encoded audio data (base64
).
The MIME type can be provided via type
or will be inferred from the file extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src
|
Optional[str]
|
Path to the audio file. If provided, the file will be read and encoded as base64. |
None
|
base64
|
Optional[str]
|
Base64-encoded audio data. Cannot be used together with |
None
|
alt
|
Optional[str]
|
The alternative text to show when the image cannot be displayed. |
None
|
type
|
Optional[str]
|
The MIME type of the audio (e.g., audio/mpeg, audio/wav). If not specified, it will be inferred from the file extension.
The type must be consistent with the real type of the file. The consistency will NOT be checked or converted.
The type can be specified with or without the |
None
|
position
|
Optional[str]
|
The position of the image. Default is |
None
|
syntax
|
Optional[str]
|
Only when specified as |
None
|
Source code in python/poml/_tags.py
bold(**kwargs)
¶
Bold (<b>
) emphasizes text in a bold style when using markup syntaxes.
Source code in python/poml/_tags.py
captioned_paragraph(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
CaptionedParagraph (<cp>
for short) creates a paragraph with a customized caption title.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the paragraph. Required. |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes.
By default, it's same as |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Example
Source code in python/poml/_tags.py
code(inline=None, lang=None, **kwargs)
¶
Code is used to represent code snippets or inline code in markup syntaxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inline
|
Optional[bool]
|
Whether to render code inline or as a block. Default is |
None
|
lang
|
Optional[str]
|
The language of the code snippet. |
None
|
Source code in python/poml/_tags.py
conversation(messages=None, selectedMessages=None, **kwargs)
¶
Display a conversation between system, human and AI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
Optional[Any]
|
A list of message. Each message should have a |
None
|
selectedMessages
|
Optional[str]
|
The messages to be selected. If not provided, all messages will be selected.
You can use a string like |
None
|
Example
Source code in python/poml/_tags.py
document(src=None, buffer=None, base64=None, parser=None, multimedia=None, selectedPages=None, **kwargs)
¶
Displaying an external document like PDF, TXT or DOCX.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src
|
Optional[str]
|
The source file to read the data from. This must be provided if records is not provided. |
None
|
buffer
|
Optional[bytes]
|
Document data buffer. Recommended to use |
None
|
base64
|
Optional[str]
|
Base64 encoded string of the document data. Mutually exclusive with |
None
|
parser
|
Optional[str]
|
The parser to use for reading the data. If not provided, it will be inferred from the file extension. Choices: |
None
|
multimedia
|
Optional[bool]
|
If true, the multimedias will be displayed. If false, the alt strings will be displayed at best effort. Default is |
None
|
selectedPages
|
Optional[str]
|
The pages to be selected. This is only available for PDF documents. If not provided, all pages will be selected.
You can use a string like |
None
|
Example
To display a Word document without including the real multimedia:
Source code in python/poml/_tags.py
dump_xml()
¶
Dumps the generated XML string, pretty-printed by default (useful for debugging).
example(caption=None, captionSerialized=None, captionStyle=None, chat=None, captionTextTransform=None, captionColon=None, **kwargs)
¶
Example is useful for providing a context, helping the model to understand what kind of inputs and outputs are expected. It can also be used to demonstrate the desired output style, clarifying the structure, tone, or level of detail in the response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the example paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption, applicable only for "markup" syntaxes. Default is |
None
|
chat
|
Optional[bool]
|
Indicates whether the example should be rendered in chat format.
When used in a example set ( |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes.
Options are |
None
|
captionColon
|
Optional[bool]
|
Indicates whether to append a colon after the caption.
By default, this is true for |
None
|
Example
Source code in python/poml/_tags.py
example_input(caption=None, captionSerialized=None, speaker=None, captionStyle=None, captionTextTransform=None, captionColon=None, **kwargs)
¶
ExampleInput (<input>
) is a paragraph that represents an example input.
By default, it's spoken by a human speaker in a chat context, but you can manually specify the speaker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the example input paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
speaker
|
Optional[str]
|
The speaker for the example input. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionColon
|
Optional[bool]
|
Indicates whether to append a colon after the caption.
By default, this is true for |
None
|
Example
When used with a template:
Source code in python/poml/_tags.py
example_output(caption=None, captionSerialized=None, speaker=None, captionStyle=None, captionTextTransform=None, captionColon=None, **kwargs)
¶
ExampleOutput (<output>
) is a paragraph that represents an example output.
By default, it's spoken by a AI speaker in a chat context, but you can manually specify the speaker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the example output paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
speaker
|
Optional[str]
|
The speaker for the example output. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionColon
|
Optional[bool]
|
Indicates whether to append a colon after the caption.
By default, this is true for |
None
|
Example
When used with a template:
Source code in python/poml/_tags.py
example_set(caption=None, captionSerialized=None, chat=None, introducer=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Example set (<examples>
) is a collection of examples that are usually presented in a list.
With the example set, you can manage multiple examples under a single title and optionally an introducer,
as well as the same chat
format.
You can also choose to use <example>
purely without example set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the example set paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
chat
|
Optional[bool]
|
Indicates whether the examples should be rendered in chat format.
By default, it's |
None
|
introducer
|
Optional[str]
|
An optional introducer text to be displayed before the examples.
For example, |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Example
Source code in python/poml/_tags.py
folder(syntax=None, src=None, data=None, filter=None, maxDepth=None, showContent=None, **kwargs)
¶
Displays a directory structure as a tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The output syntax of the content. Choices: |
None
|
src
|
Optional[str]
|
The source directory path to display. |
None
|
data
|
Optional[List[Any]]
|
Alternative to src, directly provide tree data structure. |
None
|
filter
|
Optional[str]
|
A regular expression to filter files. The regex is applied to the folder names and file names (not the full path). Directories are included by default unless all of their nested content is filtered out. When filter is on, empty directories will not be shown. |
None
|
maxDepth
|
Optional[int]
|
Maximum depth of directory traversal. Default is 3. |
None
|
showContent
|
Optional[bool]
|
Whether to show file contents. Default is false. |
None
|
Example
To display a directory structure with a filter for Python files:
Source code in python/poml/_tags.py
header(**kwargs)
¶
Header (<h>
) renders headings in markup syntaxes.
It's commonly used to highlight titles or section headings.
The header level will be automatically computed based on the context.
Use SubContent (<section>
) for nested content.
Source code in python/poml/_tags.py
hint(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionColon=None, **kwargs)
¶
Hint can be used anywhere in the prompt where you want to provide a helpful tip or explanation. It is usually a short and concise statement that guides the LLM in the right direction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the hint paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionColon
|
Optional[bool]
|
Indicates whether to append a colon after the caption.
By default, this is true for |
None
|
Source code in python/poml/_tags.py
human_message(**kwargs)
¶
Wrap the contents in a user message.
Source code in python/poml/_tags.py
image(src=None, alt=None, base64=None, type=None, position=None, maxWidth=None, maxHeight=None, resize=None, syntax=None, **kwargs)
¶
Image (<img>
) displays an image in the content.
Alternatively, it can also be shown as an alt text by specifying the syntax
prop.
Note that syntax must be specified as multimedia
to show the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src
|
Optional[str]
|
The path to the image file. |
None
|
alt
|
Optional[str]
|
The alternative text to show when the image cannot be displayed. |
None
|
base64
|
Optional[str]
|
The base64 encoded image data. It can not be specified together with |
None
|
type
|
Optional[str]
|
The MIME type of the image to be shown. If not specified, it will be inferred from the file extension.
If specified, the image will be converted to the specified type. Can be |
None
|
position
|
Optional[str]
|
The position of the image. Default is |
None
|
maxWidth
|
Optional[int]
|
The maximum width of the image to be shown. |
None
|
maxHeight
|
Optional[int]
|
The maximum height of the image to be shown. |
None
|
resize
|
Optional[float]
|
The ratio to resize the image to to be shown. |
None
|
syntax
|
Optional[str]
|
Only when specified as |
None
|
Source code in python/poml/_tags.py
inline(syntax=None, className=None, speaker=None, writerOptions=None, whiteSpace=None, charLimit=None, tokenLimit=None, priority=None, **kwargs)
¶
Inline (<span>
) is a container for inline content.
When used with markup syntaxes, it wraps text in an inline style, without any preceding or following blank characters.
In serializer syntaxes, it's treated as a generic value.
Inline elements are not designed to be used alone (especially in serializer syntaxes).
One might notice problematic renderings (e.g., speaker not applied) when using it alone.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The syntax of the content. Choices: |
None
|
className
|
Optional[str]
|
A class name for quickly styling the current block with stylesheets. |
None
|
speaker
|
Optional[str]
|
The speaker of the content. By default, it's determined by the context and the content. Choices: |
None
|
writerOptions
|
Optional[Any]
|
Experimental.. Optional JSON string to customize the format of markdown headers, JSON indents, etc. |
None
|
whiteSpace
|
Optional[str]
|
Experimental. Controls how whitespace is handled in text content.
|
None
|
charLimit
|
Optional[float]
|
Experimental. Soft character limit before truncation is applied. Content exceeding this limit will be truncated with a marker. |
None
|
tokenLimit
|
Optional[float]
|
Experimental. Soft token limit before truncation is applied. Content exceeding this limit will be truncated with a marker. |
None
|
priority
|
Optional[float]
|
Experimental. Priority used when truncating globally. Lower numbers are dropped first when content needs to be reduced to fit limits. |
None
|
Source code in python/poml/_tags.py
introducer(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Introducer is a paragraph before a long paragraph (usually a list of examples, steps, or instructions). It serves as a context introducing what is expected to follow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the introducer paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Source code in python/poml/_tags.py
italic(**kwargs)
¶
Italic (<i>
) emphasizes text in an italic style when using markup syntaxes.
Source code in python/poml/_tags.py
list(listStyle=None, **kwargs)
¶
List (<list>
) is a container for multiple ListItem (<item>
) elements.
When used with markup syntaxes, a bullet or numbering is added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listStyle
|
Optional[str]
|
The style for the list marker, such as dash or star. Default is |
None
|
Source code in python/poml/_tags.py
list_item(**kwargs)
¶
ListItem (<item>
) is an item within a List component.
In markup mode, it is rendered with the specified bullet or numbering style.
Source code in python/poml/_tags.py
message_content(content=None, **kwargs)
¶
Display a message content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
Optional[Any]
|
The content of the message. It can be a string, or an array of strings and multimedia content. |
None
|
Source code in python/poml/_tags.py
newline(newLineCount=None, **kwargs)
¶
Newline (<br>
) explicitly adds a line break, primarily in markup syntaxes.
In serializer syntaxes, it's ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
newLineCount
|
Optional[float]
|
The number of linebreaks to add. |
None
|
Source code in python/poml/_tags.py
object(syntax=None, data=None, **kwargs)
¶
Object (<obj>
, <dataObj>
) displays external data or object content.
When in serialize mode, it's serialized according to the given serializer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The syntax or serializer of the content. Default is |
None
|
data
|
Optional[Any]
|
The data object to render. |
None
|
Source code in python/poml/_tags.py
output_format(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Output format deals with the format in which the model should provide the output. It can be a specific format such as JSON, XML, or CSV, or a general format such as a story, a diagram or steps of instructions. Please refrain from specifying too complex formats that the model may not be able to generate, such as a PDF file or a video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the output format paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Example
Source code in python/poml/_tags.py
paragraph(blankLine=None, **kwargs)
¶
Paragraph (<p>
) is a standalone section preceded by and followed by two blank lines in markup syntaxes.
It's mostly used for text contents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blankLine
|
Optional[bool]
|
Whether to add one more blank line (2 in total) before and after the paragraph. |
None
|
Source code in python/poml/_tags.py
question(questionCaption=None, answerCaption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Question (<qa>
) is actually a combination of a question and a prompt for the answer.
It's usually used at the end of a prompt to ask a question.
The question is followed by a prompt for answer (e.g., Answer:
) to guide the model to respond.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
questionCaption
|
Optional[str]
|
The title or label for the question paragraph. Default is |
None
|
answerCaption
|
Optional[str]
|
The title or label for the answer paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Source code in python/poml/_tags.py
render(chat=True, context=None, stylesheet=None)
¶
Renders the final XML. Raises error if tags are still open.
Source code in python/poml/prompt.py
role(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Specifies the role you want the language model to assume when responding. Defining a role provides the model with a perspective or context, such as a scientist, poet, child, or any other persona you choose.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the role paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Source code in python/poml/_tags.py
stepwise_instructions(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
StepwiseInstructions that elaborates the task by providing a list of steps or instructions. Each step should be concise and clear, and the list should be easy to follow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the stepwise instructions paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Example
Source code in python/poml/_tags.py
strikethrough(**kwargs)
¶
Strikethrough (<s>
, <strike>
) indicates removed or invalid text in markup syntaxes.
Source code in python/poml/_tags.py
sub_content(**kwargs)
¶
SubContent (<section>
) renders nested content, often following a header.
The headers within the section will be automatically adjusted to a lower level.
Example
Source code in python/poml/_tags.py
system_message(**kwargs)
¶
Wrap the contents in a system message.
Source code in python/poml/_tags.py
table(syntax=None, records=None, columns=None, src=None, parser=None, selectedColumns=None, selectedRecords=None, maxRecords=None, maxColumns=None, **kwargs)
¶
Displaying a table with records and columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The output syntax of the content. Choices: |
None
|
records
|
Optional[Any]
|
A list, each element is an object / dictionary / list of elements. The keys are the fields and the values are the data in cells. |
None
|
columns
|
Optional[Any]
|
A list of column definitions. Each column definition is an object with keys "field", "header", and "description". The field is the key in the record object, the header is displayed in the top row, and the description is meant to be an explanation. Columns are optional. If not provided, the columns are inferred from the records. |
None
|
src
|
Optional[str]
|
The source file to read the data from. This must be provided if records is not provided. |
None
|
parser
|
Optional[str]
|
The parser to use for reading the data. If not provided, it will be inferred from the file extension. Choices: |
None
|
selectedColumns
|
Optional[Any]
|
The selected columns to display. If not provided, all columns will be displayed.
It should be an array of column field names, e.g. |
None
|
selectedRecords
|
Optional[Any]
|
The selected records to display. If not provided, all records will be displayed.
It should be an array of record indices, e.g. |
None
|
maxRecords
|
Optional[int]
|
The maximum number of records to display. If not provided, all records will be displayed. |
None
|
maxColumns
|
Optional[int]
|
The maximum number of columns to display. If not provided, all columns will be displayed. |
None
|
Example
To import an excel file, and display the first 10 records in csv syntax:
Source code in python/poml/_tags.py
task(caption=None, captionSerialized=None, captionStyle=None, captionTextTransform=None, captionEnding=None, **kwargs)
¶
Task represents the action you want the language model to perform. It is a directive or instruction that you want the model to follow. Task is usually not long, but rather a concise and clear statement. Users can also include a list of steps or instructions to complete the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
caption
|
Optional[str]
|
The title or label for the task paragraph. Default is |
None
|
captionSerialized
|
Optional[str]
|
The serialized version of the caption when using "serializer" syntaxes. Default is |
None
|
captionStyle
|
Optional[str]
|
Determines the style of the caption,
applicable only for "markup" syntaxes. Default is |
None
|
captionTextTransform
|
Optional[str]
|
Specifies text transformation for the caption, applicable only for "markup" syntaxes. Default is |
None
|
captionEnding
|
Optional[str]
|
A caption can ends with a colon, a newline or simply nothing.
If not specified, it defaults to |
None
|
Example
When including a list of steps:
Source code in python/poml/_tags.py
text(content)
¶
Adds text content to the currently open XML element.
Source code in python/poml/prompt.py
tool_request(id=None, name=None, parameters=None, speaker=None, **kwargs)
¶
ToolRequest represents an AI-generated tool request with parameters. Used to display tool calls made by AI models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
Optional[str]
|
Tool request ID |
None
|
name
|
Optional[str]
|
Tool name |
None
|
parameters
|
Optional[Any]
|
Tool input parameters |
None
|
speaker
|
Optional[str]
|
The speaker of the content. Default is |
None
|
Source code in python/poml/_tags.py
tool_response(syntax=None, id=None, name=None, speaker=None, **kwargs)
¶
ToolResponse represents the result of a tool execution. Used to display tool execution results with rich content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The syntax of ToolResponse is special.
It is always |
None
|
id
|
Optional[str]
|
Tool call ID to respond to |
None
|
name
|
Optional[str]
|
Tool name |
None
|
speaker
|
Optional[str]
|
The speaker of the content. Default is |
None
|
Example
Source code in python/poml/_tags.py
tree(syntax=None, items=None, showContent=None, **kwargs)
¶
Renders a tree structure in various formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
syntax
|
Optional[str]
|
The output syntax to use for rendering the tree Choices: |
None
|
items
|
Optional[List[Any]]
|
Array of tree items to render |
None
|
showContent
|
Optional[bool]
|
Whether to show content values of tree items |
None
|
Source code in python/poml/_tags.py
underline(**kwargs)
¶
Underline (<u>
) draws a line beneath text in markup syntaxes.
Source code in python/poml/_tags.py
webpage(url=None, src=None, buffer=None, base64=None, extractText=None, selector=None, **kwargs)
¶
Displays content from a webpage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
Optional[str]
|
The URL of the webpage to fetch and display. |
None
|
src
|
Optional[str]
|
Local file path to an HTML file to display. |
None
|
buffer
|
Optional[bytes]
|
HTML content as string or buffer. |
None
|
base64
|
Optional[str]
|
Base64 encoded HTML content. |
None
|
extractText
|
Optional[bool]
|
Whether to extract plain text content (true) or convert HTML to structured POML (false). Default is false. |
None
|
selector
|
Optional[str]
|
CSS selector to extract specific content from the page (e.g., "article", ".content", "#main"). Default is "body". |
None
|
Example
Display content from a URL:
Extract only specific content using a selector:
Convert HTML to structured POML components: