You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched the LangChain.js documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain.js rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
Most of the code are copied from the documentation. The embedding model is changed to jina and the id of Document is changed to Int with autoincrement. The postgres instance is created under the instruction in documentation.
Error: Invalid filter: IN operator requires an array of strings. Received: [
7,
8,
9
]
file:///Users/a/DevProjects/prisma-vector-test/node_modules/.pnpm/@langchain+community@0.2.19_ignore@5.3.1_openai@4.52.7/node_modules/@langchain/community/dist/vectorstores/prisma.js:246
throw new Error(Invalid filter: IN operator requires an array of strings. Received: ${JSON.stringify(value, null, 2)});
Description
I'm trying to use IN operator to filter the result in prisma vector store query. The argument are correctly inferred to number[], but I received a runtime error saying that IN operator requires an array of strings. I cannot change them to string[] as it will led to a type error.
It simply rejects all non-string arrays when building sql query, but the argument of IN can have various types in real cases. After the removal of this line, the problem is solved.
I will open a PR to fix this.
Hey there, @shan-mx! 👋 I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let's squash some bugs together!
The issue you're encountering with the IN operator in the Prisma vector store query is due to the operator requiring an array of strings, but the argument is inferred as number[]. This is because the code currently rejects all non-string arrays when building the SQL query.
To resolve this, you need to convert the number[] to string[] before using it in the IN operator. Here's an example of how you can do this:
constnumberArray=docs.map((doc)=>doc.id);// Example number arrayconststringArray=numberArray.map(String);// Convert number[] to string[]// Now use stringArray with the IN operatorconstresultOne=awaitvectorStore.similaritySearch("Hello world",1,{id: {in: stringArray,},});console.log(resultOne);
By converting the number[] to string[], you ensure that the IN operator receives the correct type of values, thus resolving the runtime error.
Additionally, it seems that the issue stems from a specific line in the prisma.ts file that rejects non-string arrays. You mentioned that removing this line solves the problem, and you plan to open a PR to fix it. This approach should help address the root cause of the issue.
If you need further assistance, @jacoblee93 might be able to provide additional guidance.
Checked other resources
Example Code
Most of the code are copied from the documentation. The embedding model is changed to jina and the id of Document is changed to Int with autoincrement. The postgres instance is created under the instruction in documentation.
Prisma Schema:
Error Message and Stack Trace (if applicable)
Error: Invalid filter: IN operator requires an array of strings. Received: [
7,
8,
9
]
file:///Users/a/DevProjects/prisma-vector-test/node_modules/.pnpm/@langchain+community@0.2.19_ignore@5.3.1_openai@4.52.7/node_modules/@langchain/community/dist/vectorstores/prisma.js:246
throw new Error(
Invalid filter: IN operator requires an array of strings. Received: ${JSON.stringify(value, null, 2)}
);Description
I'm trying to use IN operator to filter the result in prisma vector store query. The argument are correctly inferred to number[], but I received a runtime error saying that IN operator requires an array of strings. I cannot change them to string[] as it will led to a type error.
System Info
@langchain/community@0.2.19 | MIT | deps: 11 | versions: 89
Third-party integrations for LangChain.js
https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-community/
platform mac
Node v20.11.1
The text was updated successfully, but these errors were encountered: