Harden vision vector search and embedding jobs.
Add point search, circuit-breaking, and safer gateway limits so artwork similarity lookups fail closed instead of hanging the request path.
This commit is contained in:
@@ -95,13 +95,34 @@ final class AiArtworkVectorSearchService
|
||||
*/
|
||||
private function searchMatchesForArtwork(Artwork $artwork, int $limit): array
|
||||
{
|
||||
$this->client->assertCircuitClosed();
|
||||
|
||||
/*
|
||||
* Reuse the artwork's already-indexed Qdrant vector when available.
|
||||
* A missing point is expected for older/rebuilt indexes, so retain the
|
||||
* existing image/CLIP fallback below.
|
||||
*/
|
||||
try {
|
||||
$pointMatches = $this->client->searchByPointId((int) $artwork->id, $limit);
|
||||
|
||||
if ($pointMatches !== null) {
|
||||
return $pointMatches;
|
||||
}
|
||||
} catch (VectorGatewayException $pointFailure) {
|
||||
$this->client->tripIfCircuitWorthy(
|
||||
[$pointFailure],
|
||||
'similar_ai_point',
|
||||
['artwork_id' => (int) $artwork->id],
|
||||
);
|
||||
|
||||
throw $pointFailure;
|
||||
}
|
||||
|
||||
$url = $this->imageUrl->fromArtwork($artwork);
|
||||
if ($url === null || $url === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->client->assertCircuitClosed();
|
||||
|
||||
$fileFailure = null;
|
||||
$fileGatewayAttempted = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user