Course එකට ආපසු

Iterative Prompting

20 මිනිත්තු📖Lecture

🎯 පාඩමේ අරමුණු

මේ පාඩම ඉවර වෙද්දී ඔයාට:

  • First prompts rarely perfect results දෙන බව තේරුම් ගන්න පුළුවන් වෙයි
  • AI output refine කරන iteration loop master කරන්න පුළුවන් වෙයි
  • Results improve කරන effective follow-up phrases දැනගන්න පුළුවන් වෙයි
  • Common iteration anti-patterns avoid කරන්න පුළුවන් වෙයි

📖 Prompting වල Reality

Comforting truth එකක් මෙන්න:

Prompting Reality

ඔයාගේ first prompt rarely ඔයාට exactly ඕන දේ දෙනවා.

ඒත් ඒක completely okay! Professional prompt engineers ලාත් iterate කරන්න expect කරනවා.

First Prompts Miss වෙන්නේ ඇයි:

  • See කරනකම් exactly ඕන මොකක්ද දැනගන්න බැරි වෙන්න පුළුවන්
  • AI ඔයාගේ words differently interpret කරන්න පුළුවන්
  • Complex requirements upfront fully capture කරන්න අමාරුයි
  • යන ගමන් new requirements discover කරනවා

Goal එක:

Perfect first prompt ලියන එක නෙමෙයි, conversation හරහා efficiently refine කරන එක.


🔄 Iteration Loop එක

Prompting single command එකක් විදියට නෙමෙයි conversation එකක් විදියට හිතන්න:

┌─────────────────┐ │ 1. PROMPT │ ← ඔයාගේ initial request └────────┬────────┘ ↓ ┌─────────────────┐ │ 2. REVIEW │ ← AI response එක බලන්න └────────┬────────┘ ↓ ┌─────────────────┐ │ 3. IDENTIFY │ ← Missing හෝ wrong මොකක්ද? └────────┬────────┘ ↓ ┌─────────────────┐ │ 4. REFINE │ ← Specific changes ask කරන්න └────────┬────────┘ │ ↓ (satisfied වෙනකම් repeat) ┌─────────────────┐ │ 5. DONE │ ← Result needs එක්ක match වෙනවා └─────────────────┘

🔘 Quick Example: Button Iteration

Stepඔයාගේ ActionResult
Initial"Create a button"Basic gray button
Review"ම්ම්, blue සහ bigger ඕන"-
Refine"Make it blue with white text and 20px padding"Blue button, better
Review"Nice, but hover effect ඕන"-
Refine"Add hover effect that darkens slightly"Blue button with hover
Done!3 prompts, minutes 2Exactly ඔයාට ඕන එක

💬 Powerful Follow-Up Phrases

AI better results වලට guide කරන proven phrases මෙන්න:

Simplification වලට:

Text
"Make it simpler"
"Reduce complexity"
"Write a more basic version"
"Can you simplify this?"

Addition වලට:

Text
"Add [feature]"
"Include [element]"
"Also make it [quality]"
"Can you add validation for..."

Removal වලට:

Text
"Remove [element]"
"Don't include [feature]"
"Simpler, without [thing]"
"Take out the [component]"

Clarification වලට:

Text
"Explain why you did [thing]"
"What does this part do?"
"Walk me through the logic"
"Why this approach?"

Alternatives වලට:

Text
"What's another way to do this?"
"Show me a different approach"
"What if we used [alternative]?"
"Any other options?"

Style වලට:

Text
"Make it look more [adjective]"
"Use [color/style] instead"
"Match this design: [description]"
"Make it mobile-friendly"

🎮 Full Example: Countdown Timer Build කිරීම

Complete iteration session එකක් බලමු:

Prompt 1 (Initial):

Create a countdown timer

AI Creates: Basic countdown Python වලින් (console-based) Problem: Web-based ඕන වුනා!


Prompt 2 (Refine):

Make it a web-based countdown timer using HTML, CSS, and JavaScript

AI Creates: Basic styling එක්ක Web countdown Problem: Time set කරන්න way එකක් නැහැ!


Prompt 3 (Add Feature):

