Files
kupshop/bundles/KupShop/LLMBundle/TextObjects/ImageDescriptionField.php
2025-08-02 16:30:27 +02:00

28 lines
862 B
PHP

<?php
namespace KupShop\LLMBundle\TextObjects;
use KupShop\LLMBundle\Dto\TextPromptInput;
use KupShop\LLMBundle\Enum\PromptPlaceholder;
class ImageDescriptionField extends AbstractTextObject
{
public const LABEL = 'image_description';
protected const DESCRIPTION = 'Obrázek / Popis';
public function providesPlaceholders(): array
{
return array_merge(parent::providesPlaceholders(), [
PromptPlaceholder::PHOTO,
]);
}
protected function setPromptPlaceholders(TextPromptInput $prompt, ?string $entityType, ?int $entityId): void
{
if ($entityType == 'photos' && $entityId) {
$imageArray = getImage($entityId, null, null, 'default_feed');
$prompt->replacePlaceholder(PromptPlaceholder::PHOTO, $this->placeholdersCreator->getImageFromArray($imageArray));
}
}
}