Update app.py
Browse files
app.py
CHANGED
@@ -53,9 +53,11 @@ hf_embeddings = HuggingFaceEndpointEmbeddings(
|
|
53 |
huggingfacehub_api_token=HF_TOKEN,
|
54 |
)
|
55 |
|
|
|
56 |
async def add_documents_async(vectorstore, documents):
|
57 |
await vectorstore.aadd_documents(documents)
|
58 |
|
|
|
59 |
async def process_batch(vectorstore, batch, is_first_batch, pbar):
|
60 |
if is_first_batch:
|
61 |
result = await FAISS.afrom_documents(batch, hf_embeddings)
|
@@ -65,6 +67,7 @@ async def process_batch(vectorstore, batch, is_first_batch, pbar):
|
|
65 |
pbar.update(len(batch))
|
66 |
return result
|
67 |
|
|
|
68 |
async def main():
|
69 |
print("Indexing Files")
|
70 |
|
|
|
53 |
huggingfacehub_api_token=HF_TOKEN,
|
54 |
)
|
55 |
|
56 |
+
# Add chunks to vectorstore in the background
|
57 |
async def add_documents_async(vectorstore, documents):
|
58 |
await vectorstore.aadd_documents(documents)
|
59 |
|
60 |
+
# Segregates first batch and subsequent batch of documents for efficiency
|
61 |
async def process_batch(vectorstore, batch, is_first_batch, pbar):
|
62 |
if is_first_batch:
|
63 |
result = await FAISS.afrom_documents(batch, hf_embeddings)
|
|
|
67 |
pbar.update(len(batch))
|
68 |
return result
|
69 |
|
70 |
+
# Divides the split documents into batches of 32 for speed and efficiency
|
71 |
async def main():
|
72 |
print("Indexing Files")
|
73 |
|