|
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; |
@@ -1597,6 +1598,269 @@ public function testNeo4jStoreWithQuantizationCanBeConfigured() |
1597 | 1598 | $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
1598 | 1599 | } |
1599 | 1600 |
|
| 1601 | + public function testOpenSearchStoreCanBeConfigured() |
| 1602 | + { |
| 1603 | + $container = $this->buildContainer([ |
| 1604 | + 'ai' => [ |
| 1605 | + 'store' => [ |
| 1606 | + 'opensearch' => [ |
| 1607 | + 'my_opensearch_store' => [ |
| 1608 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1609 | + ], |
| 1610 | + ], |
| 1611 | + ], |
| 1612 | + ], |
| 1613 | + ]); |
| 1614 | + |
| 1615 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1616 | + |
| 1617 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1618 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1619 | + |
| 1620 | + $this->assertTrue($definition->isLazy()); |
| 1621 | + $this->assertCount(6, $definition->getArguments()); |
| 1622 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1623 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 1624 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1625 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 1626 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 1627 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 1628 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 1629 | + |
| 1630 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1631 | + $this->assertSame([ |
| 1632 | + ['interface' => StoreInterface::class], |
| 1633 | + ['interface' => ManagedStoreInterface::class], |
| 1634 | + ], $definition->getTag('proxy')); |
| 1635 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1636 | + |
| 1637 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1638 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1639 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1640 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1641 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1642 | + } |
| 1643 | + |
| 1644 | + public function testOpenSearchStoreWithCustomIndexCanBeConfigured() |
| 1645 | + { |
| 1646 | + $container = $this->buildContainer([ |
| 1647 | + 'ai' => [ |
| 1648 | + 'store' => [ |
| 1649 | + 'opensearch' => [ |
| 1650 | + 'my_opensearch_store' => [ |
| 1651 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1652 | + 'index_name' => 'foo', |
| 1653 | + ], |
| 1654 | + ], |
| 1655 | + ], |
| 1656 | + ], |
| 1657 | + ]); |
| 1658 | + |
| 1659 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1660 | + |
| 1661 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1662 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1663 | + |
| 1664 | + $this->assertTrue($definition->isLazy()); |
| 1665 | + $this->assertCount(6, $definition->getArguments()); |
| 1666 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1667 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 1668 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1669 | + $this->assertSame('foo', $definition->getArgument(2)); |
| 1670 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 1671 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 1672 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 1673 | + |
| 1674 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1675 | + $this->assertSame([ |
| 1676 | + ['interface' => StoreInterface::class], |
| 1677 | + ['interface' => ManagedStoreInterface::class], |
| 1678 | + ], $definition->getTag('proxy')); |
| 1679 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1680 | + |
| 1681 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1682 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1683 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1684 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1685 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1686 | + } |
| 1687 | + |
| 1688 | + public function testOpenSearchStoreWithCustomFieldCanBeConfigured() |
| 1689 | + { |
| 1690 | + $container = $this->buildContainer([ |
| 1691 | + 'ai' => [ |
| 1692 | + 'store' => [ |
| 1693 | + 'opensearch' => [ |
| 1694 | + 'my_opensearch_store' => [ |
| 1695 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1696 | + 'vectors_field' => 'foo', |
| 1697 | + ], |
| 1698 | + ], |
| 1699 | + ], |
| 1700 | + ], |
| 1701 | + ]); |
| 1702 | + |
| 1703 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1704 | + |
| 1705 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1706 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1707 | + |
| 1708 | + $this->assertTrue($definition->isLazy()); |
| 1709 | + $this->assertCount(6, $definition->getArguments()); |
| 1710 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1711 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 1712 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1713 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 1714 | + $this->assertSame('foo', $definition->getArgument(3)); |
| 1715 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 1716 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 1717 | + |
| 1718 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1719 | + $this->assertSame([ |
| 1720 | + ['interface' => StoreInterface::class], |
| 1721 | + ['interface' => ManagedStoreInterface::class], |
| 1722 | + ], $definition->getTag('proxy')); |
| 1723 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1724 | + |
| 1725 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1726 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1727 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1728 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1729 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1730 | + } |
| 1731 | + |
| 1732 | + public function testOpenSearchStoreWithCustomDimensionsCanBeConfigured() |
| 1733 | + { |
| 1734 | + $container = $this->buildContainer([ |
| 1735 | + 'ai' => [ |
| 1736 | + 'store' => [ |
| 1737 | + 'opensearch' => [ |
| 1738 | + 'my_opensearch_store' => [ |
| 1739 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1740 | + 'dimensions' => 768, |
| 1741 | + ], |
| 1742 | + ], |
| 1743 | + ], |
| 1744 | + ], |
| 1745 | + ]); |
| 1746 | + |
| 1747 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1748 | + |
| 1749 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1750 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1751 | + |
| 1752 | + $this->assertTrue($definition->isLazy()); |
| 1753 | + $this->assertCount(6, $definition->getArguments()); |
| 1754 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1755 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 1756 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1757 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 1758 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 1759 | + $this->assertSame(768, $definition->getArgument(4)); |
| 1760 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 1761 | + |
| 1762 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1763 | + $this->assertSame([ |
| 1764 | + ['interface' => StoreInterface::class], |
| 1765 | + ['interface' => ManagedStoreInterface::class], |
| 1766 | + ], $definition->getTag('proxy')); |
| 1767 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1768 | + |
| 1769 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1770 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1771 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1772 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1773 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1774 | + } |
| 1775 | + |
| 1776 | + public function testOpenSearchStoreWithCustomSpaceTypeCanBeConfigured() |
| 1777 | + { |
| 1778 | + $container = $this->buildContainer([ |
| 1779 | + 'ai' => [ |
| 1780 | + 'store' => [ |
| 1781 | + 'opensearch' => [ |
| 1782 | + 'my_opensearch_store' => [ |
| 1783 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1784 | + 'space_type' => 'l1', |
| 1785 | + ], |
| 1786 | + ], |
| 1787 | + ], |
| 1788 | + ], |
| 1789 | + ]); |
| 1790 | + |
| 1791 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1792 | + |
| 1793 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1794 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1795 | + |
| 1796 | + $this->assertTrue($definition->isLazy()); |
| 1797 | + $this->assertCount(6, $definition->getArguments()); |
| 1798 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1799 | + $this->assertSame('http_client', (string) $definition->getArgument(0)); |
| 1800 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1801 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 1802 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 1803 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 1804 | + $this->assertSame('l1', $definition->getArgument(5)); |
| 1805 | + |
| 1806 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1807 | + $this->assertSame([ |
| 1808 | + ['interface' => StoreInterface::class], |
| 1809 | + ['interface' => ManagedStoreInterface::class], |
| 1810 | + ], $definition->getTag('proxy')); |
| 1811 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1812 | + |
| 1813 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1814 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1815 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1816 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1817 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1818 | + } |
| 1819 | + |
| 1820 | + public function testOpenSearchStoreWithCustomHttpClientCanBeConfigured() |
| 1821 | + { |
| 1822 | + $container = $this->buildContainer([ |
| 1823 | + 'ai' => [ |
| 1824 | + 'store' => [ |
| 1825 | + 'opensearch' => [ |
| 1826 | + 'my_opensearch_store' => [ |
| 1827 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 1828 | + 'http_client' => 'foo', |
| 1829 | + ], |
| 1830 | + ], |
| 1831 | + ], |
| 1832 | + ], |
| 1833 | + ]); |
| 1834 | + |
| 1835 | + $this->assertTrue($container->hasDefinition('ai.store.opensearch.my_opensearch_store')); |
| 1836 | + |
| 1837 | + $definition = $container->getDefinition('ai.store.opensearch.my_opensearch_store'); |
| 1838 | + $this->assertSame(OpenSearchStore::class, $definition->getClass()); |
| 1839 | + |
| 1840 | + $this->assertTrue($definition->isLazy()); |
| 1841 | + $this->assertCount(6, $definition->getArguments()); |
| 1842 | + $this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
| 1843 | + $this->assertSame('foo', (string) $definition->getArgument(0)); |
| 1844 | + $this->assertSame('http://127.0.0.1:9200', $definition->getArgument(1)); |
| 1845 | + $this->assertSame('my_opensearch_store', $definition->getArgument(2)); |
| 1846 | + $this->assertSame('_vectors', $definition->getArgument(3)); |
| 1847 | + $this->assertSame(1536, $definition->getArgument(4)); |
| 1848 | + $this->assertSame('l2', $definition->getArgument(5)); |
| 1849 | + |
| 1850 | + $this->assertTrue($definition->hasTag('proxy')); |
| 1851 | + $this->assertSame([ |
| 1852 | + ['interface' => StoreInterface::class], |
| 1853 | + ['interface' => ManagedStoreInterface::class], |
| 1854 | + ], $definition->getTag('proxy')); |
| 1855 | + $this->assertTrue($definition->hasTag('ai.store')); |
| 1856 | + |
| 1857 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $my_opensearch_store')); |
| 1858 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $myOpensearchStore')); |
| 1859 | + $this->assertTrue($container->hasAlias('.Symfony\AI\Store\StoreInterface $opensearch_my_opensearch_store')); |
| 1860 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface $opensearchMyOpensearchStore')); |
| 1861 | + $this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface')); |
| 1862 | + } |
| 1863 | + |
1600 | 1864 | public function testPineconeStoreCanBeConfigured() |
1601 | 1865 | { |
1602 | 1866 | $container = $this->buildContainer([ |
@@ -6033,6 +6297,27 @@ private function getFullConfig(): array |
6033 | 6297 | 'quantization' => true, |
6034 | 6298 | ], |
6035 | 6299 | ], |
| 6300 | + 'opensearch' => [ |
| 6301 | + 'my_opensearch_store' => [ |
| 6302 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 6303 | + ], |
| 6304 | + 'my_opensearch_store_with_custom_index' => [ |
| 6305 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 6306 | + 'index_name' => 'foo', |
| 6307 | + ], |
| 6308 | + 'my_opensearch_store_with_custom_field' => [ |
| 6309 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 6310 | + 'vectors_field' => 'foo', |
| 6311 | + ], |
| 6312 | + 'my_opensearch_store_with_custom_space_type' => [ |
| 6313 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 6314 | + 'space_type' => 'l1', |
| 6315 | + ], |
| 6316 | + 'my_opensearch_store_with_custom_http_client' => [ |
| 6317 | + 'endpoint' => 'http://127.0.0.1:9200', |
| 6318 | + 'http_client' => 'foo', |
| 6319 | + ], |
| 6320 | + ], |
6036 | 6321 | 'pinecone' => [ |
6037 | 6322 | 'my_pinecone_store' => [ |
6038 | 6323 | 'namespace' => 'my_namespace', |
|
0 commit comments