Upload level exam without hooking up to firestore and running in thread, will do this when I have the edit view done

This commit is contained in:
Carlos Mesquita
2024-08-17 09:29:58 +01:00
parent beccf8b501
commit 03f5b7d72c
19 changed files with 742 additions and 9 deletions

20
app.py
View File

@@ -18,7 +18,10 @@ from helper.openai_interface import *
from helper.question_templates import *
from helper.speech_to_text_helper import *
from heygen.AvatarEnum import AvatarEnum
from training_content import TrainingContentService, TrainingContentKnowledgeBase, GPT
from modules import GPT
from modules.training_content import TrainingContentService, TrainingContentKnowledgeBase
from modules.upload_level import UploadLevelService
load_dotenv()
@@ -43,6 +46,8 @@ open_ai = GPT(OpenAI())
firestore_client = firestore.client()
tc_service = TrainingContentService(kb, open_ai, firestore_client)
upload_level_service = UploadLevelService(open_ai)
thread_event = threading.Event()
# Configure logging
@@ -1721,5 +1726,18 @@ def training_content():
return str(e)
# TODO: create a doc in firestore with a status and get its id, run this in a thread and modify the doc in firestore,
# return the id right away, in generation view poll for the id
@app.route('/upload_level', methods=['POST'])
def upload_file():
if 'file' not in request.files:
return 'File wasn\'t uploaded', 400
file = request.files['file']
if file.filename == '':
return 'No selected file', 400
if file:
return upload_level_service.generate_level_from_file(file), 200
if __name__ == '__main__':
app.run()