Add an input field where users can enter minutes to count down

AI Creates: Input field එක්ක Timer Problem: Plain වගේ පෙනෙනවා


Prompt 4 (Style):

Make the design modern with dark background, large numbers, nice start button

AI Creates: Dark theme එක්ක styled timer Problem: Done වෙද්දී sound එකක් ඕන!


Prompt 5 (Edge Case):

Add a beep sound and visual flash when timer reaches zero

AI Creates: Audio alert එක්ක Timer Review: Perfect! ✅


Total: Prompts 5ක් → Polished, fully-featured timer!


❌ Avoid කරන්න ඕන Anti-Patterns

මේ common mistakes iteration slow කරනවා:

Anti-Pattern 1: සෑම Change එකකටම Starting Over

❌ Wrong Way
✅ Right Way
'Create timer' → 'Create timer with input' → 'Create timer with input and dark theme'
'Create timer' → 'Add input field' → 'Make it dark themed'
හැම වෙලේම fresh start, context lose වෙනවා
Previous responses මත build කරනවා

Fix: Conversation continue කරන්න. AI context remember කරනවා.


Anti-Pattern 2: Review නැතුව First Result Accept කිරීම

❌ Wrong
✅ Right
AI output → Immediately use → Later problems find කරනවා
AI output → Carefully review → Refine → Confident

Fix: Accept කරන්න කලින් always seconds 30ක් review කරන්න.


Anti-Pattern 3: Vague Feedback

❌ Vague
✅ Specific
'Make it better'
'Make the button larger and add more padding'
'This isn't right'
'The calculation should subtract, not add'
'Fix it'
'Fix the hover state — it should turn blue'

Fix: Wrong මොකක්ද instead ඕන මොකක්ද specific වෙන්න.


Anti-Pattern 4: Once එකේදීම ගොඩක් දේවල් Change කිරීම

❌ Too Much
✅ Manageable
'Make it bigger, change color, add animation, fix spacing, add shadow, change font, make responsive'
'Make it bigger and add dark mode' → Then: 'Add animation and fix spacing' → Then: 'Make responsive'

Fix: වරකට 1-3 දේවල් change කරන්න. Each change worked ද verify කරන්න easier.


🌳 Iteration Decision Tree

Next step decide කරනකොට මේක use කරන්න:

Output ඔයාට ඕන එකට match වෙනවද? │ ├── YES → ✅ Done! Result accept කරන්න │ └── NO → Main issue එක මොකක්ද? │ ├── Wrong technology → "Use [correct tech] instead" │ ├── Missing feature → "Add [feature]" │ ├── Unwanted elements → "Remove [element]" │ ├── Wrong style → "Make it [description]" │ ├── Doesn't work → "This gives error: [error]. Fix it" │ └── Don't understand → "Explain [confusing part]"

🧪 Practice Exercise

මේ iteration exercise try කරන්න:

Start with:

මෙතනින් Start කරන්න
Create a simple card component
ChatGPTClaude

Then iterate කරලා add කරන්න (එක වරකට එකක් හෝ දෙකක්):

  1. Top එකේ image එකක්
  2. Image එකට පහළ title එකක්
  3. Short description එකක්
  4. "Learn More" button එකක්
  5. Shadow effect එකක්
  6. Rounded corners
  7. Hover animation එකක්

Challenge: Possible අඩුම prompts ප්‍රමාණයෙන් මේක achieve කරන්න!


📋 Iteration Checklist එක

ඕනෑම AI output accept කරන්න කලින්:

0/6

✅ පාඩමේ සාරාංශය

Key Takeaways

  1. First prompts rarely perfect — Iterate කරන්න expect කරන්න
  2. Conversation continue කරන්න — Previous responses මත build කරන්න
  3. Feedback දෙනකොට specific වෙන්න — AI ට exactly change කරන්න ඕන දේ කියන්න
  4. වරකට changes එකක් තුනක් — Verify කරන්න easier

Iteration Loop එක:

Prompt → Review → Identify Issues → Refine → Repeat

📝 Mini Quiz

📝 ඔයාගේ Understanding Check කරන්න

1/3

How many prompts should you expect for a complex task?