Skip to content

Commit

Permalink
Upgrade Pinecone java client to 4.0.1 (#2328)
Browse files Browse the repository at this point in the history
- Upgrade the java client from 0.8.0 to 4.0.1
   - Use io.pinecone.clients.Pinecone to setup the client configuration with the API key
     - Remove projectId, environment and other deprecated client configurations
   - Update upsert, delete, search operations with the new client
   - Remove the projectID and Environment configurations from the builder
   - Updated the Pinecone vectorstore autoconfiguration
   - Update tests

Signed-off-by: Ilayaperumal Gopinathan <[email protected]>

Disable autoconfig IT until the auto-configuration is modularised
  • Loading branch information
ilayaperumalg authored Feb 26, 2025
1 parent 96c8157 commit c91163b
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 210 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@
<coherence.version>24.09</coherence.version>
<milvus.version>2.5.4</milvus.version>
<gemfire.testcontainers.version>2.3.0</gemfire.testcontainers.version>
<pinecone.version>0.8.0</pinecone.version>

<pinecone.version>4.0.1</pinecone.version>
<pinecone.protobuf-java-util.version>4.29.3</pinecone.protobuf-java-util.version>

<fastjson2.version>2.0.46</fastjson2.version>
<azure-core.version>1.53.0</azure-core.version>
<azure-json.version>1.3.0</azure-json.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ link:https://www.pinecone.io/[Pinecone] is a popular cloud-based vector database
== Prerequisites

1. Pinecone Account: Before you start, sign up for a link:https://app.pinecone.io/[Pinecone account].
2. Pinecone Project: Once registered, create a new project, an index, and generate an API key. You'll need these details for configuration.
2. Pinecone Project: Once registered, generate an API key and create and index. You'll need these details for configuration.
3. `EmbeddingModel` instance to compute the document embeddings. Several options are available:
- If required, an API key for the xref:api/embeddings.adoc#available-implementations[EmbeddingModel] to generate the embeddings stored by the `PineconeVectorStore`.

To set up `PineconeVectorStore`, gather the following details from your Pinecone account:

* Pinecone API Key
* Pinecone Environment
* Pinecone Project ID
* Pinecone Index Name
* Pinecone Namespace

Expand Down Expand Up @@ -70,8 +68,6 @@ A simple configuration can either be provided via Spring Boot's _application.pro
[source,properties]
----
spring.ai.vectorstore.pinecone.apiKey=<your api key>
spring.ai.vectorstore.pinecone.environment=<your environment>
spring.ai.vectorstore.pinecone.projectId=<your project id>
spring.ai.vectorstore.pinecone.index-name=<your index name>
# API key if needed, e.g. OpenAI
Expand Down Expand Up @@ -109,8 +105,6 @@ You can use the following properties in your Spring Boot configuration to custom
|Property| Description | Default value

|`spring.ai.vectorstore.pinecone.api-key`| Pinecone API Key | -
|`spring.ai.vectorstore.pinecone.environment`| Pinecone environment | `gcp-starter`
|`spring.ai.vectorstore.pinecone.project-id`| Pinecone project ID | -
|`spring.ai.vectorstore.pinecone.index-name`| Pinecone index name | -
|`spring.ai.vectorstore.pinecone.namespace`| Pinecone namespace | -
|`spring.ai.vectorstore.pinecone.content-field-name`| Pinecone metadata field name used to store the original text content. | `document_content`
Expand Down Expand Up @@ -191,8 +185,6 @@ To configure Pinecone in your application, you can use the following setup:
public VectorStore pineconeVectorStore(EmbeddingModel embeddingModel) {
return PineconeVectorStore.builder(embeddingModel)
.apiKey(PINECONE_API_KEY)
.projectId(PINECONE_PROJECT_ID)
.environment(PINECONE_ENVIRONMENT)
.indexName(PINECONE_INDEX_NAME)
.namespace(PINECONE_NAMESPACE) // the free tier doesn't support namespaces.
.contentFieldName(CUSTOM_CONTENT_FIELD_NAME) // optional field to store the original content. Defaults to `document_content`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ public PineconeVectorStore vectorStore(EmbeddingModel embeddingModel, PineconeVe

return PineconeVectorStore.builder(embeddingModel)
.apiKey(properties.getApiKey())
.projectId(properties.getProjectId())
.environment(properties.getEnvironment())
.indexName(properties.getIndexName())
.namespace(properties.getNamespace())
.contentFieldName(properties.getContentFieldName())
.distanceMetadataFieldName(properties.getDistanceMetadataFieldName())
.serverSideTimeout(properties.getServerSideTimeout())
.observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP))
.customObservationConvention(customObservationConvention.getIfAvailable(() -> null))
.batchingStrategy(batchingStrategy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.micrometer.observation.tck.TestObservationRegistry;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

Expand All @@ -51,14 +52,13 @@
* @author Thomas Vitale
*/
@EnabledIfEnvironmentVariable(named = "PINECONE_API_KEY", matches = ".+")
@Disabled("Can be re-enabled once the auto-configuration is modularised")
public class PineconeVectorStoreAutoConfigurationIT {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(PineconeVectorStoreAutoConfiguration.class))
.withUserConfiguration(Config.class)
.withPropertyValues("spring.ai.vectorstore.pinecone.apiKey=" + System.getenv("PINECONE_API_KEY"),
"spring.ai.vectorstore.pinecone.environment=gcp-starter",
"spring.ai.vectorstore.pinecone.projectId=814621f",
"spring.ai.vectorstore.pinecone.indexName=spring-ai-test-index",
"spring.ai.vectorstore.pinecone.contentFieldName=customContentField",
"spring.ai.vectorstore.pinecone.distanceMetadataFieldName=customDistanceField");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.anyOf;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.either;

import java.time.Duration;
import java.util.HashMap;
Expand Down
33 changes: 1 addition & 32 deletions vector-stores/spring-ai-pinecone-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,13 @@
<dependency>
<groupId>io.pinecone</groupId>
<artifactId>pinecone-client</artifactId>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</exclusion>
</exclusions>
<version>${pinecone.version}</version>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.59.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.59.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.59.1</version>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf-java.version}</version>
<version>${pinecone.protobuf-java-util.version}</version>
</dependency>

<!-- TESTING -->
Expand All @@ -113,7 +83,6 @@
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

Expand Down
Loading

0 comments on commit c91163b

Please sign in to comment.