- Query external APIs or databases directly
- Implement custom ranking or filtering
- Reformulate queries before searching
- Combine multiple data sources
How It Works
When the agent decides to search for information:- The agent calls your
knowledge_retrieverfunction with the query - Your function retrieves documents however you want
- Results are returned to the agent as a list of dictionaries
- The agent uses the retrieved content to generate a response
Retriever Function Signature
Example: Direct Vector Database Query
This example bypasses the Knowledge abstraction and queries Qdrant directly:custom_retriever.py
Example: Query Reformulation
Expand or modify queries before searching:Example: Multi-Source Retrieval
Combine results from multiple knowledge bases:When to Use Custom Retrievers
For most use cases, the built-in Knowledge search is sufficient. Use custom retrievers when you need full control over the retrieval process.
Next Steps
Search & Retrieval
Learn about built-in search options
Filtering
Filter results by metadata