Files
dockergprompt/app/Services/TutorialService.php
T
2026-09-01 09:22:30 -03:00

142 lines
6.9 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Services;
class TutorialService
{
/**
* Get tutorial content.
*
* @return array<string, mixed>
*/
public function getContent(): array
{
return [
'title' => 'Prompt Engineering Tutorial',
'description' => 'Learn how to create effective prompts for AI models.',
'sections' => [
[
'id' => 'introduction',
'title' => 'Introduction',
'content' => 'Prompt engineering is the process of designing and optimizing prompts to effectively communicate with AI language models. A well-crafted prompt can significantly improve the quality and relevance of AI-generated responses.',
],
[
'id' => 'objective',
'title' => 'Objective',
'content' => 'Clearly define what you want the AI to achieve. Be specific about the goal and desired outcome. A clear objective helps the AI understand the task and produce more relevant results.',
'tips' => [
'Start with action verbs (e.g., "Write", "Analyze", "Create")',
'Specify the desired outcome explicitly',
'Keep it concise but complete',
],
],
[
'id' => 'context',
'title' => 'Context',
'content' => 'Provide background information that helps the AI understand the situation. Context includes relevant details, constraints, and situational awareness that influence the response.',
'tips' => [
'Include relevant background information',
'Mention any constraints or limitations',
'Provide examples of the desired scenario',
],
],
[
'id' => 'persona',
'title' => 'Persona / Role',
'content' => 'Define who the AI should be. Assigning a specific role or persona helps the AI adopt the appropriate tone, expertise level, and perspective for the task.',
'tips' => [
'Use professional roles (e.g., "Senior Developer", "Marketing Expert")',
'Specify expertise level (e.g., "Expert", "Beginner-friendly")',
'Combine multiple roles if needed',
],
],
[
'id' => 'tone',
'title' => 'Tone / Style',
'content' => 'Specify the communication style and tone. This ensures the AI\'s response matches your expectations for formality, friendliness, and overall style.',
'tips' => [
'Use descriptive adjectives (e.g., "Professional", "Casual", "Technical")',
'Specify formality level',
'Mention any stylistic preferences',
],
],
[
'id' => 'constraints',
'title' => 'Constraints',
'content' => 'Define limitations and rules the AI must follow. Constraints help prevent unwanted content and ensure the response meets specific requirements.',
'tips' => [
'Set word or character limits',
'Exclude certain topics or formats',
'Specify mandatory elements',
],
],
[
'id' => 'output_format',
'title' => 'Output Format',
'content' => 'Specify the expected structure of the response. A clear format helps the AI organize the information in a way that is most useful for you.',
'tips' => [
'Use markdown, JSON, or plain text',
'Specify sections and headings',
'Include examples of the desired format',
],
],
[
'id' => 'examples',
'title' => 'Examples (Few-Shot)',
'content' => 'Provide example inputs and outputs. Few-shot learning helps the AI understand the pattern and quality expected in the response.',
'tips' => [
'Include 2-3 high-quality examples',
'Show both input and desired output',
'Ensure examples cover edge cases',
],
],
[
'id' => 'variables',
'title' => 'Variables',
'content' => 'Use dynamic placeholders for reusable prompts. Variables make your prompts flexible and reusable across different scenarios.',
'tips' => [
'Use clear variable names (e.g., {{topic}}, {{audience}})',
'Document expected variable values',
'Keep variable count manageable',
],
],
[
'id' => 'temperature',
'title' => 'Temperature',
'content' => 'Control the randomness of the AI response. Lower values produce more deterministic and focused outputs, while higher values increase creativity and diversity.',
'tips' => [
'0.0 - 0.3: Factual, deterministic, focused',
'0.4 - 0.7: Balanced, natural, versatile',
'0.8 - 1.0: Creative, diverse, exploratory',
],
],
[
'id' => 'max_tokens',
'title' => 'Max Tokens',
'content' => 'Limit the length of the AI response. Setting an appropriate token limit helps control response length and cost.',
'tips' => [
'Short responses: 100-300 tokens',
'Medium responses: 500-1000 tokens',
'Long responses: 1500+ tokens',
],
],
[
'id' => 'best_practices',
'title' => 'Best Practices',
'content' => 'Follow these guidelines to create effective prompts:',
'tips' => [
'Be specific and clear about your requirements',
'Provide context and examples',
'Iterate and refine your prompts',
'Test with different models and settings',
'Keep prompts concise but complete',
'Use structured formats for complex tasks',
],
],
],
];
}
}