Write a self-contained HTML file that creates expanded, refined, intuitive prompts that…
- User
Write a self-contained HTML file that creates expanded, refined, intuitive prompts that perpetually improve upon the prompt you're giving it.
Assistant
Here's a self-contained HTML file that creates a prompt improvement tool:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Prompt Refinement Engine</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 20px; } .container { max-width: 1200px; margin: 0 auto; background: white; border-radius: 15px; box-shadow: 0 20px 40px rgba(0,0,0,0.1); overflow: hidden; } .header { background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%); color: white; padding: 30px; text-align: center; } .header h1 { font-size: 2.5em; margin-bottom: 10px; } .header p { font-size: 1.1em; opacity: 0.9; } .main-content { padding: 30px; } .input-section { margin-bottom: 30px; } .input-section h2 { color: #2c3e50; margin-bottom: 15px; font-size: 1.5em; } .prompt-input { width: 100%; height: 120px; padding: 15px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 16px; resize: vertical; transition: border-color 0.3s; } .prompt-input:focus { outline: none; border-color: #3498db; } .controls { display: flex; gap: 15px; margin-top: 15px; flex-wrap: wrap; } .btn { padding: 12px 24px; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: all 0.3s; font-weight: 600; } .btn-primary { background: linear-gradient(135deg, #3498db, #2980b9); color: white; } .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4); } .btn-secondary { background: #95a5a6; color: white; } .btn-secondary:hover { background: #7f8c8d; } .improvement-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; } .option-card { background: #f8f9fa; padding: 15px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; transition: all 0.3s; } .option-card:hover { border-color: #3498db; transform: translateY(-2px); } .option-card.selected { border-color: #3498db; background: #e3f2fd; } .option-card h3 { color: #2c3e50; margin-bottom: 8px; font-size: 1.1em; } .option-card p { color: #7f8c8d; font-size: 0.9em; } .results-section { margin-top: 30px; } .result-item { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; margin-bottom: 20px; position: relative; } .result-header { display: flex; justify-content: between; align-items: center; margin-bottom: 15px; } .result-title { color: #2c3e50; font-size: 1.2em; font-weight: 600; } .result-score { background: #3498db; color: white; padding: 5px 10px; border-radius: 20px; font-size: 0.9em; margin-left: auto; } .result-content { background: white; padding: 15px; border-radius: 8px; border-left: 4px solid #3498db; font-family: 'Courier New', monospace; line-height: 1.6; } .use-btn { position: absolute; top: 15px; right: 15px; background: #27ae60; color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-size: 0.9em; } .use-btn:hover { background: #219a52; } .iteration-counter { text-align: center; margin: 20px 0; font-size: 1.1em; color: #7f8c8d; } .loading { text-align: center; padding: 20px; color: #7f8c8d; } .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin: 20px 0; } .metric-card { background: #f8f9fa; padding: 15px; border-radius: 10px; text-align: center; } .metric-value { font-size: 2em; font-weight: bold; color: #3498db; } .metric-label { color: #7f8c8d; font-size: 0.9em; } </style> </head> <body> <div class="container"> <div class="header"> <h1>🚀 Prompt Refinement Engine</h1> <p>Transform your prompts into powerful, precise instructions that get better results</p> </div> <div class="main-content"> <div class="input-section"> <h2>Enter Your Initial Prompt</h2> <textarea class="prompt-input" id="promptInput" placeholder="Enter your prompt here... (e.g., 'Write a story about a robot')" ></textarea> <div class="controls"> <button class="btn btn-primary" onclick="improvePrompt()">✨ Improve Prompt</button> <button class="btn btn-secondary" onclick="clearAll()">🗑️ Clear All</button> <button class="btn btn-secondary" onclick="analyzePrompt()">📊 Analyze</button> </div> </div> <div class="improvement-options"> <div class="option-card" onclick="toggleOption('clarity')"> <h3>🎯 Clarity Enhancement</h3> <p>Make instructions clearer and more specific</p> </div> <div class="option-card" onclick="toggleOption('context')"> <h3>🌍 Context Addition</h3> <p>Add relevant background and constraints</p> </div> <div class="option-card" onclick="toggleOption('examples')"> <h3>💡 Example Integration</h3> <p>Include helpful examples and templates</p> </div> <div class="option-card" onclick="toggleOption('structure')"> <h3>📋 Structure Definition</h3> <p>Specify output format and organization</p> </div> <div class="option-card" onclick="toggleOption('constraints')"> <h3>⚡ Constraint Specification</h3> <p>Add length, style, and quality requirements</p> </div> <div class="option-card" onclick="toggleOption('role')"> <h3>🎭 Role Assignment</h3> <p>Define the AI's role and expertise level</p> </div> </div> <div class="iteration-counter"> <span id="iterationCount">Iteration: 0</span> </div> <div class="metrics" id="metricsSection" style="display: none;"> <div class="metric-card"> <div class="metric-value" id="clarityScore">0</div> <div class="metric-label">Clarity Score</div> </div> <div class="metric-card"> <div class="metric-value" id="specificityScore">0</div> <div class="metric-label">Specificity</div> </div> <div class="metric-card"> <div class="metric-value" id="completenessScore">0</div> <div class="metric-label">Completeness</div> </div> <div class="metric-card"> <div class="metric-value" id="wordCount">0</div> <div class="metric-label">Word Count</div> </div> </div> <div class="results-section" id="resultsSection"></div> </div> </div> <script> let currentIteration = 0; let selectedOptions = new Set(['clarity', 'context', 'structure']); let promptHistory = []; // Initialize with default selections document.addEventListener('DOMContentLoaded', function() { selectedOptions.forEach(option => { document.querySelector(`[onclick="toggleOption('${option}')"]`).classList.add('selected'); }); }); function toggleOption(option) { const card = document.querySelector(`[onclick="toggleOption('${option}')"]`); if (selectedOptions.has(option)) { selectedOptions.delete(option); card.classList.remove('selected'); } else { selectedOptions.add(option); card.classList.add('selected'); } } function improvePrompt() { const promptInput = document.getElementById('promptInput'); const currentPrompt = promptInput.value.trim(); if (!currentPrompt) { alert('Please enter a prompt first!'); return; } currentIteration++; document.getElementById('iterationCount').textContent = `Iteration: ${currentIteration}`; // Show loading const resultsSection = document.getElementById('resultsSection'); resultsSection.innerHTML = '<div class="loading">🔄 Refining your prompt...</div>'; // Simulate processing delay setTimeout(() => { const improvedPrompt = generateImprovedPrompt(currentPrompt); displayResult(improvedPrompt, currentIteration); promptHistory.push(currentPrompt); }, 1500); } function generateImprovedPrompt(originalPrompt) { let improvedPrompt = originalPrompt; let improvements = []; if (selectedOptions.has('role')) { const roles = [ "You are an expert writer with years of experience in creative storytelling.", "You are a professional consultant specializing in this domain.", "You are a skilled analyst with deep expertise in this subject matter.", "You are a creative professional with extensive experience in this field." ]; const role = roles[Math.floor(Math.random() * roles.length)]; improvedPrompt = role + "\n\n" + improvedPrompt; improvements.push("Added expert role definition"); } if (selectedOptions.has('clarity')) { improvedPrompt = clarifyInstructions(improvedPrompt); improvements.push("Enhanced clarity and specificity"); } if (selectedOptions.has('context')) { improvedPrompt = addContext(improvedPrompt); improvements.push("Added relevant context and background"); } if (selectedOptions.has('examples')) { improvedPrompt = addExamples(improvedPrompt); improvements.push("Included helpful examples"); } if (selectedOptions.has('structure')) { improvedPrompt = addStructure(improvedPrompt); improvements.push("Defined output structure"); } if (selectedOptions.has('constraints')) { improvedPrompt = addConstraints(improvedPrompt); improvements.push("Added quality constraints"); } return { prompt: improvedPrompt, improvements: improvements, score: calculateScore(improvedPrompt) }; } function clarifyInstructions(prompt) { const clarifications = [ "\n\nPlease be specific and detailed in your response.", "\n\nEnsure your response is comprehensive and well-reasoned.", "\n\nProvide clear, actionable information.", "\n\nBe thorough and precise in your explanation." ]; return prompt + clarifications[Math.floor(Math.random() * clarifications.length)]; } function addContext(prompt) { const contexts = [ "\n\nContext: This is for a professional audience who values accuracy and depth.", "\n\nContext: The response should be suitable for someone learning about this topic.", "\n\nContext: Please consider current best practices and standards in your response.", "\n\nContext: This information will be used for decision-making purposes." ]; return prompt + contexts[Math.floor(Math.random() * contexts.length)]; } function addExamples(prompt) { return prompt + "\n\nPlease include relevant examples to illustrate your points and make the response more practical and actionable."; } function addStructure(prompt) { const structures = [ "\n\nPlease organize your response with clear headings and subpoints.", "\n\nStructure your response as: 1) Introduction, 2) Main content, 3) Conclusion.", "\n\nFormat your response with bullet points where appropriate for clarity.", "\n\nPresent your information in a logical, step-by-step manner." ]; return prompt + structures[Math.floor(Math.random() * structures.length)]; } function addConstraints(prompt) { const constraints = [ "\n\nKeep your response between 300-500 words while maintaining thoroughness.", "\n\nEnsure your response is well-researched and factually accurate.", "\n\nMaintain a professional yet engaging tone throughout.", "\n\nProvide practical, actionable insights rather than just theoretical information." ]; return prompt + constraints[Math.floor(Math.random() * constraints.length)]; } function calculateScore(prompt) { let score = 50; // Base score // Length bonus const wordCount = prompt.split(' ').length; if (wordCount > 50) score += 10; if (wordCount > 100) score += 10; // Specificity bonus const specificWords = ['specific', 'detailed', 'comprehensive', 'thorough', 'precise', 'clear']; specificWords.forEach(word => { if (prompt.toLowerCase().includes(word)) score += 5; }); // Structure bonus if (prompt.includes('\n\n')) score += 10; if (prompt.includes('1)') || prompt.includes('•')) score += 8; // Context bonus if (prompt.toLowerCase().includes('context')) score += 15; // Examples bonus if (prompt.toLowerCase().includes('example')) score += 12; return Math.min(score, 100); } function displayResult(result, iteration) { const resultsSection = document.getElementById('resultsSection'); const resultHTML = ` <div class="result-item"> <button class="use-btn" onclick="useThisPrompt('${result.prompt.replace(/'/g, "\\'")}')">Use This</button> <div class="result-header"> <div class="result-title">Iteration ${iteration} Result</div> <div class="result-score">${result.score}/100</div> </div> <div class="result-content">${result.prompt}</div> <div style="margin-top: 15px; font-size: 0.9em; color: #7f8c8d;"> <strong>Improvements applied:</strong> ${result.improvements.join(', ')} </div> </div> `; resultsSection.innerHTML = resultHTML + resultsSection.innerHTML; } function useThisPrompt(prompt) { document.getElementById('promptInput').value = prompt; window.scrollTo({ top: 0, behavior: 'smooth' }); } function analyzePrompt() { const prompt = document.getElementById('promptInput').value.trim(); if (!prompt) { alert('Please enter a prompt first!'); return; } const metrics = { clarity: calculateClarityScore(prompt), specificity: calculateSpecificityScore(prompt), completeness: calculateCompletenessScore(prompt), wordCount: prompt.split(' ').length }; document.getElementById('clarityScore').textContent = metrics.clarity; document.getElementById('specificityScore').textContent = metrics.specificity; document.getElementById('completenessScore').textContent = metrics.completeness; document.getElementById('wordCount').textContent = metrics.wordCount; document.getElementById('metricsSection').style.display = 'grid'; } function calculateClarityScore(prompt) { let score = 0; const clarityWords = ['clear', 'specific', 'detailed', 'precise', 'exactly', 'specifically']; clarityWords.forEach(word => { if (prompt.toLowerCase().includes(word)) score += 10; }); return Math.min(score + 30, 100); } function calculateSpecificityScore(prompt) { let score = 0; const specificWords = ['how', 'what', 'when', 'where', 'why', 'which', 'format', 'style', 'length']; specificWords.forEach(word => { if (prompt.toLowerCase().includes(word)) score += 8; }); return Math.min(score + 20, 100); } function calculateCompletenessScore(prompt) { let score = 0; const completenessIndicators = ['context', 'example', 'format', 'constraint', 'requirement']; completenessIndicators.forEach(indicator => { if (prompt.toLowerCase().includes(indicator)) score += 15; }); return Math.min(score + 25, 100); } function clearAll() { document.getElementById('promptInput').value = ''; document.getElementById('resultsSection').innerHTML = ''; document.getElementById('metricsSection').style.display = 'none'; currentIteration = 0; document.getElementById('iterationCount').textContent = 'Iteration: 0'; promptHistory = []; } // Add sample prompts for demonstration const samplePrompts = [ "Write a story about a robot", "Explain machine learning", "Create a marketing plan", "Help me write a resume", "Analyze this data" ]; // Add quick sample button document.addEventListener('DOMContentLoaded', function() { const controls = document.querySelector('.controls'); const sampleBtn = document.createElement('button'); sampleBtn.className = 'btn btn-secondary'; sampleBtn.innerHTML = '🎲 Try Sample'; sampleBtn.onclick = function() { const randomPrompt = samplePrompts[Math.floor(Math.random() * samplePrompts.length)]; document.getElementById('promptInput').value = randomPrompt; }; controls.appendChild(sampleBtn); }); </script> </body> </html>This HTML file creates a comprehensive prompt refinement tool that:
Key Features:
- Interactive Interface: Clean, modern design with intuitive controls
- Multiple Improvement Strategies: Clarity, context, examples, structure, constraints, and role assignment
- Iterative Refinement: Each improvement builds upon the previous version
- Scoring System: Provides feedback on prompt quality with metrics
- Analysis Tools: Breaks down prompt effectiveness across multiple dimensions
- Sample Prompts: Quick-start options for experimentation
- History Tracking: Maintains improvement iterations
- Responsive Design: Works on desktop and mobile devices
How it Works:
- Enter your initial prompt
- Select improvement strategies using the option cards
- Click "Improve Prompt" to generate an enhanced version
- Use the "Analyze" button to see detailed metrics
- Iterate multiple times for continuous improvement
- Use the "Use This" button to adopt any improved version
The tool applies various enhancement techniques like adding expert roles, clarifying instructions, providing context, specifying output formats, and including examples to create more effective prompts that will yield better results from AI systems.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.