|
106 | 106 | use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore; |
107 | 107 | use Symfony\AI\Store\Bridge\Redis\Distance as RedisDistance; |
108 | 108 | use Symfony\AI\Store\Bridge\Redis\Store as RedisStore; |
| 109 | +use Symfony\AI\Store\Bridge\S3Vectors\Store as S3VectorsStore; |
109 | 110 | use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore; |
110 | 111 | use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore; |
111 | 112 | use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore; |
@@ -1939,6 +1940,47 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde |
1939 | 1940 | $container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $type.'_'.$name); |
1940 | 1941 | } |
1941 | 1942 | } |
| 1943 | + |
| 1944 | + if ('s3vectors' === $type) { |
| 1945 | + if (!ContainerBuilder::willBeAvailable('symfony/ai-s3vectors-store', S3VectorsStore::class, ['symfony/ai-bundle'])) { |
| 1946 | + throw new RuntimeException('S3Vectors store configuration requires "symfony/ai-s3vectors-store" package. Try running "composer require symfony/ai-s3vectors-store".'); |
| 1947 | + } |
| 1948 | + |
| 1949 | + foreach ($stores as $name => $store) { |
| 1950 | + if (isset($store['client'])) { |
| 1951 | + $s3VectorsClient = new Reference($store['client']); |
| 1952 | + } else { |
| 1953 | + $s3VectorsClient = new Definition(\AsyncAws\S3Vectors\S3VectorsClient::class); |
| 1954 | + $s3VectorsClient->setArguments([$store['configuration'] ?? []]); |
| 1955 | + } |
| 1956 | + |
| 1957 | + $arguments = [ |
| 1958 | + $s3VectorsClient, |
| 1959 | + $store['vector_bucket_name'], |
| 1960 | + $store['index_name'] ?? $name, |
| 1961 | + ]; |
| 1962 | + |
| 1963 | + if (\array_key_exists('filter', $store)) { |
| 1964 | + $arguments[3] = $store['filter']; |
| 1965 | + } |
| 1966 | + |
| 1967 | + if (\array_key_exists('top_k', $store)) { |
| 1968 | + $arguments[4] = $store['top_k']; |
| 1969 | + } |
| 1970 | + |
| 1971 | + $definition = new Definition(S3VectorsStore::class); |
| 1972 | + $definition |
| 1973 | + ->setLazy(true) |
| 1974 | + ->setArguments($arguments) |
| 1975 | + ->addTag('proxy', ['interface' => StoreInterface::class]) |
| 1976 | + ->addTag('proxy', ['interface' => ManagedStoreInterface::class]) |
| 1977 | + ->addTag('ai.store'); |
| 1978 | + |
| 1979 | + $container->setDefinition('ai.store.'.$type.'.'.$name, $definition); |
| 1980 | + $container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $name); |
| 1981 | + $container->registerAliasForArgument('ai.store.'.$type.'.'.$name, StoreInterface::class, $type.'_'.$name); |
| 1982 | + } |
| 1983 | + } |
1942 | 1984 | } |
1943 | 1985 |
|
1944 | 1986 | /** |
|
0 commit comments