Upload batches of users onto firebase
This commit is contained in:
@@ -21,7 +21,7 @@ class UploadLevelService:
|
||||
self._llm = openai
|
||||
|
||||
def generate_level_from_file(self, file) -> Dict[str, Any] | None:
|
||||
ext, path_id = self._save_upload(file)
|
||||
ext, path_id = FileHelper.save_upload(file)
|
||||
FileHelper.convert_file_to_pdf(
|
||||
f'./tmp/{path_id}/uploaded.{ext}', f'./tmp/{path_id}/exercises.pdf'
|
||||
)
|
||||
@@ -48,16 +48,6 @@ class UploadLevelService:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _save_upload(file) -> Tuple[str, str]:
|
||||
ext = file.filename.split('.')[-1]
|
||||
path_id = str(uuid.uuid4())
|
||||
os.makedirs(f'./tmp/{path_id}', exist_ok=True)
|
||||
|
||||
tmp_filename = f'./tmp/{path_id}/uploaded.{ext}'
|
||||
file.save(tmp_filename)
|
||||
return ext, path_id
|
||||
|
||||
def _level_json_schema(self):
|
||||
return {
|
||||
"parts": [
|
||||
@@ -392,4 +382,4 @@ class UploadLevelService:
|
||||
exercise["words"][i]["id"] = counter
|
||||
exercise["solutions"][i]["id"] = counter
|
||||
counter += 1
|
||||
return response
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user