Skip to content

Commit

Permalink
Update the datatype for parameters in rerank() (#163)
Browse files Browse the repository at this point in the history
## Problem

Update the datatype of `parameters` in `rerank()` from `Map<String,
Object>` to `Map<String, String>` to better match the OAS.

## Solution

Updated the datatype for the rerank() so the base overloaded method is
now:
```java
public RerankResult rerank(String model,
                               String query,
                               List<Map<String, String>> documents,
                               List<String> rankFields,
                               int topN,
                               boolean returnDocuments,
                               Map<String, String> parameters)
``` 
As a part of this change, I have also updated the integration test and
README.

## Type of Change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

## Test Plan

Updated the integration test for rerank and the rest of them should run
as it is.
  • Loading branch information
rohanshah18 committed Oct 24, 2024
1 parent 416934d commit 35ecac2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ int topN = 2;
boolean returnDocuments = true;

// Additional model-specific parameters for the reranker
Map<String, Object> parameters = new HashMap<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("truncate", "END");

// Send ranking request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testRerank() throws ApiException {
List<String> rankFields = Arrays.asList("my_field");
int topN = 2;
boolean returnDocuments = true;
Map<String, Object> parameters = new HashMap<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("truncate", "END");

RerankResult result = inference.rerank(model, query, documents, rankFields, topN, returnDocuments, parameters);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/pinecone/clients/Inference.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public RerankResult rerank(String model,
List<String> rankFields,
int topN,
boolean returnDocuments,
Map<String, Object> parameters) throws ApiException {
Map<String, String> parameters) throws ApiException {
RerankRequest rerankRequest = new RerankRequest();

rerankRequest
Expand All @@ -114,7 +114,7 @@ public RerankResult rerank(String model,
.rankFields(rankFields)
.topN(topN)
.returnDocuments(returnDocuments)
.putAdditionalProperty("parameters", parameters);
.parameters(parameters);

return inferenceApi.rerank(rerankRequest);
}
Expand Down

0 comments on commit 35ecac2

Please sign in to comment.