|
47 | 47 | use Symfony\AI\Store\Bridge\Milvus\Store as MilvusStore; |
48 | 48 | use Symfony\AI\Store\Bridge\MongoDb\Store as MongoDbStore; |
49 | 49 | use Symfony\AI\Store\Bridge\Neo4j\Store as Neo4jStore; |
| 50 | +use Symfony\AI\Store\Bridge\OpenSearch\Store as OpenSearchStore; |
50 | 51 | use Symfony\AI\Store\Bridge\Pinecone\Store as PineconeStore; |
51 | 52 | use Symfony\AI\Store\Bridge\Postgres\Distance; |
52 | 53 | use Symfony\AI\Store\Bridge\Postgres\Store as PostgresStore; |
@@ -2076,6 +2077,269 @@ public function testNeo4jStoreWithQuantizationCanBeConfigured() |
2076 | 2077 | $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
2077 | 2078 | } |
2078 | 2079 |
|
| 2080 | + public function testOpenSearchStoreCanBeConfigured() |
| 2081 | + { |
| 2082 | + $container = $this->buildContainer([ |
| 2083 | + 'ai' => [ |
| 2084 | + 'store' => [ |
| 2085 | + 'opensearch' => [ |
| 2086 | + 'my_opensearch_store' => [ |
| 2087 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2088 | + ], |
| 2089 | + ], |
| 2090 | + ], |
| 2091 | + ], |
| 2092 | + ]); |
| 2093 | + |
| 2094 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2095 | + |
| 2096 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2097 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2098 | + |
| 2099 | + $this->assertTrue($definition->isLazy()); |
| 2100 | + $this->assertCount(6, $definition->getArguments()); |
| 2101 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2102 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 2103 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2104 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 2105 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 2106 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 2107 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 2108 | + |
| 2109 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2110 | + $this->assertSame([ |
| 2111 | + ['interface' => StoreInterface::class], |
| 2112 | + ['interface' => ManagedStoreInterface::class], |
| 2113 | + ], $definition->getTag('proxy')); |
| 2114 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2115 | + |
| 2116 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2117 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2118 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2119 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2120 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2121 | + } |
| 2122 | + |
| 2123 | + public function testOpenSearchStoreWithCustomIndexCanBeConfigured() |
| 2124 | + { |
| 2125 | + $container = $this->buildContainer([ |
| 2126 | + 'ai' => [ |
| 2127 | + 'store' => [ |
| 2128 | + 'opensearch' => [ |
| 2129 | + 'my_opensearch_store' => [ |
| 2130 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2131 | + 'index_name' => 'foo', |
| 2132 | + ], |
| 2133 | + ], |
| 2134 | + ], |
| 2135 | + ], |
| 2136 | + ]); |
| 2137 | + |
| 2138 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2139 | + |
| 2140 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2141 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2142 | + |
| 2143 | + $this->assertTrue($definition->isLazy()); |
| 2144 | + $this->assertCount(6, $definition->getArguments()); |
| 2145 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2146 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 2147 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2148 | + $this->assertSame('foo', $definition->getArgument(2)); |
| 2149 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 2150 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 2151 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 2152 | + |
| 2153 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2154 | + $this->assertSame([ |
| 2155 | + ['interface' => StoreInterface::class], |
| 2156 | + ['interface' => ManagedStoreInterface::class], |
| 2157 | + ], $definition->getTag('proxy')); |
| 2158 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2159 | + |
| 2160 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2161 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2162 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2163 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2164 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2165 | + } |
| 2166 | + |
| 2167 | + public function testOpenSearchStoreWithCustomFieldCanBeConfigured() |
| 2168 | + { |
| 2169 | + $container = $this->buildContainer([ |
| 2170 | + 'ai' => [ |
| 2171 | + 'store' => [ |
| 2172 | + 'opensearch' => [ |
| 2173 | + 'my_opensearch_store' => [ |
| 2174 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2175 | + 'vectors_field' => 'foo', |
| 2176 | + ], |
| 2177 | + ], |
| 2178 | + ], |
| 2179 | + ], |
| 2180 | + ]); |
| 2181 | + |
| 2182 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2183 | + |
| 2184 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2185 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2186 | + |
| 2187 | + $this->assertTrue($definition->isLazy()); |
| 2188 | + $this->assertCount(6, $definition->getArguments()); |
| 2189 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2190 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 2191 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2192 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 2193 | + $this->assertSame('foo', $definition->getArgument(3)); |
| 2194 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 2195 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 2196 | + |
| 2197 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2198 | + $this->assertSame([ |
| 2199 | + ['interface' => StoreInterface::class], |
| 2200 | + ['interface' => ManagedStoreInterface::class], |
| 2201 | + ], $definition->getTag('proxy')); |
| 2202 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2203 | + |
| 2204 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2205 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2206 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2207 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2208 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2209 | + } |
| 2210 | + |
| 2211 | + public function testOpenSearchStoreWithCustomDimensionsCanBeConfigured() |
| 2212 | + { |
| 2213 | + $container = $this->buildContainer([ |
| 2214 | + 'ai' => [ |
| 2215 | + 'store' => [ |
| 2216 | + 'opensearch' => [ |
| 2217 | + 'my_opensearch_store' => [ |
| 2218 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2219 | + 'dimensions' => 768, |
| 2220 | + ], |
| 2221 | + ], |
| 2222 | + ], |
| 2223 | + ], |
| 2224 | + ]); |
| 2225 | + |
| 2226 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2227 | + |
| 2228 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2229 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2230 | + |
| 2231 | + $this->assertTrue($definition->isLazy()); |
| 2232 | + $this->assertCount(6, $definition->getArguments()); |
| 2233 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2234 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 2235 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2236 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 2237 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 2238 | + $this->assertSame(768, $definition->getArgument(4)); |
| 2239 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 2240 | + |
| 2241 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2242 | + $this->assertSame([ |
| 2243 | + ['interface' => StoreInterface::class], |
| 2244 | + ['interface' => ManagedStoreInterface::class], |
| 2245 | + ], $definition->getTag('proxy')); |
| 2246 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2247 | + |
| 2248 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2249 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2250 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2251 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2252 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2253 | + } |
| 2254 | + |
| 2255 | + public function testOpenSearchStoreWithCustomSpaceTypeCanBeConfigured() |
| 2256 | + { |
| 2257 | + $container = $this->buildContainer([ |
| 2258 | + 'ai' => [ |
| 2259 | + 'store' => [ |
| 2260 | + 'opensearch' => [ |
| 2261 | + 'my_opensearch_store' => [ |
| 2262 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2263 | + 'space_type' => 'l1', |
| 2264 | + ], |
| 2265 | + ], |
| 2266 | + ], |
| 2267 | + ], |
| 2268 | + ]); |
| 2269 | + |
| 2270 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2271 | + |
| 2272 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2273 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2274 | + |
| 2275 | + $this->assertTrue($definition->isLazy()); |
| 2276 | + $this->assertCount(6, $definition->getArguments()); |
| 2277 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2278 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 2279 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2280 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 2281 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 2282 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 2283 | + $this->assertSame('l1', $definition->getArgument(5)); |
| 2284 | + |
| 2285 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2286 | + $this->assertSame([ |
| 2287 | + ['interface' => StoreInterface::class], |
| 2288 | + ['interface' => ManagedStoreInterface::class], |
| 2289 | + ], $definition->getTag('proxy')); |
| 2290 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2291 | + |
| 2292 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2293 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2294 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2295 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2296 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2297 | + } |
| 2298 | + |
| 2299 | + public function testOpenSearchStoreWithCustomHttpClientCanBeConfigured() |
| 2300 | + { |
| 2301 | + $container = $this->buildContainer([ |
| 2302 | + 'ai' => [ |
| 2303 | + 'store' => [ |
| 2304 | + 'opensearch' => [ |
| 2305 | + 'my_opensearch_store' => [ |
| 2306 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 2307 | + 'http_client' => 'foo', |
| 2308 | + ], |
| 2309 | + ], |
| 2310 | + ], |
| 2311 | + ], |
| 2312 | + ]); |
| 2313 | + |
| 2314 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 2315 | + |
| 2316 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 2317 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 2318 | + |
| 2319 | + $this->assertTrue($definition->isLazy()); |
| 2320 | + $this->assertCount(6, $definition->getArguments()); |
| 2321 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 2322 | + $this->assertSame('foo', (string) $definition->getArgument(0)); |
| 2323 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 2324 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 2325 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 2326 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 2327 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 2328 | + |
| 2329 | + $this->assertTrue($definition->hasTag('proxy')); |
| 2330 | + $this->assertSame([ |
| 2331 | + ['interface' => StoreInterface::class], |
| 2332 | + ['interface' => ManagedStoreInterface::class], |
| 2333 | + ], $definition->getTag('proxy')); |
| 2334 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 2335 | + |
| 2336 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 2337 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 2338 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 2339 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 2340 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 2341 | + } |
| 2342 | + |
2079 | 2343 | public function testPineconeStoreCanBeConfigured() |
2080 | 2344 | { |
2081 | 2345 | $container = $this->buildContainer([ |
@@ -6856,6 +7120,27 @@ private function getFullConfig(): array |
6856 | 7120 | 'quantization' => true, |
6857 | 7121 | ], |
6858 | 7122 | ], |
| 7123 | + 'opensearch' => [ |
| 7124 | + 'my_opensearch_store' => [ |
| 7125 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 7126 | + ], |
| 7127 | + 'my_opensearch_store_with_custom_index' => [ |
| 7128 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 7129 | + 'index_name' => 'foo', |
| 7130 | + ], |
| 7131 | + 'my_opensearch_store_with_custom_field' => [ |
| 7132 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 7133 | + 'vectors_field' => 'foo', |
| 7134 | + ], |
| 7135 | + 'my_opensearch_store_with_custom_space_type' => [ |
| 7136 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 7137 | + 'space_type' => 'l1', |
| 7138 | + ], |
| 7139 | + 'my_opensearch_store_with_custom_http_client' => [ |
| 7140 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 7141 | + 'http_client' => 'foo', |
| 7142 | + ], |
| 7143 | + ], |
6859 | 7144 | 'pinecone' => [ |
6860 | 7145 | 'my_pinecone_store' => [ |
6861 | 7146 | 'namespace' => 'my_namespace', |
|
0 commit comments