Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ pinecone.deleteCollection("example-collection");

# Inference
## Embed

The Pinecone SDK now supports creating embeddings via the [Inference API](https://docs.pinecone.io/guides/inference/understanding-inference).

```java
Expand Down Expand Up @@ -689,6 +690,7 @@ List<Embedding> embeddedData = embeddings.getData();
```

## Rerank

The following example shows how to rerank items according to their relevance to a query.

```java
Expand Down Expand Up @@ -751,6 +753,41 @@ RerankResult result = inference.rerank(model, query, documents, rankFields, topN
System.out.println(result.getData());
```

## Models

The following example shows how to list and describe an embedding model.

```java
import io.pinecone.clients.Inference;
import io.pinecone.clients.Pinecone;
import org.openapitools.inference.client.ApiException;
import org.openapitools.inference.client.model.ModelInfo;
import org.openapitools.inference.client.model.ModelInfoList;
...

Pinecone pinecone = new Pinecone
.Builder(System.getenv("PINECONE_API_KEY"))
.build();

Inference inference = pinecone.getInferenceClient();

// list models
ModelInfoList models = inference.listModels();
System.out.println(models);

// list models by filtering with type
models = inference.listModels("rerank");
System.out.println(models);

// list models by filtering with type and vectorType
models = inference.listModels("embed", "dense");
System.out.println(models);

// describe a model
ModelInfo modelInfo = inference.describeModel("llama-text-embed-v2");
System.out.println(modelInfo);
```

# Imports
## Start an import

Expand Down Expand Up @@ -862,7 +899,7 @@ BackupList backupList = pinecone.listIndexBackups(indexName1);
System.out.println("backupList for index1: " + backupList);

// list all backups for a project
backupList = pinecone.listProjectBackups();
backupList = pinecone.listProjectBackups(3, "some-pagination-token");
System.out.println("backupList for project: " + backupList);

// describe backup
Expand Down
2 changes: 1 addition & 1 deletion codegen/apis
Submodule apis updated from daf808 to a91585
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.pinecone.integration.inference;

import io.pinecone.clients.Inference;
import io.pinecone.clients.Pinecone;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openapitools.inference.client.ApiException;
import org.openapitools.inference.client.model.ModelInfo;
import org.openapitools.inference.client.model.ModelInfoList;

public class ModelsTest {
private static final Pinecone pinecone = new Pinecone
.Builder(System.getenv("PINECONE_API_KEY"))
.withSourceTag("pinecone_test")
.build();

private static final Inference inference = pinecone.getInferenceClient();

@Test
public void testListAndDescribeModels() throws ApiException {
ModelInfoList models = inference.listModels();
Assertions.assertNotNull(models.getModels());

models = inference.listModels("rerank");
Assertions.assertNotNull(models.getModels());

models = inference.listModels("embed", "dense");
Assertions.assertNotNull(models.getModels());

ModelInfo modelInfo = inference.describeModel("llama-text-embed-v2");
Assertions.assertNotNull(modelInfo);
}
}
40 changes: 40 additions & 0 deletions src/main/java/io/pinecone/clients/Inference.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,46 @@ public RerankResult rerank(String model,
return inferenceApi.rerank(rerankRequest);
}

/**
* Overloaded method to list available models.
* @return ModelInfoList
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ModelInfoList listModels() throws ApiException {
return inferenceApi.listModels(null, null);
}

/**
* Overloaded method to list available models based on type parameter only.
* @param type Filter models by type (&#39;embed&#39; or &#39;rerank&#39;). (optional)
* @return ModelInfoList
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ModelInfoList listModels(String type) throws ApiException {
return inferenceApi.listModels(type, null);
}

/**
* List available models.
* @param type Filter models by type (&#39;embed&#39; or &#39;rerank&#39;). (optional)
* @param vectorType Filter embedding models by vector type (&#39;dense&#39; or &#39;sparse&#39;). Only relevant when &#x60;type&#x3D;embed&#x60;. (optional)
* @return ModelInfoList
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ModelInfoList listModels(String type, String vectorType) throws ApiException {
return inferenceApi.listModels(type, vectorType);
}

/**
* Get available model details.
* @param modelName The name of the model to look up. (required)
* @return ModelInfo
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ModelInfo describeModel(String modelName) throws ApiException {
return inferenceApi.getModel(modelName);
}

/**
* Converts a list of input strings to EmbedRequestInputsInner objects.
*
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/io/pinecone/clients/Pinecone.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,17 +913,26 @@ public BackupList listIndexBackups(String indexName, Integer limit, String pagin

/**
* List backups for all indexes in a project
* List all backups for a project.
*
* @return BackupList
*/
public BackupList listProjectBackups() throws ApiException {
return manageIndexesApi.listProjectBackups();
return listProjectBackups(null, null);
}

/**
* List backups for all indexes in a project
* @param limit The number of results to return per page. (optional)
* @param paginationToken The token to use to retrieve the next page of results. (optional)
*
* @return BackupList
*/
public BackupList listProjectBackups(Integer limit, String paginationToken) throws ApiException {
return manageIndexesApi.listProjectBackups(limit, paginationToken);
}

/**
* Describe a backup
* Get a description of a backup.
*
* @param backupId The ID of the backup to describe. (required)
* @return BackupModel
Expand Down Expand Up @@ -959,7 +968,7 @@ public void createIndexFromBackup(String backupId, String indexName, Map<String,
if (deletionProtection != null) {
createIndexFromBackupRequest.deletionProtection(deletionProtection);
}
manageIndexesApi.createIndexFromBackup(backupId, createIndexFromBackupRequest);
manageIndexesApi.createIndexFromBackupOperation(backupId, createIndexFromBackupRequest);
}

/**
Expand All @@ -974,7 +983,7 @@ public void createIndexFromBackup(String backupId, String indexName, Map<String,
public CreateIndexFromBackupResponse createIndexFromBackup(String backupId, String indexName) throws ApiException {
CreateIndexFromBackupRequest createIndexFromBackupRequest = new CreateIndexFromBackupRequest()
.name(indexName);
return manageIndexesApi.createIndexFromBackup(backupId, createIndexFromBackupRequest);
return manageIndexesApi.createIndexFromBackupOperation(backupId, createIndexFromBackupRequest);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* <p>ApiException class.</p>
*/
@SuppressWarnings("serial")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-04-29T13:39:23.829370Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-05-22T16:07:13.211110Z[Etc/UTC]")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package org.openapitools.db_control.client;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-04-29T13:39:23.829370Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-05-22T16:07:13.211110Z[Etc/UTC]")
public class Configuration {
public static final String VERSION = "2025-04";

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openapitools/db_control/client/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package org.openapitools.db_control.client;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-04-29T13:39:23.829370Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-05-22T16:07:13.211110Z[Etc/UTC]")
public class Pair {
private String name = "";
private String value = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Collection;
import java.util.Iterator;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-04-29T13:39:23.829370Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-05-22T16:07:13.211110Z[Etc/UTC]")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
Expand Down
Loading
Loading