Skip to content

Commit 1d6c50a

Browse files
authored
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.
1 parent 9fb0a24 commit 1d6c50a

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

Diff for: poetry.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ lz4 = { version = ">=3.1.3", optional = true }
6868
protobuf = { version = "^4.25", optional = true }
6969
protoc-gen-openapiv2 = {version = "^0.0.1", optional = true }
7070
pinecone-plugin-interface = "^0.0.7"
71-
pinecone-plugin-inference = "^1.0.3"
71+
pinecone-plugin-inference = "^1.1.0"
7272

7373
[tool.poetry.group.types]
7474
optional = true

Diff for: tests/integration/inference/test_rerank.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from pinecone import Pinecone
2+
from pinecone.grpc import PineconeGRPC
3+
4+
5+
class TestInferencePluginRerank:
6+
def test_rerank(self, api_key):
7+
pc = Pinecone(api_key=api_key)
8+
9+
model = "bge-reranker-v2-m3"
10+
result = pc.inference.rerank(
11+
model=model,
12+
query="i love dogs",
13+
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"],
14+
top_n=1,
15+
return_documents=True,
16+
)
17+
assert len(result.data) == 1
18+
assert result.data[0].index == 1
19+
assert result.data[0].document.text == "everyone loves dogs"
20+
assert result.model == model
21+
assert isinstance(result.usage.rerank_units, int)
22+
assert result.usage.rerank_units == 1
23+
24+
def test_rerank_grpc(self, api_key):
25+
pc = PineconeGRPC(api_key=api_key)
26+
27+
model = "bge-reranker-v2-m3"
28+
result = pc.inference.rerank(
29+
model=model,
30+
query="i love dogs",
31+
documents=["dogs are pretty cool", "everyone loves dogs", "I'm a cat person"],
32+
top_n=1,
33+
return_documents=True,
34+
)
35+
assert len(result.data) == 1
36+
assert result.data[0].index == 1
37+
assert result.data[0].document.text == "everyone loves dogs"
38+
assert result.model == model
39+
assert isinstance(result.usage.rerank_units, int)
40+
assert result.usage.rerank_units == 1

0 commit comments

Comments
 (0)