Knowledge Filters
Manual filters
Manual Knowledge Filters
Manual filtering gives you full control over which documents are searched by specifying filters directly in your code.
Step 1: Attach Metadata
There are two ways to attach metadata to your documents:
-
Attach Metadata When Initializing the Knowledge Base
-
Attach Metadata When Loading Documents One by One
💡 Tips:
• Use Option 1 if you have all your documents and metadata ready at once.
• Use Option 2 if you want to add documents incrementally or as they become available.
Step 2: Query with Filters
You can pass filters in two ways:
1. On the Agent (applies to all queries)
2. On Each Query (overrides Agent filters for that run)
If you pass filters both on the Agent and on the query, the query-level filters take precedence.
Combining Multiple Filters
You can filter by multiple fields:
Try It Yourself!
- Load documents with different metadata.
- Query with different filter combinations.
- Observe how the results change!