# 086: AI With Constraints # Guide AI behavior with rules # Generate code with constraints user_input = "Show me all users" query = ai.generate_sql: intent: user_input constraints: [ "Only SELECT queries allowed (no DELETE/UPDATE/DROP)", "Must include LIMIT clause", "No access to sensitive tables (passwords, tokens)" ] show query # SELECT * FROM users LIMIT 100 # Generate UI with branding constraints ai.generate_component: type: "login_form" constraints: [ "Use brand colors: #3366ff, #ffffff", "No third-party auth (email/password only)", "Include password strength indicator", "Accessible (ARIA labels, keyboard navigation)" ] # Content generation with constraints ai.generate_text: prompt: "Write product description" constraints: [ "Max 100 words", "Professional tone", "No superlatives (amazing, incredible, etc.)", "Include SEO keywords: sustainable, eco-friendly", "End with call-to-action" ] # Data transformation with validation ai.transform(messy_data, { to: "normalized", constraints: [ "All email addresses must be valid", "Ages must be between 0 and 120", "Phone numbers in E.164 format", "Reject records missing required fields" ] }) # Constraints ensure AI stays within bounds # Prevents security issues, maintains brand consistency