diff --git a/api/contextqa/services/context.py b/api/contextqa/services/context.py index c888f26..a042e78 100644 --- a/api/contextqa/services/context.py +++ b/api/contextqa/services/context.py @@ -102,9 +102,10 @@ def load_and_preprocess(self, filename: str, file_: BinaryIO, session: Session) file_writer = NamedTemporaryFile(mode="wb", suffix=f"{settings.tmp_separator}{filename}") path = file_writer.name file_writer.write(source_content) + finally: + file_writer.seek(0) loader: BaseLoader = LOADERS[extension](str(path)) documents = loader.load() - finally: file_writer.close() # we do not want to split csv files as they are splitted by rows