Yeah you should be able to use Recursive Reader for this. Here is an outline of how you can use Recursive Reader for this:
from llama_index.indices.vector_store.retrievers import RecursiveRetriever, BaseRetriever
from datetime import datetime
# Custom retriever to filter documents by date range
class DateRangeRetriever(BaseRetriever):
def retrieve(self, query, params=None):
# Extract date range from the query
start_date, end_date = extract_date_range(query)
# Query Qdrant with the date range metadata to get document IDs
document_ids = query_qdrant_by_date_range(start_date, end_date)
return document_ids
# Function to extract date range from the query
def extract_date_range(query):
# Implement logic to extract date range from the query
# For example, use regex or natural language processing
return start_date, end_date
# Function to query Qdrant by date range
def query_qdrant_by_date_range(start_date, end_date):
# Implement logic to query Qdrant with the date range
# Return a list of document IDs
return document_ids
# Set up the RecursiveRetriever
date_range_retriever = DateRangeRetriever()
context_retriever = ... # Set up your retriever for querying documents for context
recursive_retriever = RecursiveRetriever(date_range_retriever, context_retriever)
# Integrate with the chat engine
# You will need to modify or extend the chat engine to use the recursive_retriever