darcher/pinecone-php
Composer 安装命令:
composer require darcher/pinecone-php
包简介
Pinecode API Client in PHP
README 文档
README
This PHP Pinecone API Client is a powerful and easy-to-use library that allows you to interact with the Pinecone vector database. Pinecone is a scalable and high-performance vector database designed to store, search, and manage large volumes of high-dimensional vectors.
This library offers a convenient and efficient way to interact with Pinecone using PHP.
Getting Started
Prerequisites
To use this package, you will need to have PHP 8.1 or higher installed on your machine. You will also need to have a Pinecone account and an API key.
Installation
To install the package, you can use composer:
composer require darcher/pinecone-php
Usage
Index
To get started, you will need to create an instance of the IndexApi class:
use Darcher\PineconePhp\IndexApi; $apiKey = 'your-api-key'; $environment = 'us-west1-gcp'; $pinecone = IndexApi::build($apiKey, $environment);
Once you have an instance of the IndexApi class, you can use it to perform various operations on your Pinecone indexes. For example, you can list all of your indexes:
$indexes = $pinecone->list();
You can also create a new index:
$name = 'my-new-index'; $dimension = 256; $response = $pinecone->create($name, $dimension);
For more information on the available methods and their parameters, please refer to the inline documentation in the IndexApi class.
Usage To get started, you will need to create an instance of the VectorApi class:
Vectors
If you don't know the host
use Darcher\PineconePhp\VectorApi; $apiKey = 'your-api-key'; $environment = 'us-west1-gcp'; $indexName = 'your-index-name'; $pinecone = VectorApi::build($apiKey, null, $indexName, $environment);
Once you have an instance of the VectorApi class, you can use it to perform various operations on your Pinecone vectors. For example, you can query vectors by their ID:
$id = 'your-vector-id'; $topK = 10; $response = $pinecone->queryById($id, $topK);
You can also upsert a collection of vectors:
use Darcher\PineconePhp\Vector; use Darcher\PineconePhp\VectorCollection; $vectors = new VectorCollection([ new Vector('vector-id-1', [1, 2, 3]), new Vector('vector-id-2', [4, 5, 6]), ]); $response = $pinecone->upsertCollection($vectors);
Or using the factory class
use Darcher\PineconePhp\VectorCollectionFactory; $response = $pinecone->upsertCollection(VectorCollectionFactory::create([ ['vector-id-1', [1, 2, 3]], ['vector-id-2', [3, 4, 5]], ]));
You can also use the upsert for a single vector
use Darcher\PineconePhp\Vector; $response = $pinecone->upsertOne(new Vector('vector-id-1', [1, 2, 3]));
For more information on the available methods and their parameters, please refer to the inline documentation in the VectorApi class.
Contributing
If you would like to contribute to this package, please feel free to open a pull request or an issue on the GitHub repository.
License
This package is licensed under the MIT License.
darcher/pinecone-php 适用场景与选型建议
darcher/pinecone-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 darcher/pinecone-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 darcher/pinecone-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-17