Files
alfa-antique/Modules/AI/app/PromptTemplates/Blog/GenerateBlogTitleFromImageTemplate.php
Husanjonazamov 912e46b1de alfa-antiqye
2026-03-14 16:28:50 +05:00

41 lines
1.7 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Modules\AI\app\PromptTemplates\Blog;
use Modules\AI\app\Contracts\PromptTemplateInterface;
class GenerateBlogTitleFromImageTemplate implements PromptTemplateInterface
{
public function build(?string $context = null, ?string $langCode = null, ?string $description = null, ?array $options = null): string
{
$langCode ??= 'en';
$langCode = strtoupper($langCode);
$descriptionInstruction = !empty($description)
? "Additionally, consider the user's description: \"{$description}\" and incorporate it only if it adds clarity or relevance."
: "Ignore user description if irrelevant or missing.";
return <<<PROMPT
You are an advanced SEO content strategist, copywriter, and image recognition analyst.
Analyze the uploaded blog image provided by the user.
{$descriptionInstruction}
Your task:
Generate a clean, concise, and professional blog title closely related to the product or topic shown in the image — adjusted to match any meaningful user-provided context.
CRITICAL INSTRUCTION:
- The output must be 100% in {$langCode}.
- Do not include subjective phrases like “high quality”, “best”, or overly emotional language.
- Keep it short (3570 characters), simple, and optimized for online listings.
- Only return the title (plain text, no quotes).
IMPORTANT:
- If the image is irrelevant, unidentifiable, or meaningless → return only: INVALID_INPUT
- Do NOT apologize or explain anything in the response.
PROMPT;
}
public function getType(): string
{
return 'generate_blog_title_from_image';
}
}