-
-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Description
Hello, everyone!
I kindly ask for your help with a task, please.
I need to filter documents in storage based on multiple metadata fields. To achieve this, I'm using the Retrieval Tool
, where keys and values for filtering can be defined. The values in this tool can be dynamically passed using the $flow
variable.
However, I’ve encountered an issue: it seems that the Retrieval Tool
only allows defining a single field for filtering. When I try to add a second field, an error occurs.
I also considered configuring multiple filter fields in Chroma
metadata, but in Chroma
, it’s not possible to dynamically set values using the $flow
variable.
Could you please advise me on what to do in this situation? How can I resolve this issue?
While dynamic values can be assigned in the retriever tool, it seems that defining such a nested JSON structure is not supported, resulting in the following error:
value.startsWith is not a function
TypeError: value.startsWith is not a function
at DynamicStructuredTool.func (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/tools/RetrieverTool/RetrieverTool.js:142:31)
at DynamicStructuredTool._call (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/tools/RetrieverTool/RetrieverTool.js:68:21)
at DynamicStructuredTool.call (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/tools/RetrieverTool/RetrieverTool.js:44:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/src/agents.js:320:39
at async Promise.all (index 0)
at async AgentExecutor._call (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/src/agents.js:307:30)
at async AgentExecutor.invoke (/usr/local/lib/node_modules/flowise/node_modules/langchain/dist/chains/base.cjs:58:28)
at async agentNode (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/sequentialagents/Agent/Agent.js:609:22)
at async RunnableLambda.workerNode [as func] (/usr/local/lib/node_modules/flowise/node_modules/flowise-components/dist/nodes/sequentialagents/Agent/Agent.js:412:20)
at async /usr/local/lib/node_modules/flowise/node_modules/@langchain/langgraph/node_modules/@langchain/core/dist/runnables/base.cjs:1531:34
I’ve attached screenshots for your reference.
I believe the issue with the Retriever tool is located here:
[Link to code segment](
Flowise/packages/components/nodes/tools/RetrieverTool/RetrieverTool.ts
Lines 205 to 207 in ddca80d
if (value.startsWith('$flow')) { | |
value = customGet(flowObj, value) | |
} |
At that point in the code, the tool expects a simple object formatted like this:
{
"key": "value",
"key2": "value2"
}
However, according to the Chroma documentation (https://docs.trychroma.com/guides#filtering-by-metadata), the filtering conditions must be specified using an AND-based query structure with operators, for example:
{
"$and": [
{
"metadata_field": {
"<Operator>": "<Value>"
}
},
{
"metadata_field": {
"<Operator>": "<Value>"
}
}
]
}
This discrepancy may be causing the issue. Instead of a simple key-value object, Chroma expects a more complex, operator-based query format for filtering metadata fields.