value instanceof Stringable)) { return null; } $text = $carProperty->type->humanReadable() . ': ' . (string) $carProperty->value; if ($carRevision !== null) { $text .= ' - ' . $carRevision->name; } if ($brand !== null) { $text .= ', ' . $brand->name; } $persistedEmbedding = $this->embeddingRepository->findByPhrase($text); if ($persistedEmbedding) { return $persistedEmbedding; } $largeEmbedding = $this->aiClient->embedTextLarge($text); $smallEmbedding = $this->aiClient->embedTextSmall($text); $embedding = new Embedding(EmbeddingId::generate(), $text, $largeEmbedding, $smallEmbedding); $this->embeddingRepository->save($embedding); return $embedding; } }