StructuredOutputTemplate

Models & Types ยท AiDotNet.PromptEngineering.Templates

Template that guides models to produce structured output in specific formats.

Inheritance: PromptTemplateBase โ†’ StructuredOutputTemplate

For Beginners

Gets AI to output data in a specific format.

Example:

Supported formats:

  • JSON for APIs and data processing
  • XML for configuration and interchange
  • CSV for tabular data
  • Markdown for documentation
  • Custom formats with user-defined schemas

How It Works

This template helps ensure consistent, parseable output by providing format specifications, schemas, and examples of the expected structure.

Constructors

Constructor Summary
StructuredOutputTemplate(OutputFormat format, string schema, string example) Initializes a new instance of the StructuredOutputTemplate class.
StructuredOutputTemplate(string template) Initializes a new instance with a custom template string.

Methods

Method Summary
StructuredOutputBuilder Builder() Creates a builder for constructing structured output templates.
StructuredOutputTemplate Csv(string[] columns) Creates a CSV output template with column headers.
StructuredOutputTemplate Json(string schema, string example) Creates a JSON output template with a schema.
StructuredOutputTemplate Markdown(string structure) Creates a Markdown output template.
StructuredOutputTemplate WithTask(string task) Sets the task to perform.
StructuredOutputTemplate Xml(string rootElement, string schema) Creates an XML output template with a schema.
StructuredOutputTemplate Yaml(string schema) Creates a YAML output template with a schema.