adrianmejias / pinecone
此包已被废弃且不再维护。未建议替代包。
此包提供了Pinecone API的Laravel包装。
v1.0.12
2023-04-11 00:01 UTC
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0|^10.0
- pestphp/pest: ^1.0|^2.0
- pestphp/pest-plugin-laravel: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^8.0|^9.0|^10.0
README
此包提供了Laravel
对Pinecone API
的包装。它使您能够在Laravel
项目中轻松地与Pinecone API
交互。
安装
您可以通过composer安装此包
composer require adrianmejias/pinecone
您也可以选择使用以下命令发布配置文件
php artisan vendor:publish --provider="AdrianMejias\Pinecone\PineconeServiceProvider" --tag="config"
这将发布一个位于您的配置目录中的pinecone.php
文件,您可以按需进行自定义。
配置
在使用此包之前,您需要设置Pinecone API密钥和环境。您可以通过设置环境变量PINECONE_API_KEY
、PINECONE_PROJECT_ID
和PINECONE_ENVIRONMENT
,或通过更新config/pinecone.php
文件中的值来完成此操作。
您还可以选择设置环境变量PINECONE_CONTROLLER_HOST
/PINECONE_INDEX_HOST
或更新config/pinecone.php
文件中的controller_host
/index_host
值以指定自定义的控制器/索引主机。
使用方法
您可以使用Pinecone外观与Pinecone API交互。以下是一个创建索引的示例
use AdrianMejias\Pinecone\Facades\Pinecone; // Create an index $response = Pinecone::index('my-index')->create([ 'metric' => 'cosine', 'pods' => 1, 'replicas' => 1, 'pod_type' => 'p1.x1', ]); // Query with namespace $response = Pinecone::vector('my-index')->namespace('my-namespace')->query(10);
这将创建一个名为my-index
的索引,包含两个字段field1
和field2
。
可用方法
以下方法可通过Pinecone外观使用
- setApiKey(string $apiKey): Pinecone: 设置用于Pinecone请求的API密钥
- setEnvironment(string $environment): Pinecone: 设置要使用的Pinecone环境
- setProjectId(string $projectId): Pinecone: 设置要使用的Pinecone项目ID
- setEndpoint(string $endpoint): Pinecone: 设置要使用的Pinecone控制器主机
- getApiKey(): ?string: 获取当前正在使用的API密钥
- getEnvironment(): ?string: 获取当前正在使用的Pinecone环境
- getProjectId(): ?string: 获取当前正在使用的Pinecone项目ID
- getEndpoint(): ?string: 获取当前正在使用的Pinecone控制器主机
- vector(string $indexName): Pinecone: 向量操作
- index(?string $indexName = null): Pinecone: 索引操作
- collection(?string $collectionName = null): 索引集合操作
有关如何使用API的更多信息,请参阅官方Pinecone API参考。
许可证
Pinecone PHP包是开源软件,受MIT许可证许可。