index multiple files concurrently

This commit is contained in:
ArnoChen
2025-02-16 01:10:43 +08:00
parent 147d73bd56
commit 33a4f00b1d

View File

@@ -1206,13 +1206,18 @@ def create_app(args):
logging.error(f"Error deleting file {file_path}: {str(e)}") logging.error(f"Error deleting file {file_path}: {str(e)}")
async def batch_index_files(file_paths: List[Path]): async def batch_index_files(file_paths: List[Path]):
"""Index multiple files """Index multiple files concurrently
Args: Args:
file_paths: Paths to the files to index file_paths: Paths to the files to index
""" """
for file_path in file_paths: if not file_paths:
await index_file(file_path) return
if len(file_paths) == 1:
await index_file(file_paths[0])
else:
tasks = [index_file(path) for path in file_paths]
await asyncio.gather(*tasks)
async def save_temp_file(file: UploadFile = File(...)) -> Path: async def save_temp_file(file: UploadFile = File(...)) -> Path:
"""Save the uploaded file to a temporary location """Save the uploaded file to a temporary location