Skip to content

Commit b7a6733

Browse files
committed
Improving documentation of PineconeIndexService and PineconeVectorService + refactoring params to camel case
1 parent d8e56ba commit b7a6733

File tree

7 files changed

+71
-21
lines changed

7 files changed

+71
-21
lines changed

pinecone-client/src/main/scala/io/cequence/pineconescala/service/PineconeIndexServiceImpl.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ private class PineconeIndexServiceImpl(
114114
Tag.metric -> Some(settings.metric.toString),
115115
Tag.pods -> Some(settings.pods),
116116
Tag.replicas -> Some(settings.replicas),
117-
Tag.pod_type -> Some(settings.pod_type.toString),
118-
Tag.metadata_config -> (if (settings.metadata_config.nonEmpty) Some(settings.metadata_config) else None),
119-
Tag.source_collection -> settings.source_collection
117+
Tag.pod_type -> Some(settings.podType.toString),
118+
Tag.metadata_config -> (if (settings.metadataConfig.nonEmpty) Some(settings.metadataConfig) else None),
119+
Tag.source_collection -> settings.sourceCollection
120120
),
121121
acceptableStatusCodes = Nil // don't parse response at all
122122
).map { response =>
@@ -162,14 +162,14 @@ private class PineconeIndexServiceImpl(
162162
override def configureIndex(
163163
indexName: String,
164164
replicas: Option[Int],
165-
pod_type: Option[PodType.Value]
165+
podType: Option[PodType.Value]
166166
): Future[ConfigureIndexResponse] =
167167
execPATCHWithStatus(
168168
EndPoint.databases,
169169
endPointParam = Some(indexName),
170170
bodyParams = jsonBodyParams(
171171
Tag.replicas -> replicas,
172-
Tag.pod_type -> pod_type.map(_.toString)
172+
Tag.pod_type -> podType.map(_.toString)
173173
)
174174
).map { response =>
175175
val (statusCode, message) = statusCodeAndMessage(response)

pinecone-client/src/main/scala/io/cequence/pineconescala/service/examples/PineconeIndexExample.scala

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.cequence.pineconescala.service.examples
22

33
import akka.actor.ActorSystem
44
import akka.stream.Materializer
5+
import io.cequence.pineconescala.domain.PodType
56
import io.cequence.pineconescala.service.PineconeIndexServiceFactory
67

78
import scala.concurrent.ExecutionContext
@@ -20,7 +21,17 @@ object PineconeIndexExample extends App {
2021

2122
_ = println(indexes.mkString(", "))
2223

23-
_ <- service.describeIndex(indexes(0)).map(println(_))
24+
indexInfo <- service.describeIndex(indexes(0))
25+
26+
_ = println(indexInfo)
27+
28+
deleteResponse <- service.deleteIndex(indexes(0))
29+
30+
_ = println(deleteResponse)
31+
32+
indexInfo <- service.describeIndex(indexes(0))
33+
34+
_ = println(indexInfo)
2435

2536
createResponse <- service.createIndex(
2637
name = "auto-gpt-test",
@@ -29,6 +40,20 @@ object PineconeIndexExample extends App {
2940

3041
_ = println(createResponse)
3142

43+
configureIndexResponse <- service.configureIndex(
44+
"auto-gpt-test",
45+
replicas = Some(0),
46+
podType = Some(PodType.p1_x1)
47+
)
48+
49+
_ = println(configureIndexResponse)
50+
51+
_ = Thread.sleep(5000)
52+
53+
indexInfo <- service.describeIndex("auto-gpt-test")
54+
55+
_ = println(indexInfo)
56+
3257
createResponse2 <- service.createIndex(
3358
name = "auto-gpt-test",
3459
dimension = 1536
@@ -38,7 +63,27 @@ object PineconeIndexExample extends App {
3863

3964
indexes2 <- service.listIndexes
4065

41-
_ = println(indexes2.mkString(" "))
66+
_ = println(indexes2.mkString(", "))
67+
68+
createResponse3 <- service.createCollection("auto-gpt-test-collection", "auto-gpt-test")
69+
70+
_ = println(createResponse3)
71+
72+
collections <- service.listCollections
73+
74+
_ = println(collections.mkString(", "))
75+
76+
collectionInfo <- service.describeCollection("auto-gpt-test-collection")
77+
78+
_ = println(collectionInfo)
79+
80+
deleteResponse2 <- service.deleteCollection("auto-gpt-test-collection")
81+
82+
_ = println(deleteResponse2)
83+
84+
collections2 <- service.listCollections
85+
86+
_ = println(collections2.mkString(", "))
4287
} yield {
4388
System.exit(0)
4489
}
@@ -47,4 +92,4 @@ object PineconeIndexExample extends App {
4792
println(e)
4893
System.exit(1)
4994
}
50-
}
95+
}

pinecone-client/src/main/scala/io/cequence/pineconescala/service/examples/PineconeVectorExample.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object PineconeVectorExample extends App {
2525

2626
stats <- service.describeIndexStats
2727

28-
upsertResponse <- service.upsert(
28+
vectorUpsertedCount <- service.upsert(
2929
vectors = Seq(
3030
PVector(
3131
id = testIds(0),
@@ -103,7 +103,7 @@ object PineconeVectorExample extends App {
103103
} yield {
104104
println(stats)
105105
println()
106-
println(upsertResponse)
106+
println(vectorUpsertedCount)
107107
println()
108108
println("Before update:")
109109
println(fetchResponse)

pinecone-core/src/main/scala/io/cequence/pineconescala/domain/settings/CreateIndexSettings.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ case class CreateIndexSettings(
1414
replicas: Int,
1515

1616
// The type of pod to use. One of s1, p1, or p2 appended with . and one of x1, x2, x4, or x8.
17-
pod_type: PodType.Value,
17+
podType: PodType.Value,
1818

1919
// Configuration for the behavior of Pinecone's internal metadata index.
2020
// By default, all metadata is indexed; when metadata_config is present, only specified metadata fields are indexed.
21-
metadata_config: Map[String, String] = Map(),
21+
metadataConfig: Map[String, String] = Map(),
2222

2323
// The name of the collection to create an index from
24-
source_collection: Option[String] = None
24+
sourceCollection: Option[String] = None
2525
)

pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeIndexService.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import scala.concurrent.Future
1111
*
1212
* The following services are supported:
1313
*
14-
* - Collection Operations: listCollections, createCollection, describeCollection, and deleteCollection
14+
* - '''Collection Operations''': listCollections, createCollection, describeCollection, and deleteCollection
1515
*
16-
* - Index Operations: listIndexes, creatIndex, describeIndex, deleteIndex, and configureIndex
16+
* - '''Index Operations''': listIndexes, creatIndex, describeIndex, deleteIndex, and configureIndex
1717
*
1818
* @since Apr 2023
1919
*/
@@ -113,13 +113,13 @@ trait PineconeIndexService extends PineconeServiceConsts {
113113
*
114114
* @param indexName The name of the index
115115
* @param replicas The desired number of replicas for the index.
116-
* @param pod_type The new pod type for the index.
116+
* @param podType The new pod type for the index.
117117
* @return Whether the index was updated successfully or not found.
118118
* @see <a href="https://docs.pinecone.io/reference/configure_index">Pinecone Doc</a>
119119
*/
120120
def configureIndex(
121121
indexName: String,
122122
replicas: Option[Int],
123-
pod_type: Option[PodType.Value]
123+
podType: Option[PodType.Value]
124124
): Future[ConfigureIndexResponse]
125125
}

pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeServiceConsts.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ trait PineconeServiceConsts {
2828
metric = Metric.cosine,
2929
pods = 1,
3030
replicas = 1,
31-
pod_type = PodType.p1_x1,
32-
metadata_config = Map(),
33-
source_collection = None
31+
podType = PodType.p1_x1,
32+
metadataConfig = Map(),
33+
sourceCollection = None
3434
)
3535
}
3636
}

pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import scala.concurrent.Future
1212
*
1313
* The following services are supported:
1414
*
15-
* - describeIndexStats, query, delete, fetch, update, and upsert
15+
* - describeIndexStats
16+
* - query - by vector or by id
17+
* - delete - by filter or ids, or delete all
18+
* - fetch
19+
* - update
20+
* - upsert
1621
*
1722
* @since Apr 2023
1823
*/

0 commit comments

Comments
 (0)