-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to Inference 1.1.0 (w/ Rerank API) (#389)
## Problem Adopts version `1.1.0` of [python-plugin-inference](https://pypi.org/project/pinecone-plugin-inference/1.1.0/), which contains support for Rerank API. ## Solution Describe the approach you took. Link to any relevant bugs, issues, docs, or other resources. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Describe specific steps for validating this change.
- Loading branch information
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from pinecone import Pinecone | ||
from pinecone.grpc import PineconeGRPC | ||
|
||
|
||
class TestInferencePluginRerank: | ||
def test_rerank(self, api_key): | ||
pc = Pinecone(api_key=api_key) | ||
|
||
model = "bge-reranker-v2-m3" | ||
result = pc.inference.rerank( | ||
model=model, | ||
query="i love dogs", | ||
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"], | ||
top_n=1, | ||
return_documents=True, | ||
) | ||
assert len(result.data) == 1 | ||
assert result.data[0].index == 1 | ||
assert result.data[0].document.text == "everyone loves dogs" | ||
assert result.model == model | ||
assert isinstance(result.usage.rerank_units, int) | ||
assert result.usage.rerank_units == 1 | ||
|
||
def test_rerank_grpc(self, api_key): | ||
pc = PineconeGRPC(api_key=api_key) | ||
|
||
model = "bge-reranker-v2-m3" | ||
result = pc.inference.rerank( | ||
model=model, | ||
query="i love dogs", | ||
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"], | ||
top_n=1, | ||
return_documents=True, | ||
) | ||
assert len(result.data) == 1 | ||
assert result.data[0].index == 1 | ||
assert result.data[0].document.text == "everyone loves dogs" | ||
assert result.model == model | ||
assert isinstance(result.usage.rerank_units, int) | ||
assert result.usage.rerank_units == 1 |