-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
6,721 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PINECONE_API_KEY= | ||
PINECONE_ENVIRONMENT= | ||
PINECONE_INDEX_NAME= | ||
PINECONE_COLLECTION_NAME= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
composer.phar | ||
/vendor/ | ||
|
||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,302 @@ | ||
# pinecone-php | ||
# Pinecone PHP | ||
|
||
A beautiful, extendable PHP Package to communicate with your [pincone.io](https://pincone.io) indices, collections and | ||
vectors, powered by [Saloon](https://github.com/sammyjo20/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. | ||
## Introduction | ||
|
||
This API provides a feature rich, elegant baseline for working with the [pincone.io](https://pincone.io) API. Developers | ||
can | ||
install and leverage this API to help them integrate [pincone.io](https://pincone.io) easily and beautifully. | ||
|
||
## Installation | ||
|
||
`composer require probots-io/pinecone-php` | ||
|
||
## Features | ||
|
||
Currently supports all of the available endpoints in the [pincone.io](https://pincone.io) API based | ||
on [the official documentation](https://docs.pinecone.io/reference) | ||
|
||
### Authentication | ||
|
||
Authentication via Api Key is the only available authentication methods currently supported. | ||
First, you will need to create an Api Key in your [pincone.io](https://pincone.io) instance. | ||
|
||
```php | ||
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. | ||
``` | ||
|
||
## Responses | ||
|
||
All responses are returned as a `Response` object. | ||
Please check the [Saloon documentation](https://docs.saloon.dev/the-basics/responses#available-methods) to see all | ||
available methods. | ||
|
||
## Index Operations | ||
|
||
Work(s) with your indices. | ||
|
||
### Create Index | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/create_index) | ||
|
||
```php | ||
$response = $pinecone->index()->create( | ||
name: 'my-index', | ||
dimension: 1536 | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Describe Index | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/describe_index) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->describe(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### List Indices | ||
|
||
[Pincone Docs](https://docs.pinecone.io/reference/list_indexes) | ||
|
||
```php | ||
$response = $pinecone->index()->list(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Configure Index | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/configure_index) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->configure( | ||
pod_type: 'p1.x1', | ||
replicas: 1 | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Delete Index | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/delete_index) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->delete(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
## Collection Operations | ||
|
||
Work(s) with your collections too. | ||
|
||
### Create Collection | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/create_collection) | ||
|
||
```php | ||
$response = $pinecone->collections()->create( | ||
name: 'my-collection', | ||
source: 'my-index' | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Describe Collection | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/describe_collection) | ||
|
||
```php | ||
$response = $pinecone->collections('my-collection')->describe(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### List Collections | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/list_collections) | ||
|
||
```php | ||
$response = $pinecone->collections()->list(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Delete Collections | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/delete_collection) | ||
|
||
```php | ||
$response = $pinecone->collections('my-collection')->delete(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
## Vector Operations | ||
|
||
Vectors are the basic unit of data in Pinecone. Use them. | ||
|
||
### Describe Index Stats | ||
|
||
TBD | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->stats(); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Update Vector | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/update) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->update( | ||
id: 'vector_1', | ||
values: array_fill(0, 128, 0.14), | ||
setMetadata: [ | ||
'meta1' => 'value1', | ||
] | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Upsert Vectors | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/upsert) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->upsert(vectors: [ | ||
'id' => 'vector_1', | ||
'values' => array_fill(0, 128, 0.14), | ||
'metadata' => [ | ||
'meta1' => 'value1', | ||
] | ||
]); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Query Vectors | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/query) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->query( | ||
vector: array_fill(0, 128, 0.12), | ||
topK: 1, | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Delete Vectors | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/delete_post) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->delete( | ||
deleteAll: true | ||
); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
### Fetch Vectors | ||
|
||
[Pinecone Docs](https://docs.pinecone.io/reference/fetch) | ||
|
||
```php | ||
$response = $pinecone->index('my-index')->vectors()->fetch([ | ||
'vector_1', 'vector_2' | ||
]); | ||
|
||
if($response->successful()) { | ||
// | ||
} | ||
``` | ||
|
||
## Testing | ||
|
||
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. | ||
|
||
## Changelog | ||
|
||
Please see [releases](https://github.com/njoguamos/laravel-plausible/releases) for more information on what has changed | ||
recently. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Security Vulnerabilities | ||
|
||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities. | ||
|
||
## Credits | ||
|
||
- [Marcus Pohorely](https://github.com/derpoho) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
|
||
## TODO: | ||
|
||
- [ ] validate parameters based on API docs - needs more checking | ||
- [ ] Implement Custom Exceptions | ||
- [ ] Add failure tests | ||
- [ ] Add some examples | ||
- [ ] Finish docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "probots-io/pinecone-php", | ||
"description": "Unofficial PHP Client for Pinecone Vector Database (pinecone.io)", | ||
"type": "library", | ||
"keywords": [ | ||
"pinecone", | ||
"vector", | ||
"database", | ||
"sdk", | ||
"client" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Marcus Pohorely", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=8.0", | ||
"sammyjo20/saloon": "^2.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Probots\\Pinecone\\": "src/", | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"require-dev": { | ||
"pestphp/pest": "^2.4", | ||
"vlucas/phpdotenv": "^5.5", | ||
"symfony/var-dumper": "^6.2", | ||
"pestphp/pest-plugin-watch": "^2.0", | ||
"pestphp/pest-plugin-faker": "^2.0" | ||
}, | ||
"scripts": { | ||
"test": "pest", | ||
"test:watch": "pest --watch" | ||
}, | ||
"scripts-descriptions": { | ||
"test": "Run the tests", | ||
"test:watch": "Run the tests & watch for changes" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
} | ||
} |
Oops, something went wrong.