Skip to content

Commit ee116f3

Browse files
committed
README examples cleaned up and extended with rerank. Version 1.1.0
1 parent 8e5716e commit ee116f3

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

README.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Pinecone Scala Client 🗂️
2-
[![version](https://img.shields.io/badge/version-1.0.2-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT) ![GitHub Stars](https://img.shields.io/github/stars/cequence-io/pinecone-scala?style=social) [![Twitter Follow](https://img.shields.io/twitter/follow/0xbnd?style=social)](https://twitter.com/0xbnd)
2+
[![version](https://img.shields.io/badge/version-1.1.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT) ![GitHub Stars](https://img.shields.io/github/stars/cequence-io/pinecone-scala?style=social) [![Twitter Follow](https://img.shields.io/twitter/follow/0xbnd?style=social)](https://twitter.com/0xbnd)
33

44
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:
55

66
* **Vector Operations**: [describeIndexStats](https://docs.pinecone.io/reference/api/2024-07/data-plane/describeindexstats), [query](https://docs.pinecone.io/reference/api/2024-07/data-plane/query), [delete](https://docs.pinecone.io/reference/api/2024-07/data-plane/delete), [fetch](https://docs.pinecone.io/reference/api/2024-07/data-plane/fetch), [update](https://docs.pinecone.io/reference/api/2024-07/data-plane/update), and [upsert](https://docs.pinecone.io/reference/api/2024-07/data-plane/upsert)
77
* **Collection Operations**: [listCollections](https://docs.pinecone.io/reference/api/2024-07/control-plane/list_collections), [createCollection](https://docs.pinecone.io/reference/api/2024-07/control-plane/create_collection), [describeCollection](https://docs.pinecone.io/reference/api/2024-07/control-plane/describe_collection), and [deleteCollection](https://docs.pinecone.io/reference/api/2024-07/control-plane/delete_collection)
88
* **Index Operations**: [listIndexes](https://docs.pinecone.io/reference/api/2024-07/control-plane/list_indexes), [creatIndex](https://docs.pinecone.io/reference/api/2024-07/control-plane/create_index), [describeIndex](https://docs.pinecone.io/reference/api/2024-07/control-plane/describe_index), [deleteIndex](https://docs.pinecone.io/reference/api/2024-07/control-plane/delete_index), and [configureIndex](https://docs.pinecone.io/reference/api/2024-07/control-plane/configure_index)
9-
* **Inference Operations**: [embedData](https://docs.pinecone.io/reference/api/2024-07/inference/generate-embeddings)
9+
* **Inference Operations**: [embedData](https://docs.pinecone.io/reference/api/2024-07/inference/generate-embeddings), and [rerank](https://docs.pinecone.io/reference/api/2024-10/inference/rerank)
1010
* **Assistant Operations**: [listAssistants](https://docs.pinecone.io/reference/api/2024-07/assistant/list-assistants), [createAssistant](https://docs.pinecone.io/reference/api/2024-07/assistant/create-assistant), [describeAssistant](https://docs.pinecone.io/reference/api/2024-07/assistant/describe-assistant), [deleteAssistant](https://docs.pinecone.io/reference/api/2024-07/assistant/delete-assistant), [listFiles](https://docs.pinecone.io/reference/api/2024-07/assistant/list-files), [uploadFile](https://docs.pinecone.io/reference/api/2024-07/assistant/create-file), [describeFile](https://docs.pinecone.io/reference/api/2024-07/assistant/describe-file), [deleteFile](https://docs.pinecone.io/reference/api/2024-07/assistant/delete-file), [chatWithAssistant](https://docs.pinecone.io/reference/api/2024-07/assistant/chat-completion-assistant)
1111
- these operations are provided by two services: `PineconeAssistantService` and `PineconeAssistantFileService`
1212

@@ -24,7 +24,7 @@ The currently supported Scala versions are **2.12, 2.13**, and **3**.
2424
To pull the library you have to add the following dependency to your *build.sbt*
2525

2626
```
27-
"io.cequence" %% "pinecone-scala-client" % "1.0.2"
27+
"io.cequence" %% "pinecone-scala-client" % "1.1.0"
2828
```
2929

3030
or to *pom.xml* (if you use maven)
@@ -33,7 +33,7 @@ or to *pom.xml* (if you use maven)
3333
<dependency>
3434
<groupId>io.cequence</groupId>
3535
<artifactId>pinecone-scala-client_2.12</artifactId>
36-
<version>1.0.2</version>
36+
<version>1.1.0</version>
3737
</dependency>
3838
```
3939

@@ -102,33 +102,39 @@ Same as with `PineconeIndexService`, you need to first provide implicit executio
102102

103103
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.
104104

105-
With config
105+
- Default config
106+
107+
```scala
108+
val service = PineconeInferenceServiceFactory()
109+
```
110+
111+
- Custom config
106112
```scala
107113
val config = ConfigFactory.load("path_to_my_custom_config")
108114
val service = PineconeInferenceServiceFactory(config)
109115
```
110116

111-
Directly with api-key
117+
- Directly with api-key
112118
```scala
113119
val service = PineconeInferenceServiceFactory(
114120
apiKey = "your_api_key"
115121
)
116122
```
117123

118-
- Custom config
119-
```scala
120-
val config = ConfigFactory.load("path_to_my_custom_config")
121-
PineconeInferenceServiceFactory("index_name", config)
122-
```
123-
124124
**Id. Obtaining `PineconeAssistantService`**
125125

126126

127-
- With config
127+
- Default config
128128

129129
```scala
130-
val config = ConfigFactory.load("path_to_my_custom_config")
131-
val service = PineconeAssistantServiceFactory(config)
130+
val service = PineconeAssistantServiceFactory()
131+
```
132+
133+
- Custom config
134+
135+
```scala
136+
val config = ConfigFactory.load("path_to_my_custom_config")
137+
val service = PineconeAssistantServiceFactory(config)
132138
```
133139

134140
- Directly with api-key
@@ -139,20 +145,19 @@ Directly with api-key
139145
)
140146
```
141147

142-
- Custom config
148+
**Ie. Obtaining `PineconeAssistantFileService`**
149+
150+
- Default config
143151

144152
```scala
145-
val config = ConfigFactory.load("path_to_my_custom_config")
146-
PineconeAssistantServiceFactory(config)
153+
val service = PineconeAssistantFileServiceFactory()
147154
```
148155

149-
**Ie. Obtaining `PineconeAssistantFileService`**
150-
151-
- With config
156+
- Custom config
152157

153158
```scala
154-
val config = ConfigFactory.load("path_to_my_custom_config")
155-
val service = PineconeAssistantFileServiceFactory(config)
159+
val config = ConfigFactory.load("path_to_my_custom_config")
160+
val service = PineconeAssistantFileServiceFactory(config)
156161
```
157162

158163
- Directly with api-key
@@ -163,15 +168,6 @@ Directly with api-key
163168
)
164169
```
165170

166-
- Custom config
167-
168-
```scala
169-
val config = ConfigFactory.load("path_to_my_custom_config")
170-
PineconeAssistantFileServiceFactory(config)
171-
```
172-
173-
174-
175171
**II. Calling functions**
176172

177173
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`.
@@ -430,6 +426,17 @@ Examples:
430426
}
431427
```
432428

429+
- Rerank documents / chunks
430+
431+
```scala
432+
pineconeInferenceService.rerank(
433+
query = "The tech company Apple is known for its innovative products like the iPhone.",
434+
documents = Seq(...)
435+
).map(
436+
_.data.foreach(println)
437+
)
438+
```
439+
433440
** Assistant Operations**
434441

435442
- List assistants
@@ -542,7 +549,7 @@ pinecone-scala-client {
542549
}
543550
```
544551

545-
2. _I got an exception like `com.typesafe.config.ConfigException$UnresolvedSubstitution: pinecone-scala-client.conf @ jar:file:.../io/cequence/pinecone-scala-client_2.13/1.0.2/pinecone-scala-client_2.13-1.0.2.jar!/pinecone-scala-client.conf: 4: Could not resolve substitution to a value: ${PINECONE_SCALA_CLIENT_API_KEY}`. What should I do?_
552+
2. _I got an exception like `com.typesafe.config.ConfigException$UnresolvedSubstitution: pinecone-scala-client.conf @ jar:file:.../io/cequence/pinecone-scala-client_2.13/1.1.0/pinecone-scala-client_2.13-1.1.0.jar!/pinecone-scala-client.conf: 4: Could not resolve substitution to a value: ${PINECONE_SCALA_CLIENT_API_KEY}`. What should I do?_
546553

547554
Set the env. variable `PINECONE_SCALA_CLIENT_API_KEY`. If you don't have one register [here](https://app.pinecone.io/?sessionType=signup).
548555

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ val scala33 = "3.3.1"
88

99
ThisBuild / organization := "io.cequence"
1010
ThisBuild / scalaVersion := scala212
11-
ThisBuild / version := "1.0.2"
11+
ThisBuild / version := "1.1.0"
1212
ThisBuild / isSnapshot := false
1313

1414
lazy val core = (project in file("pinecone-core"))

0 commit comments

Comments
 (0)