optimizations
This commit is contained in:
54
app/Services/Vision/VectorService.php
Normal file
54
app/Services/Vision/VectorService.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user