-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add better error messages for mistaken from_texts
and from_documents
#342
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
00d46b5
Add better error messages for from_texts and from_documents
jhamon b071d86
Make a variable for repo location url
jhamon 596cc51
Merge branch 'main' into jhamon/from-texts-helpful-error
jhamon 1c465fe
Merge branch 'main' into jhamon/from-texts-helpful-error
jhamon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pinecone.utils import docslinks | ||
|
||
KB_ARTICLE = docslinks['LANGCHAIN_IMPORT_KB_ARTICLE'] | ||
GITHUB_REPO = docslinks['GITHUB_REPO'] | ||
|
||
def _build_langchain_attribute_error_message(method_name: str): | ||
return f"""{method_name} is not a top-level attribute of the Pinecone class provided by pinecone's official python package developed at {GITHUB_REPO}. You may have a name collision with an export from another dependency in your project that wraps Pinecone functionality and exports a similarly named class. Please refer to the following knowledge base article for more information: {KB_ARTICLE} | ||
""" | ||
|
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
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,4 @@ | ||
docslinks = { | ||
'GITHUB_REPO': 'https://github.com/pinecone-io/pinecone-python-client', | ||
'LANGCHAIN_IMPORT_KB_ARTICLE': 'https://docs.pinecone.io/troubleshooting/pinecone-attribute-errors-with-langchain' | ||
} |
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,19 @@ | ||
import pytest | ||
from pinecone import Pinecone | ||
|
||
class TestLangchainErrorMessages(): | ||
def test_error_from_texts_positional_args(self): | ||
with pytest.raises(AttributeError) as e: | ||
Pinecone.from_texts("texts", "id") | ||
assert "from_texts is not a top-level attribute of the Pinecone class" in str(e.value) | ||
|
||
def test_error_from_texts_kwargs(self): | ||
with pytest.raises(AttributeError) as e: | ||
Pinecone.from_texts(foo="texts", bar="id", num_threads=1) | ||
assert "from_texts is not a top-level attribute of the Pinecone class" in str(e.value) | ||
|
||
def test_error_from_documents(self): | ||
with pytest.raises(AttributeError) as e: | ||
Pinecone.from_documents("documents", "id") | ||
assert "from_documents is not a top-level attribute of the Pinecone class" in str(e.value) | ||
|
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,10 @@ | ||
import pytest | ||
import requests | ||
from pinecone.utils import docslinks | ||
|
||
urls = list(docslinks.values()) | ||
|
||
@pytest.mark.parametrize("url", urls) | ||
def test_valid_links(url): | ||
response = requests.get(url) | ||
assert response.status_code == 200, f"Docs link is invalid: {url}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, good thinking. 👍