diff --git a/src/store/src/Document/Vectorizer.php b/src/store/src/Document/Vectorizer.php index 86ce2e364..1e3ee2133 100644 --- a/src/store/src/Document/Vectorizer.php +++ b/src/store/src/Document/Vectorizer.php @@ -19,7 +19,7 @@ * The Vectorizer encapsulates the logic to convert a collection of TextDocuments into VectorDocuments. It checks for * the model's capabilities to handle batch processing or handles it with HttpClient's concurrency feature. */ -final readonly class Vectorizer +final readonly class Vectorizer implements VectorizerInterface { public function __construct( private PlatformInterface $platform, diff --git a/src/store/src/Document/VectorizerInterface.php b/src/store/src/Document/VectorizerInterface.php new file mode 100644 index 000000000..2550e62a2 --- /dev/null +++ b/src/store/src/Document/VectorizerInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\AI\Store\Document; + +/** + * Interface for converting TextDocuments into VectorDocuments. + * + * @author Oskar Stark + */ +interface VectorizerInterface +{ + /** + * @param TextDocument[] $documents + * + * @return VectorDocument[] + */ + public function vectorizeDocuments(array $documents): array; +} diff --git a/src/store/src/Indexer.php b/src/store/src/Indexer.php index 385f10a5b..645b8e641 100644 --- a/src/store/src/Indexer.php +++ b/src/store/src/Indexer.php @@ -14,7 +14,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Symfony\AI\Store\Document\TextDocument; -use Symfony\AI\Store\Document\Vectorizer; +use Symfony\AI\Store\Document\VectorizerInterface; /** * Converts a collection of TextDocuments into VectorDocuments and pushes them to a store implementation. @@ -24,7 +24,7 @@ final readonly class Indexer { public function __construct( - private Vectorizer $vectorizer, + private VectorizerInterface $vectorizer, private StoreInterface $store, private LoggerInterface $logger = new NullLogger(), ) {