54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Vision;
|
|
|
|
use App\Models\Artwork;
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
final class VectorService
|
|
{
|
|
public function __construct(
|
|
private readonly AiArtworkVectorSearchService $searchService,
|
|
private readonly ArtworkVectorIndexService $indexService,
|
|
) {
|
|
}
|
|
|
|
public function isConfigured(): bool
|
|
{
|
|
return $this->searchService->isConfigured();
|
|
}
|
|
|
|
/**
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
public function similarToArtwork(Artwork $artwork, int $limit = 12): array
|
|
{
|
|
return $this->searchService->similarToArtwork($artwork, $limit);
|
|
}
|
|
|
|
/**
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
public function searchByUploadedImage(UploadedFile $file, int $limit = 12): array
|
|
{
|
|
return $this->searchService->searchByUploadedImage($file, $limit);
|
|
}
|
|
|
|
/**
|
|
* @return array{url: string, metadata: array{content_type: string, category: string, user_id: string}}
|
|
*/
|
|
public function payloadForArtwork(Artwork $artwork): array
|
|
{
|
|
return $this->indexService->payloadForArtwork($artwork);
|
|
}
|
|
|
|
/**
|
|
* @return array{url: string, metadata: array{content_type: string, category: string, user_id: string}}
|
|
*/
|
|
public function upsertArtwork(Artwork $artwork): array
|
|
{
|
|
return $this->indexService->upsertArtwork($artwork);
|
|
}
|
|
} |