From 92f2baeb1ae9d4eeb0927f0d6f25ceb576648295 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Thu, 13 Nov 2025 10:05:47 -0700 Subject: [PATCH 01/10] Add Pinecone ManagedStore --- .../src/Bridge/Pinecone/ManagedStore.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/store/src/Bridge/Pinecone/ManagedStore.php diff --git a/src/store/src/Bridge/Pinecone/ManagedStore.php b/src/store/src/Bridge/Pinecone/ManagedStore.php new file mode 100644 index 000000000..86d916a61 --- /dev/null +++ b/src/store/src/Bridge/Pinecone/ManagedStore.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\AI\Store\Bridge\Pinecone; + +use Probots\Pinecone\Client; +use Symfony\AI\Store\Exception\RuntimeException; +use Symfony\AI\Store\ManagedStoreInterface; + +final class ManagedStore implements ManagedStoreInterface +{ + public function __construct( + private readonly Client $pinecone, + private readonly string $indexName, + private readonly int $dimension, + private readonly string $metric, + private readonly string $cloud, + private readonly string $region, + ) { + if (!class_exists(Client::class)) { + throw new RuntimeException('For using the Pinecone as retrieval vector store, the probots-io/pinecone-php package is required. Try running "composer require probots-io/pinecone-php".'); + } + } + + public function setup(array $options = []): void + { + $this->pinecone + ->control() + ->index($this->indexName) + ->createServerless($this->dimension, $this->metric, $this->cloud, $this->region); + } + + public function drop(): void + { + $this->pinecone + ->control() + ->index($this->indexName) + ->delete(); + } +} From ebc6e0ab904b84c2ddd6e85d1012951b0a3ceccc Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Thu, 13 Nov 2025 17:51:47 -0700 Subject: [PATCH 02/10] id: support more types and cast to uuid --- src/store/src/Document/VectorDocument.php | 9 ++++++- .../tests/Document/VectorDocumentTest.php | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/store/src/Document/VectorDocument.php b/src/store/src/Document/VectorDocument.php index 861f0d882..af6f108c1 100644 --- a/src/store/src/Document/VectorDocument.php +++ b/src/store/src/Document/VectorDocument.php @@ -19,12 +19,19 @@ */ final class VectorDocument { + public readonly int|string|Uuid $id; + public function __construct( - public readonly Uuid $id, + int|string|Uuid $id, public readonly VectorInterface $vector, public readonly Metadata $metadata = new Metadata(), public readonly ?float $score = null, ) { + if (\is_string($id) && Uuid::isValid($id)) { + $this->id = Uuid::fromString($id); + } else { + $this->id = $id; + } } /** diff --git a/src/store/tests/Document/VectorDocumentTest.php b/src/store/tests/Document/VectorDocumentTest.php index 54a5c2f82..ac692f5a9 100644 --- a/src/store/tests/Document/VectorDocumentTest.php +++ b/src/store/tests/Document/VectorDocumentTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; +use Symfony\AI\Platform\Vector\NullVector; use Symfony\AI\Platform\Vector\Vector; use Symfony\AI\Store\Document\Metadata; use Symfony\AI\Store\Document\VectorDocument; @@ -25,6 +26,29 @@ */ final class VectorDocumentTest extends TestCase { + #[TestWith([1])] + #[TestWith(['id'])] + #[TestWith(['uuid'])] + public function testConstructorIdSupportsManyTypes(int|string $id) + { + if ('uuid' === $id) { + $id = Uuid::v4(); + } + + $document = new VectorDocument($id, new NullVector()); + + $this->assertSame($id, $document->id); + } + + #[TestDox('Automatically convert strings in UUID format to Uuid instances')] + public function testConstructorConvertIdToUuid() + { + $id = Uuid::v4()->toString(); + $document = new VectorDocument($id, new NullVector()); + + $this->assertInstanceOf(Uuid::class, $document->id); + } + #[TestDox('Creates document with required parameters only')] public function testConstructorWithRequiredParameters() { From 6701f7df1705d6c2fa7b0268d1532478c27bc388 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Thu, 13 Nov 2025 18:02:01 -0700 Subject: [PATCH 03/10] remove sneaky code --- .../src/Bridge/Pinecone/ManagedStore.php | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/store/src/Bridge/Pinecone/ManagedStore.php diff --git a/src/store/src/Bridge/Pinecone/ManagedStore.php b/src/store/src/Bridge/Pinecone/ManagedStore.php deleted file mode 100644 index 86d916a61..000000000 --- a/src/store/src/Bridge/Pinecone/ManagedStore.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\AI\Store\Bridge\Pinecone; - -use Probots\Pinecone\Client; -use Symfony\AI\Store\Exception\RuntimeException; -use Symfony\AI\Store\ManagedStoreInterface; - -final class ManagedStore implements ManagedStoreInterface -{ - public function __construct( - private readonly Client $pinecone, - private readonly string $indexName, - private readonly int $dimension, - private readonly string $metric, - private readonly string $cloud, - private readonly string $region, - ) { - if (!class_exists(Client::class)) { - throw new RuntimeException('For using the Pinecone as retrieval vector store, the probots-io/pinecone-php package is required. Try running "composer require probots-io/pinecone-php".'); - } - } - - public function setup(array $options = []): void - { - $this->pinecone - ->control() - ->index($this->indexName) - ->createServerless($this->dimension, $this->metric, $this->cloud, $this->region); - } - - public function drop(): void - { - $this->pinecone - ->control() - ->index($this->indexName) - ->delete(); - } -} From f2860b8a1a7e30f8b9bb0353b9b7e700c547dea9 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Fri, 14 Nov 2025 13:47:49 -0700 Subject: [PATCH 04/10] support more types in TextDocument --- src/store/src/Document/TextDocument.php | 12 ++++++++-- src/store/tests/Document/TextDocumentTest.php | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/store/src/Document/TextDocument.php b/src/store/src/Document/TextDocument.php index eefac3f31..db17469af 100644 --- a/src/store/src/Document/TextDocument.php +++ b/src/store/src/Document/TextDocument.php @@ -19,14 +19,22 @@ */ final class TextDocument implements EmbeddableDocumentInterface { + private readonly int|string|Uuid $id; + public function __construct( - private readonly Uuid $id, + int|string|Uuid $id, private readonly string $content, private readonly Metadata $metadata = new Metadata(), ) { if ('' === trim($this->content)) { throw new InvalidArgumentException('The content shall not be an empty string.'); } + + if (\is_string($id) && Uuid::isValid($id)) { + $this->id = Uuid::fromString($id); + } else { + $this->id = $id; + } } public function withContent(string $content): self @@ -34,7 +42,7 @@ public function withContent(string $content): self return new self($this->id, $content, $this->metadata); } - public function getId(): Uuid + public function getId(): int|string|Uuid { return $this->id; } diff --git a/src/store/tests/Document/TextDocumentTest.php b/src/store/tests/Document/TextDocumentTest.php index 5f9c876ad..fd28fe272 100644 --- a/src/store/tests/Document/TextDocumentTest.php +++ b/src/store/tests/Document/TextDocumentTest.php @@ -22,6 +22,29 @@ final class TextDocumentTest extends TestCase { + #[TestWith([1])] + #[TestWith(['id'])] + #[TestWith(['uuid'])] + public function testConstructorIdSupportsManyTypes(int|string $id) + { + if ('uuid' === $id) { + $id = Uuid::v4(); + } + + $document = new TextDocument($id, 'content'); + + $this->assertSame($id, $document->getId()); + } + + #[TestDox('Automatically convert strings in UUID format to Uuid instances')] + public function testConstructorConvertIdToUuid() + { + $id = Uuid::v4()->toString(); + $document = new TextDocument($id, 'content'); + + $this->assertInstanceOf(Uuid::class, $document->getId()); + } + #[TestDox('Creates document with valid content and metadata')] public function testConstructorWithValidContent() { From 4ab61fa5fb2b31c3b47c06ab2ad5d93097d48347 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Fri, 14 Nov 2025 13:52:27 -0700 Subject: [PATCH 05/10] fix places where VectorDocument is intantiated --- src/store/src/Bridge/Azure/SearchStore.php | 2 +- src/store/src/Bridge/ChromaDb/Store.php | 2 +- src/store/src/Bridge/ClickHouse/Store.php | 2 +- src/store/src/Bridge/Cloudflare/Store.php | 2 +- src/store/src/Bridge/Local/CacheStore.php | 2 +- src/store/src/Bridge/Manticore/Store.php | 2 +- src/store/src/Bridge/Neo4j/Store.php | 2 +- src/store/src/Bridge/Pinecone/Store.php | 2 +- src/store/src/Bridge/Postgres/Store.php | 2 +- src/store/src/Bridge/Qdrant/Store.php | 2 +- src/store/src/Bridge/Redis/Store.php | 2 +- src/store/src/Bridge/Supabase/Store.php | 2 +- src/store/src/Bridge/SurrealDb/Store.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/store/src/Bridge/Azure/SearchStore.php b/src/store/src/Bridge/Azure/SearchStore.php index 6e6dc5fed..17ec696ef 100644 --- a/src/store/src/Bridge/Azure/SearchStore.php +++ b/src/store/src/Bridge/Azure/SearchStore.php @@ -89,7 +89,7 @@ private function convertToIndexableArray(VectorDocument $document): array private function convertToVectorDocument(array $data): VectorDocument { return new VectorDocument( - id: Uuid::fromString($data['id']), + id: $data['id'], vector: !\array_key_exists($this->vectorFieldName, $data) || null === $data[$this->vectorFieldName] ? new NullVector() : new Vector($data[$this->vectorFieldName]), diff --git a/src/store/src/Bridge/ChromaDb/Store.php b/src/store/src/Bridge/ChromaDb/Store.php index 3f29f44e6..750a10d7e 100644 --- a/src/store/src/Bridge/ChromaDb/Store.php +++ b/src/store/src/Bridge/ChromaDb/Store.php @@ -68,7 +68,7 @@ public function query(Vector $vector, array $options = []): array $documents = []; for ($i = 0; $i < \count($queryResponse->metadatas[0]); ++$i) { $documents[] = new VectorDocument( - id: Uuid::fromString($queryResponse->ids[0][$i]), + id: $queryResponse->ids[0][$i], vector: new Vector($queryResponse->embeddings[0][$i]), metadata: new Metadata($queryResponse->metadatas[0][$i]), ); diff --git a/src/store/src/Bridge/ClickHouse/Store.php b/src/store/src/Bridge/ClickHouse/Store.php index 5f4f4b84f..699f01da2 100644 --- a/src/store/src/Bridge/ClickHouse/Store.php +++ b/src/store/src/Bridge/ClickHouse/Store.php @@ -96,7 +96,7 @@ public function query(Vector $vector, array $options = [], ?float $minScore = nu $documents = []; foreach ($results as $result) { $documents[] = new VectorDocument( - id: Uuid::fromString($result['id']), + id: $result['id'], vector: new Vector($result['embedding']), metadata: new Metadata(json_decode($result['metadata'] ?? '{}', true, 512, \JSON_THROW_ON_ERROR)), score: $result['score'], diff --git a/src/store/src/Bridge/Cloudflare/Store.php b/src/store/src/Bridge/Cloudflare/Store.php index f248e15c9..c133bf13c 100644 --- a/src/store/src/Bridge/Cloudflare/Store.php +++ b/src/store/src/Bridge/Cloudflare/Store.php @@ -136,7 +136,7 @@ private function convertToVectorDocument(array $data): VectorDocument : new Vector($data['values']); return new VectorDocument( - id: Uuid::fromString($id), + id: $id, vector: $vector, metadata: new Metadata($data['metadata']), score: $data['score'] ?? null diff --git a/src/store/src/Bridge/Local/CacheStore.php b/src/store/src/Bridge/Local/CacheStore.php index ad85bea40..ce633f129 100644 --- a/src/store/src/Bridge/Local/CacheStore.php +++ b/src/store/src/Bridge/Local/CacheStore.php @@ -80,7 +80,7 @@ public function query(Vector $vector, array $options = []): array $documents = $this->cache->get($this->cacheKey, static fn (): array => []); $vectorDocuments = array_map(static fn (array $document): VectorDocument => new VectorDocument( - id: Uuid::fromString($document['id']), + id: $document['id'], vector: new Vector($document['vector']), metadata: new Metadata($document['metadata']), ), $documents); diff --git a/src/store/src/Bridge/Manticore/Store.php b/src/store/src/Bridge/Manticore/Store.php index f5b9f51ff..1334e2237 100644 --- a/src/store/src/Bridge/Manticore/Store.php +++ b/src/store/src/Bridge/Manticore/Store.php @@ -148,7 +148,7 @@ private function convertToVectorDocument(array $data): VectorDocument : new Vector($payload[$this->field]); return new VectorDocument( - id: Uuid::fromString($payload['uuid']), + id: $payload['uuid'], vector: $vector, metadata: new Metadata($payload['metadata'] ?? []), score: $data['_knn_dist'] ?? null diff --git a/src/store/src/Bridge/Neo4j/Store.php b/src/store/src/Bridge/Neo4j/Store.php index a69d2ab92..8105a92c4 100644 --- a/src/store/src/Bridge/Neo4j/Store.php +++ b/src/store/src/Bridge/Neo4j/Store.php @@ -115,7 +115,7 @@ private function convertToVectorDocument(array $data): VectorDocument : new Vector($payload['properties'][$this->embeddingsField]); return new VectorDocument( - id: Uuid::fromString($id), + id: $id, vector: $vector, metadata: new Metadata(json_decode($payload['properties']['metadata'], true)), score: $data[1] ?? null diff --git a/src/store/src/Bridge/Pinecone/Store.php b/src/store/src/Bridge/Pinecone/Store.php index ac5a01d22..c98d1145b 100644 --- a/src/store/src/Bridge/Pinecone/Store.php +++ b/src/store/src/Bridge/Pinecone/Store.php @@ -70,7 +70,7 @@ public function query(Vector $vector, array $options = []): array $documents = []; foreach ($result->json()['matches'] as $match) { $documents[] = new VectorDocument( - id: Uuid::fromString($match['id']), + id: $match['id']), vector: new Vector($match['values']), metadata: new Metadata($match['metadata']), score: $match['score'], diff --git a/src/store/src/Bridge/Postgres/Store.php b/src/store/src/Bridge/Postgres/Store.php index cd5ebf1dd..b4b9357d3 100644 --- a/src/store/src/Bridge/Postgres/Store.php +++ b/src/store/src/Bridge/Postgres/Store.php @@ -173,7 +173,7 @@ public function query(Vector $vector, array $options = []): array $documents = []; foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $result) { $documents[] = new VectorDocument( - id: Uuid::fromString($result['id']), + id: $result['id'], vector: new Vector($this->fromPgvector($result['embedding'])), metadata: new Metadata(json_decode($result['metadata'] ?? '{}', true, 512, \JSON_THROW_ON_ERROR)), score: $result['score'], diff --git a/src/store/src/Bridge/Qdrant/Store.php b/src/store/src/Bridge/Qdrant/Store.php index e0682b39e..0ec1c5281 100644 --- a/src/store/src/Bridge/Qdrant/Store.php +++ b/src/store/src/Bridge/Qdrant/Store.php @@ -151,7 +151,7 @@ private function convertToVectorDocument(array $data): VectorDocument : new Vector($data['vector']); return new VectorDocument( - id: Uuid::fromString($id), + id: $id, vector: $vector, metadata: new Metadata($data['payload']), score: $data['score'] ?? null diff --git a/src/store/src/Bridge/Redis/Store.php b/src/store/src/Bridge/Redis/Store.php index fd4b6b218..97267a4c2 100644 --- a/src/store/src/Bridge/Redis/Store.php +++ b/src/store/src/Bridge/Redis/Store.php @@ -168,7 +168,7 @@ public function query(Vector $vector, array $options = []): array } $documents[] = new VectorDocument( - id: Uuid::fromString($data['$.id']), + id: $data['$.id'], vector: new Vector($data['$.embedding'] ?? []), metadata: new Metadata($data['$.metadata'] ?? []), score: $score, diff --git a/src/store/src/Bridge/Supabase/Store.php b/src/store/src/Bridge/Supabase/Store.php index 8a2d558e7..0a6f2b42f 100644 --- a/src/store/src/Bridge/Supabase/Store.php +++ b/src/store/src/Bridge/Supabase/Store.php @@ -138,7 +138,7 @@ public function query(Vector $vector, array $options = []): array $metadata = \is_array($record['metadata']) ? $record['metadata'] : json_decode($record['metadata'], true, 512, \JSON_THROW_ON_ERROR); $documents[] = new VectorDocument( - id: Uuid::fromString($record['id']), + id: $record['id'], vector: new Vector($embedding), metadata: new Metadata($metadata), score: (float) $record['score'], diff --git a/src/store/src/Bridge/SurrealDb/Store.php b/src/store/src/Bridge/SurrealDb/Store.php index 5605a91b3..998d7444b 100644 --- a/src/store/src/Bridge/SurrealDb/Store.php +++ b/src/store/src/Bridge/SurrealDb/Store.php @@ -147,7 +147,7 @@ private function convertToVectorDocument(array $data): VectorDocument unset($data['_metadata']['_id']); return new VectorDocument( - id: Uuid::fromString($id), + id: $id, vector: $vector, metadata: new Metadata($data['_metadata']), ); From 96a2d62c1f9c8777e61fd0937f9f9ce96edce2ef Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Fri, 14 Nov 2025 13:52:46 -0700 Subject: [PATCH 06/10] update reference in docs --- docs/cookbook/rag-implementation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cookbook/rag-implementation.rst b/docs/cookbook/rag-implementation.rst index cdccb395b..043562436 100644 --- a/docs/cookbook/rag-implementation.rst +++ b/docs/cookbook/rag-implementation.rst @@ -205,7 +205,7 @@ Document Loading Strategies $articles = $articleRepository->findAll(); $documents = array_map( fn($article) => new TextDocument( - id: Uuid::fromString($article->getId()), + id: $article->getId(), content: $article->getTitle().PHP_EOL.$article->getContent(), metadata: new Metadata(['author' => $article->getAuthor()]) ), From f9d44eb9be75e918934aea830f460e0a1637c202 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Fri, 14 Nov 2025 14:03:52 -0700 Subject: [PATCH 07/10] fix Pinecone store --- src/store/src/Bridge/Pinecone/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/src/Bridge/Pinecone/Store.php b/src/store/src/Bridge/Pinecone/Store.php index c98d1145b..4f3f8eceb 100644 --- a/src/store/src/Bridge/Pinecone/Store.php +++ b/src/store/src/Bridge/Pinecone/Store.php @@ -70,7 +70,7 @@ public function query(Vector $vector, array $options = []): array $documents = []; foreach ($result->json()['matches'] as $match) { $documents[] = new VectorDocument( - id: $match['id']), + id: $match['id'], vector: new Vector($match['values']), metadata: new Metadata($match['metadata']), score: $match['score'], From ab54367816649f459ac7161745d73bfb01355fcb Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Fri, 14 Nov 2025 14:05:19 -0700 Subject: [PATCH 08/10] Fix PHP CS --- src/store/src/Bridge/Azure/SearchStore.php | 1 - src/store/src/Bridge/ChromaDb/Store.php | 1 - src/store/src/Bridge/ClickHouse/Store.php | 1 - src/store/src/Bridge/Cloudflare/Store.php | 1 - src/store/src/Bridge/Local/CacheStore.php | 1 - src/store/src/Bridge/Manticore/Store.php | 1 - src/store/src/Bridge/Neo4j/Store.php | 1 - src/store/src/Bridge/Pinecone/Store.php | 1 - src/store/src/Bridge/Postgres/Store.php | 1 - src/store/src/Bridge/Qdrant/Store.php | 1 - src/store/src/Bridge/Redis/Store.php | 1 - src/store/src/Bridge/Supabase/Store.php | 1 - src/store/src/Bridge/SurrealDb/Store.php | 1 - 13 files changed, 13 deletions(-) diff --git a/src/store/src/Bridge/Azure/SearchStore.php b/src/store/src/Bridge/Azure/SearchStore.php index 17ec696ef..a581b7e2a 100644 --- a/src/store/src/Bridge/Azure/SearchStore.php +++ b/src/store/src/Bridge/Azure/SearchStore.php @@ -16,7 +16,6 @@ use Symfony\AI\Store\Document\Metadata; use Symfony\AI\Store\Document\VectorDocument; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/ChromaDb/Store.php b/src/store/src/Bridge/ChromaDb/Store.php index 750a10d7e..467efa3db 100644 --- a/src/store/src/Bridge/ChromaDb/Store.php +++ b/src/store/src/Bridge/ChromaDb/Store.php @@ -17,7 +17,6 @@ use Symfony\AI\Store\Document\VectorDocument; use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; /** * @author Christopher Hertel diff --git a/src/store/src/Bridge/ClickHouse/Store.php b/src/store/src/Bridge/ClickHouse/Store.php index 699f01da2..b39bed510 100644 --- a/src/store/src/Bridge/ClickHouse/Store.php +++ b/src/store/src/Bridge/ClickHouse/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; diff --git a/src/store/src/Bridge/Cloudflare/Store.php b/src/store/src/Bridge/Cloudflare/Store.php index c133bf13c..6186ba268 100644 --- a/src/store/src/Bridge/Cloudflare/Store.php +++ b/src/store/src/Bridge/Cloudflare/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/Local/CacheStore.php b/src/store/src/Bridge/Local/CacheStore.php index ce633f129..013fd3fc0 100644 --- a/src/store/src/Bridge/Local/CacheStore.php +++ b/src/store/src/Bridge/Local/CacheStore.php @@ -19,7 +19,6 @@ use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\Cache\CacheInterface; /** diff --git a/src/store/src/Bridge/Manticore/Store.php b/src/store/src/Bridge/Manticore/Store.php index 1334e2237..eac744fca 100644 --- a/src/store/src/Bridge/Manticore/Store.php +++ b/src/store/src/Bridge/Manticore/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/Neo4j/Store.php b/src/store/src/Bridge/Neo4j/Store.php index 8105a92c4..5c37d6685 100644 --- a/src/store/src/Bridge/Neo4j/Store.php +++ b/src/store/src/Bridge/Neo4j/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/Pinecone/Store.php b/src/store/src/Bridge/Pinecone/Store.php index 4f3f8eceb..c3b3e5e8f 100644 --- a/src/store/src/Bridge/Pinecone/Store.php +++ b/src/store/src/Bridge/Pinecone/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Document\VectorDocument; use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; /** * @author Christopher Hertel diff --git a/src/store/src/Bridge/Postgres/Store.php b/src/store/src/Bridge/Postgres/Store.php index b4b9357d3..7e2f2e405 100644 --- a/src/store/src/Bridge/Postgres/Store.php +++ b/src/store/src/Bridge/Postgres/Store.php @@ -19,7 +19,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; /** * Requires PostgreSQL with pgvector extension. diff --git a/src/store/src/Bridge/Qdrant/Store.php b/src/store/src/Bridge/Qdrant/Store.php index 0ec1c5281..83fb70117 100644 --- a/src/store/src/Bridge/Qdrant/Store.php +++ b/src/store/src/Bridge/Qdrant/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/Redis/Store.php b/src/store/src/Bridge/Redis/Store.php index 97267a4c2..a7f48715b 100644 --- a/src/store/src/Bridge/Redis/Store.php +++ b/src/store/src/Bridge/Redis/Store.php @@ -18,7 +18,6 @@ use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; /** * @author Grégoire Pineau diff --git a/src/store/src/Bridge/Supabase/Store.php b/src/store/src/Bridge/Supabase/Store.php index 0a6f2b42f..d9c52efa9 100644 --- a/src/store/src/Bridge/Supabase/Store.php +++ b/src/store/src/Bridge/Supabase/Store.php @@ -17,7 +17,6 @@ use Symfony\AI\Store\Exception\InvalidArgumentException; use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** diff --git a/src/store/src/Bridge/SurrealDb/Store.php b/src/store/src/Bridge/SurrealDb/Store.php index 998d7444b..e6865514d 100644 --- a/src/store/src/Bridge/SurrealDb/Store.php +++ b/src/store/src/Bridge/SurrealDb/Store.php @@ -19,7 +19,6 @@ use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\ManagedStoreInterface; use Symfony\AI\Store\StoreInterface; -use Symfony\Component\Uid\Uuid; use Symfony\Contracts\HttpClient\HttpClientInterface; /** From 26c88ed28068d7bdc371f6118b3c427ab76f2e6a Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Tue, 18 Nov 2025 09:55:07 -0700 Subject: [PATCH 09/10] remove Uuid auto-casting --- src/store/src/Document/TextDocument.php | 10 +--------- src/store/src/Document/VectorDocument.php | 9 +-------- src/store/tests/Document/TextDocumentTest.php | 9 --------- src/store/tests/Document/VectorDocumentTest.php | 9 --------- 4 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/store/src/Document/TextDocument.php b/src/store/src/Document/TextDocument.php index db17469af..cd3b5da54 100644 --- a/src/store/src/Document/TextDocument.php +++ b/src/store/src/Document/TextDocument.php @@ -19,22 +19,14 @@ */ final class TextDocument implements EmbeddableDocumentInterface { - private readonly int|string|Uuid $id; - public function __construct( - int|string|Uuid $id, + private readonly int|string|Uuid $id, private readonly string $content, private readonly Metadata $metadata = new Metadata(), ) { if ('' === trim($this->content)) { throw new InvalidArgumentException('The content shall not be an empty string.'); } - - if (\is_string($id) && Uuid::isValid($id)) { - $this->id = Uuid::fromString($id); - } else { - $this->id = $id; - } } public function withContent(string $content): self diff --git a/src/store/src/Document/VectorDocument.php b/src/store/src/Document/VectorDocument.php index af6f108c1..b076ae34d 100644 --- a/src/store/src/Document/VectorDocument.php +++ b/src/store/src/Document/VectorDocument.php @@ -19,19 +19,12 @@ */ final class VectorDocument { - public readonly int|string|Uuid $id; - public function __construct( - int|string|Uuid $id, + public readonly int|string|Uuid $id, public readonly VectorInterface $vector, public readonly Metadata $metadata = new Metadata(), public readonly ?float $score = null, ) { - if (\is_string($id) && Uuid::isValid($id)) { - $this->id = Uuid::fromString($id); - } else { - $this->id = $id; - } } /** diff --git a/src/store/tests/Document/TextDocumentTest.php b/src/store/tests/Document/TextDocumentTest.php index fd28fe272..0a36eaad5 100644 --- a/src/store/tests/Document/TextDocumentTest.php +++ b/src/store/tests/Document/TextDocumentTest.php @@ -36,15 +36,6 @@ public function testConstructorIdSupportsManyTypes(int|string $id) $this->assertSame($id, $document->getId()); } - #[TestDox('Automatically convert strings in UUID format to Uuid instances')] - public function testConstructorConvertIdToUuid() - { - $id = Uuid::v4()->toString(); - $document = new TextDocument($id, 'content'); - - $this->assertInstanceOf(Uuid::class, $document->getId()); - } - #[TestDox('Creates document with valid content and metadata')] public function testConstructorWithValidContent() { diff --git a/src/store/tests/Document/VectorDocumentTest.php b/src/store/tests/Document/VectorDocumentTest.php index ac692f5a9..2b94a5c9b 100644 --- a/src/store/tests/Document/VectorDocumentTest.php +++ b/src/store/tests/Document/VectorDocumentTest.php @@ -40,15 +40,6 @@ public function testConstructorIdSupportsManyTypes(int|string $id) $this->assertSame($id, $document->id); } - #[TestDox('Automatically convert strings in UUID format to Uuid instances')] - public function testConstructorConvertIdToUuid() - { - $id = Uuid::v4()->toString(); - $document = new VectorDocument($id, new NullVector()); - - $this->assertInstanceOf(Uuid::class, $document->id); - } - #[TestDox('Creates document with required parameters only')] public function testConstructorWithRequiredParameters() { From c2ae175f8a6f14add6a7b98f7855590d95c266d3 Mon Sep 17 00:00:00 2001 From: Diego Aguiar Date: Tue, 18 Nov 2025 10:15:32 -0700 Subject: [PATCH 10/10] fix broken tests --- src/store/tests/Bridge/Supabase/StoreTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/tests/Bridge/Supabase/StoreTest.php b/src/store/tests/Bridge/Supabase/StoreTest.php index c68627a59..b381481bb 100644 --- a/src/store/tests/Bridge/Supabase/StoreTest.php +++ b/src/store/tests/Bridge/Supabase/StoreTest.php @@ -146,7 +146,7 @@ public function testQuerySuccess() $this->assertCount(1, $result); $this->assertInstanceOf(VectorDocument::class, $result[0]); - $this->assertTrue($uuid->equals($result[0]->id)); + $this->assertSame($uuid->toRfc4122(), $result[0]->id); $this->assertSame([0.5, 0.6, 0.7], $result[0]->vector->getData()); $this->assertSame(['category' => 'test'], $result[0]->metadata->getArrayCopy()); $this->assertSame(0.85, $result[0]->score); @@ -178,12 +178,12 @@ public function testQueryHandlesMultipleResultsAndMultipleOptions() $this->assertCount(2, $result); $this->assertInstanceOf(VectorDocument::class, $result[0]); - $this->assertTrue($uuid1->equals($result[0]->id)); + $this->assertSame($uuid1->toRfc4122(), $result[0]->id); $this->assertSame([0.1, 0.2], $result[0]->vector->getData()); $this->assertSame(0.95, $result[0]->score); $this->assertSame(['type' => 'first'], $result[0]->metadata->getArrayCopy()); $this->assertInstanceOf(VectorDocument::class, $result[1]); - $this->assertTrue($uuid2->equals($result[1]->id)); + $this->assertSame($uuid2->toRfc4122(), $result[1]->id); $this->assertSame([0.3, 0.4], $result[1]->vector->getData()); $this->assertSame(0.85, $result[1]->score); $this->assertSame(['type' => 'second'], $result[1]->metadata->getArrayCopy()); @@ -211,7 +211,7 @@ public function testQueryParsesComplexMetadata() $metadata = $document->metadata->getArrayCopy(); $this->assertCount(1, $result); $this->assertInstanceOf(VectorDocument::class, $document); - $this->assertTrue($uuid->equals($document->id)); + $this->assertSame($uuid->toRfc4122(), $document->id); $this->assertSame([0.1, 0.2, 0.3, 0.4], $document->vector->getData()); $this->assertSame(0.92, $document->score); $this->assertSame('Test Document', $metadata['title']);