Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/src/Blog/Embedder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

use Symfony\AI\Store\Document\Metadata;
use Symfony\AI\Store\Document\TextDocument;
use Symfony\AI\Store\Indexer;
use Symfony\AI\Store\IndexerInterface;

final readonly class Embedder
{
public function __construct(
private FeedLoader $loader,
private Indexer $indexer,
private IndexerInterface $indexer,
) {
}

Expand Down
3 changes: 2 additions & 1 deletion src/ai-bundle/src/AiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
use Symfony\AI\Store\Document\Vectorizer;
use Symfony\AI\Store\Indexer;
use Symfony\AI\Store\IndexerInterface;
use Symfony\AI\Store\StoreInterface;
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\Attribute\Target;
Expand Down Expand Up @@ -144,7 +145,7 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
$this->processIndexerConfig($indexerName, $indexer, $builder);
}
if (1 === \count($config['indexer']) && isset($indexerName)) {
$builder->setAlias(Indexer::class, 'ai.indexer.'.$indexerName);
$builder->setAlias(IndexerInterface::class, 'ai.indexer.'.$indexerName);
}

$builder->registerAttributeForAutoconfiguration(AsTool::class, static function (ChildDefinition $definition, AsTool $attribute): void {
Expand Down
2 changes: 1 addition & 1 deletion src/store/src/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final readonly class Indexer
final readonly class Indexer implements IndexerInterface
{
public function __construct(
private Vectorizer $vectorizer,
Expand Down
28 changes: 28 additions & 0 deletions src/store/src/IndexerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\AI\Store;

use Symfony\AI\Store\Document\TextDocument;

/**
* Converts a collection of TextDocuments into VectorDocuments and pushes them to a store implementation.
*
* @author Oskar Stark <oskarstark@googlemail.com>
*/
interface IndexerInterface
{
/**
* @param TextDocument|iterable<TextDocument> $documents
* @param int $chunkSize number of documents to vectorize and store in one batch
*/
public function index(TextDocument|iterable $documents, int $chunkSize = 50): void;
}