Skip to content
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

fix(pinecone): fix PineconeStore to support null or undefined pageContent #6920

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

sam-trost
Copy link
Contributor

@sam-trost sam-trost commented Oct 2, 2024

This change provides compatibility with vectorstores that may not have been populated by langchain and do not have the pageContent property defined or populated. Previous versions of this module supported this, so this is to provide backwards compatibility for those data pipelines & workloads.

Note that any new Documents added to the document store via langchain will ensure pageContent is set.

Fixes #6919

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Oct 3, 2024 0:12am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Oct 3, 2024 0:12am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases labels Oct 2, 2024
@sam-trost sam-trost changed the title + fix PineconeStore to support null or undefined pageContent community[patch]: fix PineconeStore to support null or undefined pageContent Oct 2, 2024
@sam-trost sam-trost changed the title community[patch]: fix PineconeStore to support null or undefined pageContent fix(community): fix PineconeStore to support null or undefined pageContent Oct 2, 2024
@@ -425,7 +425,7 @@ export class PineconeStore extends VectorStore {
documentsWithScores.push([
new Document({
id,
pageContent: pageContent.toString(),
pageContent: pageContent?.toString(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fallback to something like an empty string?

Having this unpopulated breaks the typing doesn't it? At the very least I think it'd cause problems downstream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, safer to do as you mentioned.

FWIW, the Document constructor handles it currently. I'm happy to defer but would probably suggest the Document class should be responsible for determining what the default is.

this.pageContent =
fields.pageContent !== undefined ? fields.pageContent.toString() : "";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right - but it's still required in the input so I'm surprised it passes typechecking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I see that now...I agree, I would have anticipated the typecheck to fail...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's subtly being typed as any in the client

@jacoblee93 jacoblee93 changed the title fix(community): fix PineconeStore to support null or undefined pageContent fix(pinecone): fix PineconeStore to support null or undefined pageContent Oct 3, 2024
@jacoblee93 jacoblee93 merged commit 5a4b926 into langchain-ai:main Oct 3, 2024
27 checks passed
@jacoblee93
Copy link
Collaborator

Thank you!

@langchain-ai langchain-ai locked as spam and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto:improvement Medium size change to existing code to handle new use-cases size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PineconeStore: NullCannot read properties of undefined (reading 'toString')
2 participants