Skip to content

Commit ea38e15

Browse files
community[patch]: Better errors for neo4j vector (#5501)
* Better errors for neo4j vector * Lint --------- Co-authored-by: jacoblee93 <[email protected]>
1 parent 2494ed7 commit ea38e15

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

libs/langchain-community/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = {
6060
"no-else-return": 0,
6161
"func-names": 0,
6262
"no-lonely-if": 0,
63+
"prefer-template": 0,
6364
"prefer-rest-params": 0,
6465
"new-cap": ["error", { properties: false, capIsNew: false }],
6566
"arrow-body-style": 0,

libs/langchain-community/src/vectorstores/neo4j_vector.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,22 @@ export class Neo4jVectorStore extends VectorStore {
720720
const results = await this.query(readQuery, parameters);
721721

722722
if (results) {
723+
if (results.some((result) => result.text == null)) {
724+
if (!this.retrievalQuery) {
725+
throw new Error(
726+
"Make sure that none of the '" +
727+
this.textNodeProperty +
728+
"' properties on nodes with label '" +
729+
this.nodeLabel +
730+
"' are missing or empty"
731+
);
732+
} else {
733+
throw new Error(
734+
"Inspect the 'retrievalQuery' and ensure it doesn't return null for the 'text' column"
735+
);
736+
}
737+
}
738+
723739
const docs: [Document, number][] = results.map((result: Any) => [
724740
new Document({
725741
pageContent: result.text,
@@ -1026,7 +1042,7 @@ function handleFieldFilter(
10261042
return [querySnippet, queryParam];
10271043
} else if (["$in", "$nin", "$like", "$ilike"].includes(operator)) {
10281044
if (["$in", "$nin"].includes(operator)) {
1029-
filterValue.forEach((val: any) => {
1045+
filterValue.forEach((val: Any) => {
10301046
if (
10311047
typeof val !== "string" &&
10321048
typeof val !== "number" &&

0 commit comments

Comments
 (0)