One or more tags that represent case-sensitive tag names that will invoke this extension.
Protected DefaultAIVendorDefault implementation simply returns 'OpenAI' - override this in your subclass if you are using a different AI vendor.
Protected GetAIModelDefault implementation simply grabs the first AI model that matches GetAIModelName().
Executes AI prompt processing using the configured language model.
Parameter Mapping from CallExtensionAsync:
new nodes.CallExtensionAsync(this, 'run', params, [body])run(context, params, body, callBack)The key difference from TemplateEmbed is that we pass [body] as the 4th parameter
to CallExtensionAsync, which shifts the parameter order to include both params and body
as separate arguments. The body contains the prompt text between the opening and closing tags.
Nunjucks template rendering context containing variables and data
Parsed parameters from the opening tag (AIModel, AllowFormatting, etc.)
Function that returns the rendered prompt content between {% AIPrompt %} and {% endAIPrompt %}
Async callback function to return the AI-generated response or errors
{% AIPrompt AIModel="gpt-4", AllowFormatting=true %}
Generate a personalized greeting for {{ user.name }} who works as {{ user.jobTitle }}.
Make it professional but warm.
{% endAIPrompt %}
This class is an extension for the Nunjucks template engine that allows for the use of an AI prompt in a template.