diff --git a/src/store/src/Bridge/Pinecone/ManagedStore.php b/src/store/src/Bridge/Pinecone/ManagedStore.php new file mode 100644 index 000000000..86d916a61 --- /dev/null +++ b/src/store/src/Bridge/Pinecone/ManagedStore.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\AI\Store\Bridge\Pinecone; + +use Probots\Pinecone\Client; +use Symfony\AI\Store\Exception\RuntimeException; +use Symfony\AI\Store\ManagedStoreInterface; + +final class ManagedStore implements ManagedStoreInterface +{ + public function __construct( + private readonly Client $pinecone, + private readonly string $indexName, + private readonly int $dimension, + private readonly string $metric, + private readonly string $cloud, + private readonly string $region, + ) { + if (!class_exists(Client::class)) { + throw new RuntimeException('For using the Pinecone as retrieval vector store, the probots-io/pinecone-php package is required. Try running "composer require probots-io/pinecone-php".'); + } + } + + public function setup(array $options = []): void + { + $this->pinecone + ->control() + ->index($this->indexName) + ->createServerless($this->dimension, $this->metric, $this->cloud, $this->region); + } + + public function drop(): void + { + $this->pinecone + ->control() + ->index($this->indexName) + ->delete(); + } +}