feat: Add search filter support in knowledge base and vector store implementations #855
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Add search filter support in knowledge base and vector store implementations
AgentScope Version
[1.0.6dev]
Description
This commit adds search filter support to the knowledge base and vector store implementations in AgentScope. Previously, users could only perform basic similarity searches in vector databases without the ability to filter results based on metadata or other criteria. This limitation made it difficult to retrieve documents with specific characteristics or restrict searches to particular subsets of data.
Changes Made
1. ReAct Agent Integration
knowledge_filterparameter to theReActAgentconstructorretrievemethod2. Knowledge Base Interface Updates
KnowledgeBase.retrievemethod to accept asearch_filterparameterSimpleKnowledgeimplementation to pass filters through to the vector store3. Vector Store Filter Support
_format_filtersmethod that converts dictionary filters to Qdrant'smodels.Filterformat_build_exprmethod that converts filters to Milvus expression stringsfilterparameter in theirsearchmethods4. Document Metadata Enhancement
DocMetadataclass to accept additional keyword arguments for custom metadata fields@dataclassto custom__init__method for better flexibilityHow to Test
1. Basic Filter Usage
2. Vector Store Direct Testing
3. Document Metadata Testing
Checklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand