One or more tags that represent case-sensitive tag names that will invoke this extension.
Static ReadonlyNoWhy an {% AIPrompt %} tag fails in a render that has no user.
The user this extension acts for: the user of the render in progress. An extension instance is shared by every render in the process, so it must read this at run time and never cache it. Inside a render that has no user it is undefined; it never falls back to the user the instance was constructed with, which is whichever caller first configured the engine. Outside a render it returns the constructed user.
ProtectedDefaultDefault implementation simply returns 'OpenAI' - override this in your subclass if you are using a different AI vendor.
Use Tags.
ProtectedGetDefault implementation simply grabs the first AI model that matches GetAIModelName().
Required, must implement this method to parse the template and return the results of a call to nodes.CallExtensionAsync()
ProtectedparseMaps the tag's parameters onto an AIPromptConfig, matching names case- and space-insensitively.
ProtectedresolveThe model the tag names, or the highest-power Groq LLM when it names none.
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
ProtectedrunRuns the prompt as contextUser and returns the model's reply. Rejects when the AI engine cannot be
configured, no model is found, or the model call does not succeed.
This class is an extension for the Nunjucks template engine that allows for the use of an AI prompt in a template.