-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
PineconeStore: NullCannot read properties of undefined (reading 'toString') #6919
Comments
Hey there, @sam-trost! I'm here to help you with any bugs, questions, or contributions. Let's work on solving the issue together. I found a similar discussion regarding the "TypeError: Cannot read properties of undefined (reading 'toString')" error in the PineconeStore when handling null To resolve this, you can modify the code in the private _formatMatches(
matches: ScoredPineconeRecord<RecordMetadata>[] = []
): [Document, number][] {
const documentsWithScores: [Document, number][] = [];
for (const record of matches) {
const {
id,
score,
metadata: { [this.textKey]: pageContent, ...metadata } = {
[this.textKey]: "",
},
} = record;
if (score) {
documentsWithScores.push([
new Document({
id,
pageContent: pageContent ? pageContent.toString() : "", // Provide a default empty string if pageContent is null
metadata,
}),
score,
]);
}
}
return documentsWithScores;
} This modification ensures that if |
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
TypeError: Cannot read properties of undefined (reading 'toString')
Description
The current version of the pinecone vector store assumes a property named pageContent will be set on each record. This was not previously required when ingesting content.
System Info
└─ langchain@workspace:langchain
├─ Instances: 1
├─ Version: 0.3.2
│
└─ Dependencies
├─ @faker-js/faker@npm:^7.6.0 → npm:7.6.0
├─ @jest/globals@npm:^29.5.0 → npm:29.5.0
├─ @langchain/core@workspace:* → workspace:langchain-core
├─ @langchain/scripts@>=0.1.0 <0.2.0 → workspace:libs/langchain-scripts
├─ @tsconfig/recommended@npm:^1.0.2 → npm:1.0.2
├─ @types/handlebars@npm:^4.1.0 → npm:4.1.0
├─ @types/html-to-text@npm:^9 → npm:9.0.0
├─ @types/js-yaml@npm:^4 → npm:4.0.5
├─ @types/jsdom@npm:^21.1.1 → npm:21.1.1
├─ @types/uuid@npm:^9 → npm:9.0.1
├─ @types/ws@npm:^8 → npm:8.5.8
├─ axios@npm:^0.26.0 → npm:0.26.1
├─ cheerio@npm:1.0.0-rc.12 → npm:1.0.0-rc.12
├─ dotenv@npm:^16.0.3 → npm:16.0.3
├─ dpdm@patch:dpdm@npm%3A3.12.0#./.yarn/patches/dpdm-npm-3.12.0-0dfdd8e3b8.patch::locator=langchainjs%40workspace%3A. → patch:dpdm@npm%3A3.12.0#./.yarn/patches/dpdm-npm-3.12.0-0dfdd8e3b8.patch::version=3.12.0&hash=2406a8&locator=langchainjs%40workspace%3A.
├─ eslint-plugin-no-instanceof@npm:^1.0.1 → npm:1.0.1
├─ eslint@npm:^8.33.0 → npm:8.35.0
├─ handlebars@npm:^4.7.8 → npm:4.7.8
├─ jest-environment-node@npm:^29.6.4 → npm:29.6.4
├─ js-tiktoken@npm:^1.0.12 → npm:1.0.12
├─ js-yaml@npm:^4.1.0 → npm:4.1.0
├─ jsonpointer@npm:^5.0.1 → npm:5.0.1
├─ openai@npm:^4.41.1 → npm:4.42.0
├─ openapi-types@npm:^12.1.3 → npm:12.1.3
├─ p-retry@npm:4 → npm:4.6.2
├─ peggy@npm:^3.0.2 → npm:3.0.2
├─ prettier@npm:^2.8.3 → npm:2.8.4
├─ release-it@npm:^17.6.0 → npm:17.6.0
├─ rimraf@npm:^5.0.1 → npm:5.0.1
├─ rollup@npm:^3.19.1 → npm:3.19.1
├─ typescript@patch:typescript@~5.1.6#~builtin<compat/typescript> → patch:typescript@npm%3A5.1.6#~builtin<compat/typescript>::version=5.1.6&hash=77c9e2
├─ uuid@npm:^10.0.0 → npm:10.0.0
├─ wikipedia@npm:^2.1.2 → npm:2.1.2
├─ yaml@npm:^2.2.1 → npm:2.2.1
├─ zod@npm:3.23.8 → npm:3.23.8
├─ @langchain/anthropic@workspace:* → workspace:libs/langchain-anthropic [773c0]
├─ @langchain/aws@workspace:* → workspace:libs/langchain-aws [773c0]
├─ @langchain/cohere@workspace:* → workspace:libs/langchain-cohere [773c0]
├─ @langchain/google-genai@workspace:* → workspace:libs/langchain-google-genai [773c0]
├─ @langchain/google-vertexai@workspace:* → workspace:libs/langchain-google-vertexai [773c0]
├─ @langchain/groq@workspace:* → workspace:libs/langchain-groq [773c0]
├─ @langchain/mistralai@workspace:* → workspace:libs/langchain-mistralai [773c0]
├─ @langchain/ollama@workspace:* → workspace:libs/langchain-ollama [773c0]
├─ @langchain/openai@workspace:* → workspace:libs/langchain-openai [773c0]
├─ @langchain/textsplitters@workspace:* → workspace:libs/langchain-textsplitters [773c0]
├─ @swc/core@npm:^1.3.90 → npm:1.3.90 [6dbfd]
├─ @swc/jest@npm:^0.2.29 → npm:0.2.29 [6dbfd]
├─ @typescript-eslint/eslint-plugin@npm:^5.58.0 → npm:5.58.0 [6d556]
├─ @typescript-eslint/parser@npm:^5.58.0 → npm:5.58.0 [6d556]
├─ eslint-config-airbnb-base@npm:^15.0.0 → npm:15.0.0 [6d556]
├─ eslint-config-prettier@npm:^8.6.0 → npm:8.7.0 [6dbfd]
├─ eslint-plugin-import@npm:^2.27.5 → npm:2.27.5 [6d556]
├─ eslint-plugin-jest@npm:^27.6.0 → npm:27.6.0 [6d556]
├─ eslint-plugin-prettier@npm:^4.2.1 → npm:4.2.1 [6dbfd]
├─ jest@npm:^29.5.0 → npm:29.7.0 [6dbfd]
├─ langsmith@npm:^0.1.56 → npm:0.1.56 [0b9fc]
├─ ts-jest@npm:^29.1.0 → npm:29.1.0 [221f6]
├─ typeorm@npm:^0.3.20 → npm:0.3.20 [3a972]
└─ zod-to-json-schema@npm:^3.22.3 → npm:3.22.3 [221f6]
The text was updated successfully, but these errors were encountered: