When I use file_batches
to upload multiple files to a vector store, occasionally the file_batches
status shows as ‘completed’, but there are some failed files in file_batches.file_counts
, such as ‘FileCounts(cancelled=0, completed=53, failed=1, in_progress=0, total=54)’. What could be the cause of this, and how can it be resolved?
My code is as follows:
def upload_file(file_paths, client,vector_store_ids):
file_streams = []
try:
for path in file_paths:
file_streams.append(open(path, "rb"))
file_batch = client.beta.vector_stores.file_batches.upload_and_poll(
vector_store_id=vector_store_ids[0], files=file_streams
)
if file_batch.status == "completed":
print(f"success:{file_batch.file_counts}")
return True
print(f"{file_batch.status}:{file_batch.file_counts}")
return False
finally:
for file_stream in file_streams:
file_stream.close()