Currently Available
- Template Validation: Check templates for Jinja2 syntax errors and variable usage against the schema
- Live Preview: See rendered results instantly to verify changes
- Context-Aware Validation: Validates against your template variables and schema
Planned Features (Not Yet Available)
Accessing the AI Template Editor
- Navigate to AI Studio → UI Resources
- Create a new template or edit an existing one
- Go to the Template tab
- Click the AI Edit button (purple sparkles icon) in the top right of the template editor
How to Use
1. Describe Your Changes
In the AI Editor dialog, enter a clear instruction describing what you want to change. Examples:- “Add a button to toggle visibility of the description”
- “Make the layout responsive with Tailwind classes”
- “Add icons to list items using lucide-react icon classes”
- “Change the color scheme to use purple tones”
- “Add hover effects to interactive elements”
2. AI Processes Your Request
The AI will:- Analyze your current template
- Understand available variables from your context schema
- Use preview data to test rendering
- Research best practices if needed (via internet access)
- Generate the modified template
3. Review the Results
After processing, you’ll see:- Validation Status: Whether the template is valid
- Edited Template: The modified code with syntax highlighting
- Live Preview: Rendered output with your preview data
- Error Messages: Any validation or rendering errors
4. Apply or Adjust
- Apply Changes: Click “Apply Changes” to update your template
- Try Again: Click “Cancel” and provide different instructions
- Manual Edit: Close the AI editor and make manual adjustments
Best Practices
Writing Effective Instructions
Good Instructions:- ✅ “Add a card wrapper with shadow and rounded corners”
- ✅ “Make the list items display in a 2-column grid on desktop”
- ✅ “Add a badge showing the item count”
- ✅ “Make it look like Gmail’s interface using https://mail.google.com”
- ✅ “Use the color scheme from https://stripe.com”
- ✅ “Search for modern card design patterns and apply them”
- ✅ “Fix errors” (AI will validate and fix any issues)
- ✅ “Validate the template” (AI will check for errors)
- ✅ “Analyze https://github.com and use their notification card design”
- ✅ “Copy the color palette from https://twitter.com”
- ✅ “Use the spacing and typography from https://notion.so”
- ✅ “Fix the validation errors”
- ✅ “Check for errors and fix them”
- ✅ “Validate and fix any issues”
- ❌ “Make it look better” (too vague)
- ❌ “Use variable X” (if X doesn’t exist in your schema)
- ❌ “Add JavaScript” (Jinja2 templates are HTML only)
Template Variables
The AI can only use variables defined in your Context Schema. Make sure your schema includes all necessary variables before using AI editing.Iterative Editing
For complex changes, break them into smaller steps:- First: “Add basic card structure”
- Then: “Add responsive grid layout”
- Finally: “Add icons and styling”
Technical Details
AI Capabilities
- Template Engine: Jinja2
- CSS Framework: Tailwind CSS (recommended)
- Icon Library: Lucide (when applicable)
- Internet Access:
- WebFetch: Can analyze specific website designs by URL
- WebSearch: Can search for UI/UX patterns and best practices
- Design Extraction: Analyzes colors, spacing, typography, and layout from websites
- Validation Tool: Built-in
validate_templatetool that:- Checks Jinja2 syntax errors
- Validates variable usage against schema
- Tests rendering with preview data
- Provides detailed error reports
- Gives fix recommendations
- Multi-turn Editing: Can make up to 10 turns for research, editing, and validation
Constraints
The AI Editor:- ✅ Modifies template content only
- ✅ Uses only variables from your context schema
- ✅ Validates syntax and rendering
- ✅ Preserves existing functionality unless asked to change
- ❌ Cannot create new files
- ❌ Cannot modify context schema
- ❌ Cannot add JavaScript (templates are HTML only)
Security
- All AI operations are server-side
- Templates are sandboxed during rendering
- Only staff users can access AI editing
- Internet access is read-only (research purposes)
Troubleshooting
Template has validation errors
Template has validation errors
- Check that all variables in the template exist in your context schema
- Verify Jinja2 syntax is correct (proper tags, filters)
- Review error messages for specific issues
Preview failed to render
Preview failed to render
- Verify preview data matches the context schema
- Check for missing required variables
- Verify data types match schema definitions
AI didn't understand my instruction
AI didn't understand my instruction
- Be more specific about what you want
- Break complex changes into smaller steps
- Refer to specific variables by name
- Provide examples if possible
Example Workflows
Scenario 1: Adding Interactive Features
-
Initial Template:
- AI Instruction: “Add a toggle button to show/hide the description, and style it with Tailwind”
-
AI Output:
- Review: Check the preview, verify it works as expected
- Apply: Click “Apply Changes” to update the template
Scenario 2: Analyzing a Website Design
-
Initial Template:
- AI Instruction: “Make it look like Stripe’s pricing cards from https://stripe.com/pricing”
-
AI Process:
- Uses WebFetch to analyze Stripe’s pricing page
- Extracts design elements: color scheme, spacing, shadows, typography
- Applies Stripe’s design patterns to the template
-
AI Output:
- Review: Preview shows a Stripe-inspired card design
- Apply: Click “Apply Changes” to update the template
Scenario 3: Validating and Fixing Errors
-
Template with Errors:
- AI Instruction: “Fix errors”
-
AI Process:
- Uses
validate_templatetool - Gets validation report:
- Uses Edit to fix:
titel→title - Uses Edit to fix:
status = 'active'→status == 'active' - Runs validate_template again to confirm fixes
- Uses
-
AI Output:
- Validation Report: ✅ Template is valid and renders successfully!
- Result: All errors fixed automatically
Related Features
- UI Resources — Template management and syntax reference
- UI Resource Tool — Return rich UI components from agents
- UI Resources Guide — Design patterns and accessibility
