Skip to content

Fence Formats

GenAIScript supports various types of โ€œfenceโ€ formats when rendering def function, since LLMs may behave differently depending on the format of the input text. As of 1.82.0, the default format is to use XML tags.

The following def call will generate a fenced region with different syntax:

  • xml
def("TEXT", ":)", { fenceFormat: "xml" })
<TEXT>
:)
</TEXT>
  • markdown
def("TEXT", ":)", { fenceFormat: "markdown" })
TEXT:
\`\`\`
:)
\`\`\`
  • none
def("TEXT", ":)", { fenceFormat: "none" })
TEXT:
:)

Referencing a def

If you are using the xml format, it is advised to use <NAME> when referencing the def variable, or use the returned value as the name.

const textName = def("TEXT", ":)", { fenceFormat: "xml" })
$`Summarize ${textName}` // Summarize <TEXT>

Configuriation

GenAIScript will automatically pick a format based on the model. However, you can override the format at the script level.

script({ fenceFormat: "xml" })

or at the def level:

def("TEXT", ":)", { fenceFormat: "xml" })

or through the --fence-format flag on the cli:

Terminal window
genaiscript run ... --fence-format xml