Skip to content
Open
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
5 changes: 4 additions & 1 deletion examples/.env
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ AZURE_OPENAI_WHISPER_API_VERSION=
AZURE_LLAMA_BASEURL=
AZURE_LLAMA_KEY=

# For using Bedrock
# For using Bedrock and S3 Vectors
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=

# For S3 Vectors (store)
S3_VECTORS_BUCKET=

# Hugging Face Access Token
HUGGINGFACE_KEY=

Expand Down
11 changes: 11 additions & 0 deletions examples/commands/stores.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

require_once dirname(__DIR__).'/bootstrap.php';

use AsyncAws\S3Vectors\S3VectorsClient;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Tools\DsnParser;
use MongoDB\Client as MongoDbClient;
Expand All @@ -29,6 +30,7 @@
use Symfony\AI\Store\Bridge\Postgres\Store as PostgresStore;
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
use Symfony\AI\Store\Bridge\Redis\Store as RedisStore;
use Symfony\AI\Store\Bridge\S3Vectors\Store as S3VectorsStore;
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
Expand Down Expand Up @@ -119,6 +121,15 @@
'host' => env('REDIS_HOST'),
'port' => 6379,
]), 'symfony'),
// 's3vectors' => static fn (): S3VectorsStore => new S3VectorsStore(
// new S3VectorsClient([
// 'region' => env('AWS_DEFAULT_REGION'),
// 'accessKeyId' => env('AWS_ACCESS_KEY_ID'),
// 'accessKeySecret' => env('AWS_SECRET_ACCESS_KEY'),
// ]),
// env('S3_VECTORS_BUCKET'),
// 'symfony',
// ),
'surrealdb' => static fn (): SurrealDbStore => new SurrealDbStore(
httpClient: http_client(),
endpointUrl: env('SURREALDB_HOST'),
Expand Down
1 change: 1 addition & 0 deletions examples/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"symfony/ai-vertex-ai-platform": "^0.3",
"symfony/ai-voyage-platform": "^0.3",
"symfony/ai-weaviate-store": "^0.3",
"symfony/ai-s3vectors-store": "^0.4",
"symfony/ai-wikipedia-tool": "^0.3",
"symfony/ai-youtube-tool": "^0.3",
"symfony/console": "^7.4|^8.0",
Expand Down
3 changes: 2 additions & 1 deletion splitsh.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"ai-supabase-store": "src/store/src/Bridge/Supabase",
"ai-surreal-db-store": "src/store/src/Bridge/SurrealDb",
"ai-typesense-store": "src/store/src/Bridge/Typesense",
"ai-weaviate-store": "src/store/src/Bridge/Weaviate"
"ai-weaviate-store": "src/store/src/Bridge/Weaviate",
"ai-s3vectors-store": "src/store/src/Bridge/S3Vectors"
}
}
1 change: 1 addition & 0 deletions src/ai-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"symfony/ai-vertex-ai-platform": "^0.3",
"symfony/ai-voyage-platform": "^0.3",
"symfony/ai-weaviate-store": "^0.3",
"symfony/ai-s3vectors-store": "^0.4",
"symfony/expression-language": "^7.3|^8.0",
"symfony/security-core": "^7.3|^8.0",
"symfony/translation": "^7.3|^8.0"
Expand Down
1 change: 1 addition & 0 deletions src/ai-bundle/config/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
->append($import('store/postgres'))
->append($import('store/qdrant'))
->append($import('store/redis'))
->append($import('store/s3vectors'))
->append($import('store/supabase'))
->append($import('store/surrealdb'))
->append($import('store/typesense'))
Expand Down
39 changes: 39 additions & 0 deletions src/ai-bundle/config/store/s3vectors.php
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();
42 changes: 42 additions & 0 deletions src/ai-bundle/src/AiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
use Symfony\AI\Store\Bridge\Redis\Distance as RedisDistance;
use Symfony\AI\Store\Bridge\Redis\Store as RedisStore;
use Symfony\AI\Store\Bridge\S3Vectors\Store as S3VectorsStore;
use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore;
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
Expand Down Expand Up @@ -1939,6 +1940,47 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
$container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $type.'_'.$name);
}
}

if ('s3vectors' === $type) {
if (!ContainerBuilder::willBeAvailable('symfony/ai-s3vectors-store', S3VectorsStore::class, ['symfony/ai-bundle'])) {
Copy link
Contributor

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

Copy link
Contributor Author

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

throw new RuntimeException('S3Vectors store configuration requires "symfony/ai-s3vectors-store" package. Try running "composer require symfony/ai-s3vectors-store".');
}

foreach ($stores as $name => $store) {
if (isset($store['client'])) {
$s3VectorsClient = new Reference($store['client']);
} else {
$s3VectorsClient = new Definition(\AsyncAws\S3Vectors\S3VectorsClient::class);
$s3VectorsClient->setArguments([$store['configuration'] ?? []]);
}

$arguments = [
$s3VectorsClient,
$store['vector_bucket_name'],
$store['index_name'] ?? $name,
];

if (\array_key_exists('filter', $store)) {
$arguments[3] = $store['filter'];
}

if (\array_key_exists('top_k', $store)) {
$arguments[4] = $store['top_k'];
}

$definition = new Definition(S3VectorsStore::class);
$definition
->setLazy(true)
->setArguments($arguments)
->addTag('proxy', ['interface' => StoreInterface::class])
->addTag('proxy', ['interface' => ManagedStoreInterface::class])
->addTag('ai.store');

$container->setDefinition('ai.store.'.$type.'.'.$name, $definition);
$container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $name);
$container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $type.'_'.$name);
}
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/store/src/Bridge/S3Vectors/.gitattributes
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
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!
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!
5 changes: 5 additions & 0 deletions src/store/src/Bridge/S3Vectors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/composer.lock
/phpunit.xml
/.phpunit.result.cache
/phpstan.neon
/vendor/
7 changes: 7 additions & 0 deletions src/store/src/Bridge/S3Vectors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHANGELOG
=========

0.4
---

* Add the bridge
19 changes: 19 additions & 0 deletions src/store/src/Bridge/S3Vectors/LICENSE
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.
91 changes: 91 additions & 0 deletions src/store/src/Bridge/S3Vectors/README.md
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Loading