-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inference plugin and tests (#370)
## Problem We want to ship inference as part of the core SDK ## Solution Add a dependency on v1.0.2 of the inference plugin, which includes a recent fix to plugin installation for use with the GRPC client. ## Usage The plugin should automatically be installed and available for usage. ```python from pinecone import Pinecone pc = Pinecone(api_key='key') embedding_model = "multilingual-e5-large" embeddings = pc.inference.embed( model=embedding_model, inputs=["The quick brown fox jumps over the lazy dog.", "lorem ipsum"], parameters={"input_type": "query", "truncate": "END"}, ) ``` ## Type of Change - [x] New feature (non-breaking change which adds functionality) ## Test Plan See tests passing.
- Loading branch information
Showing
6 changed files
with
79 additions
and
48 deletions.
There are no files selected for viewing
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
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
Empty file.
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,7 @@ | ||
import pytest | ||
from ..helpers import get_environment_var | ||
|
||
|
||
@pytest.fixture() | ||
def api_key(): | ||
return get_environment_var("PINECONE_API_KEY") |
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,34 @@ | ||
from pinecone import Pinecone | ||
from pinecone.grpc import PineconeGRPC | ||
|
||
|
||
class TestInferencePlugin: | ||
def test_embed(self, api_key): | ||
pc = Pinecone(api_key=api_key) | ||
|
||
embedding_model = "multilingual-e5-large" | ||
embeddings = pc.inference.embed( | ||
model=embedding_model, | ||
inputs=["The quick brown fox jumps over the lazy dog.", "lorem ipsum"], | ||
parameters={"input_type": "query", "truncate": "END"}, | ||
) | ||
|
||
assert len(embeddings.get("data")) == 2 | ||
assert len(embeddings.get("data")[0]["values"]) == 1024 | ||
assert len(embeddings.get("data")[1]["values"]) == 1024 | ||
assert embeddings.get("model") == embedding_model | ||
|
||
def test_embed_grpc(self, api_key): | ||
pc = PineconeGRPC(api_key=api_key) | ||
|
||
embedding_model = "multilingual-e5-large" | ||
embeddings = pc.inference.embed( | ||
model=embedding_model, | ||
inputs=["The quick brown fox jumps over the lazy dog.", "lorem ipsum"], | ||
parameters={"input_type": "query", "truncate": "END"}, | ||
) | ||
|
||
assert len(embeddings.get("data")) == 2 | ||
assert len(embeddings.get("data")[0]["values"]) == 1024 | ||
assert len(embeddings.get("data")[1]["values"]) == 1024 | ||
assert embeddings.get("model") == embedding_model |