islambaraka90/pinecone-php-client
Composer 安装命令:
composer require islambaraka90/pinecone-php-client
包简介
A PHP client for connecting to Pinecone DB
README 文档
README
This is a PHP client implementation for handling all of the Pinecone endpoints. This library was created because there was no existing PHP client for Pinecone vector database.
Pinecone Vector Database
Pinecone is a vector database designed for high-performance similarity search and other similarity-related tasks. It provides a simple API for inserting and querying high-dimensional vectors, making it easy to build intelligent search applications that can handle large amounts of data.
Pinecone is used by OpenAI applications as part of its long-term memory architecture. By storing high-dimensional vectors in Pinecone, OpenAI applications can retrieve them quickly and efficiently when needed, allowing it to build complex models that can learn from large amounts of data and make more accurate predictions.
Pinecone's vector database is highly scalable and can handle millions or even billions of vectors with ease. It's designed to work with a variety of machine learning frameworks and libraries, making it easy to integrate into your existing workflow.
One of the key benefits of using Pinecone is its ability to perform fast, accurate similarity searches. This makes it ideal for applications such as image search, product recommendations, and personalized content delivery. By using Pinecone, you can build intelligent search applications that can handle large amounts of data and provide accurate results in real-time.
Overall, Pinecone is a powerful tool for anyone who needs to work with high-dimensional vectors and wants to build intelligent search applications that can handle large amounts of data. Whether you're building a recommendation engine, an image search application, or a personalized content delivery system, Pinecone can help you achieve your goals quickly and easily.
Important Note:
This library isn't restricted to only OpenAI embedding and can be used with any other embedding.
Make sure to check the dimensions of your embedding before using it with this library.
Installation
To install the Pinecone PHP Client, you can use Composer. Run the following command:
composer require islambaraka90/pinecone-php-client
Usage
Initialization
To use the Pinecone PHP Client, you need to first initialize it with your API key and Pinecone endpoint. You can do this by creating a new instance of the Pinecone client:
use IslamBaraka90\PineconeClient; $this->api_key = $_ENV['PINCONE_KEY'] ?: ''; $this->environment = $_ENV['PINCONE_ENV'] ?: 'us-east1-gcp'; $this->client = new PineconePhpClient( $this->api_key , $this->environment );
Listing Indexes
To list all indexes available in your Pinecone instance, you can use the listIndexes method:
$response = $this->client->listIndexes();
Creating an Index
To create a new index, you can use the createIndex method:
$name = 'my-index'; $dimension = 1536; $result = $this->client->createIndex($name, $dimension);
Deleting an Index
To delete an index, you can use the deleteIndex method:
$response = $this->client->deleteIndex('my-index');
Describing an Index
To get information about an index, you can use the describeIndex method:
$this->client->describeIndex('my-index');
Working with an Index
To work with a specific index, you can use the Index method to get an instance of the Index interface. Here are some examples of methods available on the Index interface:
Describe Index Stats
To get statistics about an index, you can use the describeIndexStats method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats();
Upsert Vectors
To insert or update vectors in an index, you can use the upsert method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats(); // Upsert 20 vectors $vectorsFile = __DIR__ . '/vectors_objects.json'; $vectors = json_decode(file_get_contents($vectorsFile), true); $project_id = 'project-0000'.rand(1,99); $response = $index->upsert($project_id,$vectors['vectors']);
Query Vectors
To query vectors from an index, you can use the query method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats(); // Query vectors $vectorsFile = __DIR__ . '/query.json'; $vectors = json_decode(file_get_contents($vectorsFile), true); $response = $index->query('project-000001',$vectors, [],3); $response = json_decode($response, true);
Fetch Vectors
To fetch vectors from an index, you can use the fetch method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats(); // Fetch vectors $id = "DEeSvRP8XKZwzpWD"; $response = $index->fetch([$id], 'project-000001'); $response = json_decode($response, true);
Update Vectors
To update vectors in an index, you can use the update method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats(); // Update vectors $id = "DEeSvRP8XKZwzpWD"; $response = $index->update($id, 'project-000001',null,null,['testing' => 'testing5']); $response = json_decode($response, true);
Delete Vectors
To delete vectors from an index, you can use the delete method:
$index = $this->client->Index('my-index'); $state = $index->describeIndexStats(); // Delete vectors $id = "DEeSvRP8XKZwzpWD"; $response = $index->delete($id, 'project-000001');
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
islambaraka90/pinecone-php-client 适用场景与选型建议
islambaraka90/pinecone-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 973 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「client」 「pinecone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 islambaraka90/pinecone-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 islambaraka90/pinecone-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 islambaraka90/pinecone-php-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Unofficial PHP Client for Pinecone Vector Database (pinecone.io)
Low-level abstraction for storing and retrieving documents in a vector store.
Dibi is Database Abstraction Library for PHP
Unofficial PHP Client for Pinecone Vector Database (pinecone.io)
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
统计信息
- 总下载量: 973
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-10