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

community[patch]: Better errors for neo4j vector #5501

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/langchain-community/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
"no-else-return": 0,
"func-names": 0,
"no-lonely-if": 0,
"prefer-template": 0,
"prefer-rest-params": 0,
"new-cap": ["error", { properties: false, capIsNew: false }],
"arrow-body-style": 0,
Expand Down
18 changes: 17 additions & 1 deletion libs/langchain-community/src/vectorstores/neo4j_vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,22 @@ export class Neo4jVectorStore extends VectorStore {
const results = await this.query(readQuery, parameters);

if (results) {
if (results.some((result) => result.text == null)) {
if (!this.retrievalQuery) {
throw new Error(
"Make sure that none of the '" +
this.textNodeProperty +
"' properties on nodes with label '" +
this.nodeLabel +
"' are missing or empty"
);
} else {
throw new Error(
"Inspect the 'retrievalQuery' and ensure it doesn't return null for the 'text' column"
);
}
}

const docs: [Document, number][] = results.map((result: Any) => [
new Document({
pageContent: result.text,
Expand Down Expand Up @@ -1026,7 +1042,7 @@ function handleFieldFilter(
return [querySnippet, queryParam];
} else if (["$in", "$nin", "$like", "$ilike"].includes(operator)) {
if (["$in", "$nin"].includes(operator)) {
filterValue.forEach((val: any) => {
filterValue.forEach((val: Any) => {
if (
typeof val !== "string" &&
typeof val !== "number" &&
Expand Down
Loading