Skip to main content

Dynamic Prompt Examples

Adjusting prompt inputs based on content length to reduce token consumption

Providing different Summary Prompts based on content length to enhance summarization experience

Syntax

Comments

The content between {# #} is a comment and will not be parsed.

Conditional Statements

{% if ... %} ... {% else %} ... {% elif %} ... {% endif %} are conditional statements that execute different code blocks based on the conditions in the parentheses.

Variables

The content between {{ ... }} is a variable and will be parsed into the corresponding value. Builtin Variables:
  • content. The content of the article.
  • lang/language. The language you set in basic settings.
  • title. The title of the article.
  • url. The URL of the article.
  • encodedUrl. The encoded URL of the article, typically used as a URL query.

Filter

Filters are essentially functions that can be applied to variables. They are called with a pipe operator (|) and can take arguments. Builtin Filters:
  • num_tokens. Calculate the number of tokens of the content.
  • central_part. Extract the central part of the content.

More

Refer to nunjucks doc