AI Assistant attributes define:
- The target property to be generated by AI (by applying the attribute directly to the property)
- The source content used as input context (by specifying source property names; if omitted, the entire page content is used)
- The generation behavior (how the AI interprets the input and produces the output)
If source properties are explicitly specified in the attribute, AI Assistant uses those properties as the generation context. If no source properties are provided, AI Assistant automatically uses the entire page content as the source input.
When to use entire page content
Use the entire page as input when the task needs a full understanding of the content, rather than just parts of it.
- Generate meta title
- Generate meta description
- Generate FAQs for the page
Example: Configure meta description generator
[AiMetaDescriptionGenerator]
public virtual string MetaDescription { get; set }
When to specify source properties
Use explicit source properties when the generation task depends on specific content:
- Generate Alt Text
- Generate summaries for a section
- Translation
- Spell checking
Example: Configure introduction generator with specified source properties
public virtual XhtmlString MainBody { get; set; }
public virtual ContentArea ContentArea { get; set; }
[AiIntroductionGenerator(nameof(MainBody), nameof(ContentArea))]
public virtual string Introduction { get; set; }
Using generator attributes with options
1. Source properties
Generator attributes accept source property names that provide the input context for AI generation.
Source properties can be any content type, including: XhtmlString and ContentArea.
Note: Source properties must belong to the same content type where the generator attribute is applied.
2. Working with ContentArea
When a ContentArea is used as a source, AI Assistant will:
- Iterate through all content items within the ContentArea
- Extract string-based properties from each content item
- Combine the extracted text into a single input
3. Excluding content from AI prompts
To control what content is included in the AI prompt, you can exclude:
- Specific properties within a content item
- Entire content item types
Example: Exclude a property
[AiExcludeFromPrompt]
public virtual string InternalNotes { get; set; }
Example: Exclude a content type
[AiExcludeFromPrompt]
public class TrackingBlock : BlockData
{
public virtual string Script { get; set; }
}
This ensures irrelevant content is not sent to the AI.
4. Property combination behavior
When multiple source properties are provided, AI Assistant combines them based on PropertyCombinationType.
Default Behavior: PropertyCombinationType.And
- All specified sources are combined into a single prompt
- Every source contributes to the final context
Use when:
- All sources are relevant
- You want maximum context coverage
Alternative Behavior: PropertyCombinationType.Or
[AiIntroductionGenerator(
PropertyCombinationType.Or,
nameof(MainBody),
nameof(ContentArea))]
public virtual string Introduction { get; set; }
- Sources are evaluated in order
- The first non-empty source is used
- Remaining sources are ignored
Use when:
- Content may exist in different fields
- Only one source is needed
- You want fallback behavior
Summary
- Source properties define where the AI gets its input
- ContentArea sources are automatically flattened into text
- AiExcludeFromPrompt gives fine-grained control over prompt content
- PropertyCombinationType controls how multiple sources are used:
- And: combine all sources (default)
- Or: use first non-empty source