-
-
Notifications
You must be signed in to change notification settings - Fork 172
[Store] S3 Vectors store bridge #1554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aszenz
wants to merge
1
commit into
symfony:main
Choose a base branch
from
aszenz:feat/s3-vectors-store-bridge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?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\Component\Config\Definition\Configurator; | ||
|
|
||
| use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
|
|
||
| return (new ArrayNodeDefinition('s3vectors')) | ||
| ->useAttributeAsKey('name') | ||
| ->arrayPrototype() | ||
| ->children() | ||
| ->stringNode('client') | ||
| ->info('Service reference to an existing S3VectorsClient') | ||
| ->end() | ||
| ->arrayNode('configuration') | ||
| ->info('AsyncAws S3Vectors client configuration (used if client service is not provided)') | ||
| ->end() | ||
| ->stringNode('vector_bucket_name') | ||
| ->isRequired() | ||
| ->cannotBeEmpty() | ||
| ->end() | ||
| ->stringNode('index_name')->end() | ||
| ->arrayNode('filter') | ||
| ->info('Default filter for queries') | ||
| ->end() | ||
| ->integerNode('top_k') | ||
| ->info('Default number of results to return') | ||
| ->defaultValue(3) | ||
| ->end() | ||
| ->end() | ||
| ->end(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /.github export-ignore | ||
| /.gitattributes export-ignore | ||
| /.gitignore export-ignore | ||
| /phpstan.dist.neon export-ignore | ||
| /phpunit.xml.dist export-ignore | ||
| /Tests export-ignore |
8 changes: 8 additions & 0 deletions
8
src/store/src/Bridge/S3Vectors/.github/PULL_REQUEST_TEMPLATE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Please do not submit any Pull Requests here. They will be closed. | ||
| --- | ||
|
|
||
| Please submit your PR here instead: | ||
| https://github.com/symfony/ai | ||
|
|
||
| This repository is what we call a "subtree split": a read-only subset of that main repository. | ||
| We're looking forward to your PR there! |
20 changes: 20 additions & 0 deletions
20
src/store/src/Bridge/S3Vectors/.github/workflows/close-pull-request.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Close Pull Request | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened] | ||
|
|
||
| jobs: | ||
| run: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: superbrothers/close-pull-request@v3 | ||
| with: | ||
| comment: | | ||
| Thanks for your Pull Request! We love contributions. | ||
| However, you should instead open your PR on the main repository: | ||
| https://github.com/symfony/ai | ||
| This repository is what we call a "subtree split": a read-only subset of that main repository. | ||
| We're looking forward to your PR there! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /composer.lock | ||
| /phpunit.xml | ||
| /.phpunit.result.cache | ||
| /phpstan.neon | ||
| /vendor/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| CHANGELOG | ||
| ========= | ||
|
|
||
| 0.4 | ||
| --- | ||
|
|
||
| * Add the bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Copyright (c) 2026-present Fabien Potencier | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is furnished | ||
| to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # AWS S3 Vectors Store Bridge for Symfony AI | ||
|
|
||
| This bridge provides integration between Symfony AI Store and AWS S3 Vectors for vector storage and similarity search. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| composer require symfony/ai-s3vectors-store | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```php | ||
| use AsyncAws\S3Vectors\S3VectorsClient; | ||
| use Symfony\AI\Store\Bridge\S3Vectors\Store; | ||
|
|
||
| $client = new S3VectorsClient([ | ||
| 'region' => 'us-east-1', | ||
| ]); | ||
|
|
||
| $store = new Store( | ||
| client: $client, | ||
| vectorBucketName: 'my-vector-bucket', | ||
| indexName: 'my-index', | ||
| filter: [], // Optional: default filter for queries | ||
| topK: 3, // Optional: default number of results | ||
| ); | ||
|
|
||
| // Setup the vector bucket and index | ||
| $store->setup([ | ||
| 'dimension' => 1536, | ||
| 'distanceMetric' => \AsyncAws\S3Vectors\Enum\DistanceMetric::COSINE, // Optional | ||
| 'dataType' => \AsyncAws\S3Vectors\Enum\DataType::FLOAT32, // Optional | ||
| 'encryption' => ['kmsKeyId' => 'your-kms-key-id'], // Optional | ||
| 'tags' => ['env' => 'production'], // Optional | ||
| ]); | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```php | ||
| use Symfony\AI\Platform\Vector\Vector; | ||
| use Symfony\AI\Store\Document\Metadata; | ||
| use Symfony\AI\Store\Document\VectorDocument; | ||
| use Symfony\Component\Uid\Uuid; | ||
|
|
||
| // Add documents | ||
| $document = new VectorDocument( | ||
| id: Uuid::v4(), | ||
| vector: new Vector([0.1, 0.2, 0.3, ...]), | ||
| metadata: new Metadata(['title' => 'My Document']) | ||
| ); | ||
| $store->add($document); | ||
|
|
||
| // Query similar vectors | ||
| $results = $store->query( | ||
| vector: new Vector([0.1, 0.2, 0.3, ...]), | ||
| options: [ | ||
| 'topK' => 5, | ||
| 'filter' => ['category' => 'documentation'], | ||
| ] | ||
| ); | ||
|
|
||
| foreach ($results as $result) { | ||
| echo $result->metadata['title'] . ' (score: ' . $result->score . ')' . PHP_EOL; | ||
| } | ||
|
|
||
| // Remove documents | ||
| $store->remove(['id1', 'id2']); | ||
|
|
||
| // Drop the index and bucket | ||
| $store->drop(); | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - Full CRUD operations for vector documents | ||
| - Similarity search with configurable distance metrics (cosine, euclidean) | ||
| - Metadata filtering support | ||
| - KMS encryption support | ||
| - Tag management | ||
| - Batch operations | ||
|
|
||
| ## Resources | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check the other Md files and add the last part from them here too |
||
| - [Contributing](https://symfony.com/doc/current/contributing/index.html) | ||
| - [Report issues](https://github.com/symfony/ai/issues) and | ||
| [send Pull Requests](https://github.com/symfony/ai/pulls) | ||
| in the [main Symfony AI repository](https://github.com/symfony/ai) | ||
| - [AWS S3 Vectors Documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vectors.html) | ||
| - [AsyncAws S3Vectors Package](https://github.com/async-aws/aws/tree/master/src/Service/S3Vectors) | ||
| - [Symfony AI Documentation](https://github.com/symfony/ai) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be moved inside the next foreach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any specific reason, all other stores throw exception before the foreach