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" })

  • markdown

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

  • none

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

Referencing a def

Section titled “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>

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:

genaiscript run ... --fence-format xml