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:
20
app.py
20
app.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user