In the following code
def load_index():
# index if dir 'storage' does not exist
if not os.path.exists('storage'):
print('Building index...')
build_index()
storage_context = StorageContext.from_defaults(persist_dir='./storage')
# doc_hash_to_filename = json.load(open('doc_hash_to_filename.json', 'r'))
return load_index_from_storage(storage_context)
def ask_question(index, query):
query_engine = index.as_query_engine()
response = query_engine.query(query)
return response
I always get 2 responses right now, for any query. How can I get more? is there a parameter I can change?
Here's an example of how to extract the top k = 5 window and sentences using sentence window retrieval. Your case may also be similar.
Replace i with 0, 1, 2, 3, 4 to get the top 5 results.