You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a no-nonsense async Scala client for Pinecone API supporting all the available vector and index/collection operations/endpoints, provided in two convenient services called [PineconeVectorService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala) and [PineconeIndexService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeIndexService.scala). The supported calls are:
4
+
This is an intuitive async Scala client for Pinecone API supporting all the available vector and index/collection operations/endpoints, provided in two convenient services called [PineconeVectorService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala) and [PineconeIndexService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeIndexService.scala). The supported calls are:
5
5
6
6
***Vector Operations**: [describeIndexStats](https://docs.pinecone.io/reference/describe_index_stats_post), [query](https://docs.pinecone.io/reference/query), [delete](https://docs.pinecone.io/reference/delete_post), [fetch](https://docs.pinecone.io/reference/fetch), [update](https://docs.pinecone.io/reference/update), and [upsert](https://docs.pinecone.io/reference/upsert)
7
-
***Collection Operations**: [listCollections](https://docs.pinecone.io/reference/list_collections), [createCollection](https://docs.pinecone.io/reference/create_collection), [describeCollection](https://docs.pinecone.io/reference/describe_collection), and [delete_collection](https://docs.pinecone.io/reference/delete_collection)
7
+
***Collection Operations**: [listCollections](https://docs.pinecone.io/reference/list_collections), [createCollection](https://docs.pinecone.io/reference/create_collection), [describeCollection](https://docs.pinecone.io/reference/describe_collection), and [deleteCollection](https://docs.pinecone.io/reference/delete_collection)
8
8
***Index Operations**: [listIndexes](https://docs.pinecone.io/reference/list_indexes), [creatIndex](https://docs.pinecone.io/reference/create_index), [describeIndex](https://docs.pinecone.io/reference/describe_index), [deleteIndex](https://docs.pinecone.io/reference/delete_index), and [configureIndex](https://docs.pinecone.io/reference/configure_index)
9
9
10
10
Note that in order to be consistent with the Pinecone API naming, the service function names match exactly the API endpoint titles/descriptions with camelcase.
11
-
Also, we aimed the lib to be self-contained with the fewest dependencies possible therefore we ended up using only two libs `play-ahc-ws-standalone` and `play-ws-standalone-json` (at the top level). Additionally, if dependency injection is required we use `scala-guice` lib as well.
11
+
Also, we aimed the lib to be self-contained with the fewest dependencies possible therefore we ended up using only two libs `play-ahc-ws-standalone` and `play-ws-standalone-json` (at the top level).
12
12
13
13
**✔️ Important**: this is a "community-maintained" library and, as such, has no relation to Pinecone company.
14
14
15
15
## Installation 🚀
16
16
17
-
The currently supported Scala versions are **2.12, 2.13**, and **3**. Note that an optional module `pinecone-scala-guice` is available only for Scala 2.12 and 2.13.
17
+
The currently supported Scala versions are **2.12, 2.13**, and **3**.
18
18
19
19
To pull the library you have to add the following dependency to your *build.sbt*
20
20
@@ -39,7 +39,7 @@ or to *pom.xml* (if you use maven)
environment ="your_env"// e.g. "northamerica-northeast1-gcp
70
+
)
68
71
```
69
72
70
-
or
73
+
**Ib. Obtaining `PineconeVectorService`**
74
+
75
+
Same as with `PineconeIndexService`, you need to first provide implicit execution context and akka materializer. Then you can obtain a service in one of the following ways.
71
76
77
+
- Default config (expects env. variable(s) to be set as defined in `Config` section). Note that if the index with a given name is not available, the factory will return `None`.
PineconeVectorServiceFactory("index_name", config).map { service =>
91
+
valservice= serviceOption.getOrElse(
92
+
thrownewException(s"Index with a given name does not exist.")
93
+
)
94
+
// do something with the service
95
+
}
75
96
```
76
97
77
98
- Without config
78
99
79
100
```scala
80
-
valservice=PineconeVectorServiceFactory(
81
-
apiKey ="your_api_key",
82
-
environment ="your_env", // e.g. "northamerica-northeast1-gcp
83
-
indexName ="index_name", // e.g. "auto-gpt-xxxxxxx"
101
+
PineconeVectorServiceFactory(
102
+
apiKey ="your_api_key",
103
+
indexName ="index_name", // e.g. "auto-gpt"
104
+
pineconeIndexService = pineconeIndexService // index service to be used to find the index host URL
105
+
).map { serviceOption =>
106
+
valservice= serviceOption.getOrElse(
107
+
thrownewException(s"Index with a given name does not exist.")
108
+
)
109
+
// do something with the service
110
+
}
111
+
```
112
+
113
+
**II. Calling functions**
114
+
115
+
Full documentation of each call with its respective inputs and settings is provided in [PineconeVectorService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala) and [PineconeIndexService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeIndexService.scala). Since all the calls are async they return responses wrapped in `Future`.
116
+
117
+
Examples:
118
+
119
+
**Index Operations**
120
+
121
+
- List indexes
122
+
123
+
```scala
124
+
pineconeIndexService.listIndexes.map(indexes =>
125
+
indexes.foreach(println)
84
126
)
85
127
```
86
128
87
-
or
129
+
- Create index (with default settings)
88
130
89
131
```scala
90
-
valservice=PineconeIndexServiceFactory(
91
-
apiKey ="your_api_key",
92
-
environment ="your_env"// e.g. "northamerica-northeast1-gcp
caseCreateResponse.BadRequest=> println("Index creation failed. Request exceeds quota or an invalid index name.")
141
+
caseCreateResponse.AlreadyExists=> println("Index with a given name already exists.")
142
+
}
93
143
)
94
144
```
95
145
96
-
**II. Calling functions**
146
+
- Describe index
97
147
98
-
Full documentation of each call with its respective inputs and settings is provided in [PineconeVectorService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala) and [PineconeIndexService](./pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeIndexService.scala). Since all the calls are async they return responses wrapped in `Future`.
1.I got a timeout exception. How can I change the timeout setting?_
371
+
1._I got a timeout exception. How can I change the timeout setting?_
115
372
116
-
You can do it either by passing the `timeouts` param to `PineconeServiceFactory` or, if you use your own configuration file, then you can simply add it there as:
373
+
You can do it either by passing the `timeouts` param to `Pinecone{Vector,Index}ServiceFactory` or, if you use your own configuration file, then you can simply add it there as:
117
374
118
375
```
119
376
pinecone-scala-client {
@@ -126,12 +383,12 @@ pinecone-scala-client {
126
383
}
127
384
```
128
385
129
-
2.I got an exception like `com.typesafe.config.ConfigException$UnresolvedSubstitution: pinecone-scala-client.conf @ jar:file:.../io/cequence/pinecone-scala-client_2.13/0.0.1/pinecone-scala-client_2.13-0.0.1.jar!/pinecone-scala-client.conf: 4: Could not resolve substitution to a value: ${PINECONE_SCALA_CLIENT_API_KEY}`. What should I do?_
386
+
2._I got an exception like `com.typesafe.config.ConfigException$UnresolvedSubstitution: pinecone-scala-client.conf @ jar:file:.../io/cequence/pinecone-scala-client_2.13/0.0.1/pinecone-scala-client_2.13-0.0.1.jar!/pinecone-scala-client.conf: 4: Could not resolve substitution to a value: ${PINECONE_SCALA_CLIENT_API_KEY}`. What should I do?_
130
387
131
-
Set the env. variable `PINECONE_SCALA_CLIENT_API_KEY`. If you don't have one register [here](https://beta.pinecone.com/signup).
388
+
Set the env. variable `PINECONE_SCALA_CLIENT_API_KEY`. If you don't have one register [here](https://app.pinecone.io/?sessionType=signup).
132
389
133
390
134
-
3_It all looks cool. I want to chat with you about your research and development?_
391
+
3._It all looks cool. I want to chat with you about your research and development?_
0 commit comments