Skip to content

Commit 94fc6ec

Browse files
committed
Merge branch 'release/1.0.1'
2 parents a425b4b + 3266290 commit 94fc6ec

File tree

112 files changed

+1876
-1952
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1876
-1952
lines changed

.env.github

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
PINECONE_API_KEY=XOXO
2-
PINECONE_ENVIRONMENT=us-east1-gcp
3-
PINECONE_INDEX_NAME=pinecone-php
2+
PINECONE_INDEX_NAME=pinecone-test-php
3+
PINECONE_INDEX_HOST=https://pinecone-test-php-pod-xx.pinecone.io
44
PINECONE_COLLECTION_NAME=pinecone-collect-php

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup PHP
1414
uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: 8.1
16+
php-version: 8.2
1717
tools: composer:v2
1818
coverage: xdebug
1919

README.md

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Pinecone PHP
22

33
A beautiful, extendable PHP Package to communicate with your [pinecone.io](https://pinecone.io) indices, collections and
4-
vectors, powered by [Saloon](https://github.com/sammyjo20/saloon).
4+
vectors, powered by [Saloon](https://github.com/saloonphp/saloon).
55

66
> **Info**
7-
> This package is still in active development, but is already used in some production scenarios.
8-
> Check Todo list below for more information what's missing.
7+
> From Version 1.x onwards we are using the latest Pinecone API which support serverless. If you need the legacy API
8+
> please use a version before
9+
> 1.0.0!
910
1011
[![probots.io](art/probots-banner-1000x400.png)](https://probots.io)
1112

@@ -33,34 +34,90 @@ First, you will need to create an Api Key in your [pinecone.io](https://pinecone
3334
```php
3435
use \Probots\Pinecone\Client as Pinecone;
3536

36-
3737
$apiKey = 'YOUR_PINECONE_API_KEY';
38-
$environment = 'YOU_PINECONE_ENVIRONMENT';
3938

4039
// Initialize Pinecone
41-
$pinecone = new Pinecone($apiKey, $environment);
40+
$pinecone = new Pinecone($apiKey);
4241

4342
// Now you are ready to make requests, all requests will be authenticated automatically.
4443
```
4544

45+
## Quick Start
46+
47+
There are two ways to initialize the SDK. You can either provide an index during initialization or you can provide it
48+
later on.
49+
50+
```php
51+
use \Probots\Pinecone\Client as Pinecone;
52+
53+
$apiKey = 'YOUR_PINECONE_API_KEY';
54+
$pinecone = new Pinecone($apiKey);
55+
56+
// all control methods are available now, create an index or similar
57+
// e.g. $pinecone->control()->index()
58+
59+
// later on you can provide the index
60+
$pinecone->setIndexHost('INDEX_HOST_FROM_PINECONE');
61+
62+
// data methods are available now
63+
64+
// e.g. $pinecone->data()->vectors()
65+
```
66+
67+
or
68+
69+
```php
70+
use \Probots\Pinecone\Client as Pinecone;
71+
72+
$apiKey = 'YOUR_PINECONE_API_KEY';
73+
$indexHost = 'INDEX_HOST_FROM_PINECONE';
74+
75+
$pinecone = new Pinecone($apiKey, $indexHost);
76+
77+
// all control AND data methods are available now
78+
```
79+
4680
## Responses
4781

4882
All responses are returned as a `Response` object.
4983
Please check the [Saloon documentation](https://docs.saloon.dev/the-basics/responses#available-methods) to see all
5084
available methods.
5185

86+
# Control Pane
87+
5288
## Index Operations
5389

5490
Work(s) with your indices.
5591

56-
### Create Index
92+
### Create Index (POD)
5793

5894
[Pinecone Docs](https://docs.pinecone.io/reference/create_index)
5995

6096
```php
61-
$response = $pinecone->index()->create(
62-
name: 'my-index',
63-
dimension: 1536
97+
$response = $pinecone->control()->index('my-index')->createPod(
98+
dimension: 1536,
99+
metric: 'cosine',
100+
podType: 'p1.x1',
101+
replicas: 1
102+
// ... more options
103+
);
104+
105+
if($response->successful()) {
106+
//
107+
}
108+
```
109+
110+
### Create Index (Serverless)
111+
112+
[Pinecone Docs](https://docs.pinecone.io/reference/create_index)
113+
114+
```php
115+
$response = $pinecone->control()->index('my-index')->createServerless(
116+
dimension: 1536,
117+
metric: 'cosine',
118+
cloud: 'aws',
119+
region: 'us-west-2'
120+
// ... more options
64121
);
65122

66123
if($response->successful()) {
@@ -73,7 +130,7 @@ if($response->successful()) {
73130
[Pinecone Docs](https://docs.pinecone.io/reference/describe_index)
74131

75132
```php
76-
$response = $pinecone->index('my-index')->describe();
133+
$response = $pinecone->control()->index('my-index')->describe();
77134

78135
if($response->successful()) {
79136
//
@@ -85,7 +142,7 @@ if($response->successful()) {
85142
[Pinecone Docs](https://docs.pinecone.io/reference/list_indexes)
86143

87144
```php
88-
$response = $pinecone->index()->list();
145+
$response = $pinecone->control()->index()->list();
89146

90147
if($response->successful()) {
91148
//
@@ -97,7 +154,7 @@ if($response->successful()) {
97154
[Pinecone Docs](https://docs.pinecone.io/reference/configure_index)
98155

99156
```php
100-
$response = $pinecone->index('my-index')->configure(
157+
$response = $pinecone->control()->index('my-index')->configure(
101158
pod_type: 'p1.x1',
102159
replicas: 1
103160
);
@@ -112,7 +169,7 @@ if($response->successful()) {
112169
[Pinecone Docs](https://docs.pinecone.io/reference/delete_index)
113170

114171
```php
115-
$response = $pinecone->index('my-index')->delete();
172+
$response = $pinecone->control()->index('my-index')->delete();
116173

117174
if($response->successful()) {
118175
//
@@ -128,8 +185,7 @@ Work(s) with your collections too.
128185
[Pinecone Docs](https://docs.pinecone.io/reference/create_collection)
129186

130187
```php
131-
$response = $pinecone->collections()->create(
132-
name: 'my-collection',
188+
$response = $pinecone->control()->collections('my-collection')->create(
133189
source: 'my-index'
134190
);
135191

@@ -143,7 +199,7 @@ if($response->successful()) {
143199
[Pinecone Docs](https://docs.pinecone.io/reference/describe_collection)
144200

145201
```php
146-
$response = $pinecone->collections('my-collection')->describe();
202+
$response = $pinecone->control()->collections('my-collection')->describe();
147203

148204
if($response->successful()) {
149205
//
@@ -155,7 +211,7 @@ if($response->successful()) {
155211
[Pinecone Docs](https://docs.pinecone.io/reference/list_collections)
156212

157213
```php
158-
$response = $pinecone->collections()->list();
214+
$response = $pinecone->control()->collections()->list();
159215

160216
if($response->successful()) {
161217
//
@@ -167,23 +223,29 @@ if($response->successful()) {
167223
[Pinecone Docs](https://docs.pinecone.io/reference/delete_collection)
168224

169225
```php
170-
$response = $pinecone->collections('my-collection')->delete();
226+
$response = $pinecone->control()->collections('my-collection')->delete();
171227

172228
if($response->successful()) {
173229
//
174230
}
175231
```
176232

233+
# Data Pane
234+
235+
> **Info**
236+
> These operations need the index to be set. You can set the index during initialization or later on.
237+
> See description at the beginning.
238+
177239
## Vector Operations
178240

179241
Vectors are the basic unit of data in Pinecone. Use them.
180242

181-
### Describe Index Stats
243+
### Get Index Stats
182244

183-
TBD
245+
[Pinecone Docs](https://docs.pinecone.io/reference/describe_index_stats)
184246

185247
```php
186-
$response = $pinecone->index('my-index')->vectors()->stats();
248+
$response = $pinecone->data()->vectors()->stats();
187249

188250
if($response->successful()) {
189251
//
@@ -195,7 +257,7 @@ if($response->successful()) {
195257
[Pinecone Docs](https://docs.pinecone.io/reference/update)
196258

197259
```php
198-
$response = $pinecone->index('my-index')->vectors()->update(
260+
$response = $pinecone->data()->vectors()->update(
199261
id: 'vector_1',
200262
values: array_fill(0, 128, 0.14),
201263
setMetadata: [
@@ -213,7 +275,7 @@ if($response->successful()) {
213275
[Pinecone Docs](https://docs.pinecone.io/reference/upsert)
214276

215277
```php
216-
$response = $pinecone->index('my-index')->vectors()->upsert(vectors: [
278+
$response = $pinecone->data()->vectors()->upsert(vectors: [
217279
'id' => 'vector_1',
218280
'values' => array_fill(0, 128, 0.14),
219281
'metadata' => [
@@ -231,7 +293,7 @@ if($response->successful()) {
231293
[Pinecone Docs](https://docs.pinecone.io/reference/query)
232294

233295
```php
234-
$response = $pinecone->index('my-index')->vectors()->query(
296+
$response = $pinecone->data()->vectors()->query(
235297
vector: array_fill(0, 128, 0.12),
236298
topK: 1,
237299
);
@@ -246,7 +308,7 @@ if($response->successful()) {
246308
[Pinecone Docs](https://docs.pinecone.io/reference/delete_post)
247309

248310
```php
249-
$response = $pinecone->index('my-index')->vectors()->delete(
311+
$response = $pinecone->data()->vectors()->delete(
250312
deleteAll: true
251313
);
252314

@@ -260,7 +322,7 @@ if($response->successful()) {
260322
[Pinecone Docs](https://docs.pinecone.io/reference/fetch)
261323

262324
```php
263-
$response = $pinecone->index('my-index')->vectors()->fetch([
325+
$response = $pinecone->data()->vectors()->fetch([
264326
'vector_1', 'vector_2'
265327
]);
266328

@@ -283,7 +345,7 @@ Copy .env.example to .env and update accordingly.
283345

284346
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
285347

286-
## TODO:
348+
## TODO - Submit PR if you want to contribute:
287349

288350
- [ ] validate parameters based on API docs - needs more checking
289351
- [ ] Implement Custom Exceptions

art/pinecone-php-img-1200x600.png

266 KB
Loading

art/probots-banner-1000x400.png

113 KB
Loading

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.1",
22-
"saloonphp/saloon": "^2.7"
21+
"php": "^8.2",
22+
"saloonphp/saloon": "^3.6"
2323
},
2424
"autoload": {
2525
"psr-4": {

0 commit comments

Comments
 (0)