A beautiful, extendable PHP Package to communicate with your pinecone.io indices, collections and vectors, powered by Saloon.
Info This package is still in active development, but is already used in some production scenarios. Check Todo list below for more information what's missing.
This API provides a feature rich, elegant baseline for working with the pinecone.io API. Developers can install and leverage this API to help them integrate pinecone.io easily and beautifully.
composer require probots-io/pinecone-php
Currently supports all of the available endpoints in the pinecone.io API based on the official documentation
Authentication via Api Key is the only available authentication methods currently supported. First, you will need to create an Api Key in your pinecone.io instance.
use \Probots\Pinecone\Client as Pinecone;
$apiKey = 'YOUR_PINECONE_API_KEY';
$environment = 'YOU_PINECONE_ENVIRONMENT';
// Initialize Pinecone
$pinecone = new Pinecone($apiKey, $environment);
// Now you are ready to make requests, all requests will be authenticated automatically.
All responses are returned as a Response
object.
Please check the Saloon documentation to see all
available methods.
Work(s) with your indices.
$response = $pinecone->index()->create(
name: 'my-index',
dimension: 1536
);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->describe();
if($response->successful()) {
//
}
$response = $pinecone->index()->list();
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->configure(
pod_type: 'p1.x1',
replicas: 1
);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->delete();
if($response->successful()) {
//
}
Work(s) with your collections too.
$response = $pinecone->collections()->create(
name: 'my-collection',
source: 'my-index'
);
if($response->successful()) {
//
}
$response = $pinecone->collections('my-collection')->describe();
if($response->successful()) {
//
}
$response = $pinecone->collections()->list();
if($response->successful()) {
//
}
$response = $pinecone->collections('my-collection')->delete();
if($response->successful()) {
//
}
Vectors are the basic unit of data in Pinecone. Use them.
TBD
$response = $pinecone->index('my-index')->vectors()->stats();
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->vectors()->update(
id: 'vector_1',
values: array_fill(0, 128, 0.14),
setMetadata: [
'meta1' => 'value1',
]
);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->vectors()->upsert(vectors: [
'id' => 'vector_1',
'values' => array_fill(0, 128, 0.14),
'metadata' => [
'meta1' => 'value1',
]
]);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->vectors()->query(
vector: array_fill(0, 128, 0.12),
topK: 1,
);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->vectors()->delete(
deleteAll: true
);
if($response->successful()) {
//
}
$response = $pinecone->index('my-index')->vectors()->fetch([
'vector_1', 'vector_2'
]);
if($response->successful()) {
//
}
Testing is done via PestPHP. You can run the tests by running ./vendor/bin/pest
in the root of the project.
Copy .env.example to .env and update accordingly.
The MIT License (MIT). Please see License File for more information.
- validate parameters based on API docs - needs more checking
- Implement Custom Exceptions
- Add failure tests
- Add some examples
- Finish docs