SuperSeller3000/src/Infrastructure/Messenger/Handler/PhotoUploadHandler.php
Simon Kuehn fddfd920f5 feat: add Symfony Messenger pipeline with AI agents and handlers
Messages and handlers for the full AI pipeline:
DraftArticle → Validation → SpecsResearch → PhotoUpload → EbayText →
JsonCoding → PublishToChannel / DeactivateListingMessage / TrackingPush /
UpdateStockOnChannels / OrderReceived.

OllamaClient and OllamaClientInterface provide the base LLM backend.
AI agents (EbayTextAgent, JsonCodingAgent, OllamaVisionAgent,
SpecsResearchAgent) wrap the client with task-specific prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:43:47 +00:00

51 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Infrastructure\Messenger\Handler;
use App\Domain\Pipeline\Repository\AIPipelineJobRepositoryInterface;
use App\Infrastructure\AI\Agent\OllamaVisionAgent;
use App\Infrastructure\Messenger\Message\PhotoUploadMessage;
use App\Infrastructure\Messenger\Message\SpecsResearchMessage;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Uid\Uuid;
#[AsMessageHandler]
final class PhotoUploadHandler
{
public function __construct(
private readonly OllamaVisionAgent $visionAgent,
private readonly AIPipelineJobRepositoryInterface $jobRepository,
private readonly MessageBusInterface $bus,
) {
}
public function __invoke(PhotoUploadMessage $message): void
{
$job = $this->jobRepository->findById(Uuid::fromString($message->jobId));
if (null === $job) {
return;
}
$job->markProcessing();
$this->jobRepository->save($job);
$result = $this->visionAgent->analyze($message->storedPhotoPath);
if ('' === $result['model']) {
$job->markNeedsReview('OllamaVisionAgent: no model name detected on nameplate');
$this->jobRepository->save($job);
return;
}
$this->bus->dispatch(new SpecsResearchMessage(
jobId: $message->jobId,
articleTypeId: $message->articleTypeId,
modelName: $result['model'],
serialNumber: $result['serial'],
));
}
}