ENCOA-295
This commit is contained in:
@@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, Path, Query, UploadFile
|
||||
from ielts_be.middlewares import Authorized, IsAuthenticatedViaBearerToken
|
||||
from ielts_be.controllers import IListeningController
|
||||
from ielts_be.configs.constants import EducationalContent
|
||||
from ielts_be.dtos.listening import GenerateListeningExercises, Dialog
|
||||
from ielts_be.dtos.listening import ListeningExercisesDTO, Dialog, InstructionsDTO
|
||||
|
||||
controller = "listening_controller"
|
||||
listening_router = APIRouter()
|
||||
@@ -64,6 +64,17 @@ async def transcribe_dialog(
|
||||
return await listening_controller.transcribe_dialog(audio)
|
||||
|
||||
|
||||
@listening_router.post(
|
||||
'/instructions',
|
||||
dependencies=[Depends(Authorized([IsAuthenticatedViaBearerToken]))]
|
||||
)
|
||||
@inject
|
||||
async def create_instructions(
|
||||
dto: InstructionsDTO,
|
||||
listening_controller: IListeningController = Depends(Provide[controller])
|
||||
):
|
||||
return await listening_controller.create_instructions(dto.text)
|
||||
|
||||
|
||||
@listening_router.post(
|
||||
'/',
|
||||
@@ -71,7 +82,7 @@ async def transcribe_dialog(
|
||||
)
|
||||
@inject
|
||||
async def generate_listening_exercise(
|
||||
dto: GenerateListeningExercises,
|
||||
dto: ListeningExercisesDTO,
|
||||
listening_controller: IListeningController = Depends(Provide[controller])
|
||||
):
|
||||
return await listening_controller.get_listening_question(dto)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import random
|
||||
from typing import Optional
|
||||
from typing import Optional, List
|
||||
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
from fastapi import APIRouter, Path, Query, Depends
|
||||
@@ -59,7 +59,7 @@ async def get_speaking_task(
|
||||
topic: Optional[str] = Query(None),
|
||||
first_topic: Optional[str] = Query(None),
|
||||
second_topic: Optional[str] = Query(None),
|
||||
difficulty: str = Query(default=random.choice(EducationalContent.DIFFICULTIES)),
|
||||
difficulty: Optional[str] = None,
|
||||
speaking_controller: ISpeakingController = Depends(Provide[controller])
|
||||
):
|
||||
if not second_topic:
|
||||
@@ -67,5 +67,8 @@ async def get_speaking_task(
|
||||
else:
|
||||
topic_or_first_topic = first_topic if first_topic else random.choice(EducationalContent.MTI_TOPICS)
|
||||
|
||||
if not difficulty:
|
||||
difficulty = random.choice(random.choice(EducationalContent.DIFFICULTIES))
|
||||
|
||||
second_topic = second_topic if second_topic else random.choice(EducationalContent.MTI_TOPICS)
|
||||
return await speaking_controller.get_speaking_part(task, topic_or_first_topic, second_topic, difficulty)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import random
|
||||
from typing import Optional, List
|
||||
|
||||
from dependency_injector.wiring import inject, Provide
|
||||
from fastapi import APIRouter, Path, Query, Depends, UploadFile, File
|
||||
@@ -19,7 +20,7 @@ writing_router = APIRouter()
|
||||
async def generate_writing_academic(
|
||||
task: int = Path(..., ge=1, le=2),
|
||||
file: UploadFile = File(...),
|
||||
difficulty: str = Query(default=None),
|
||||
difficulty: Optional[List[str]] = None,
|
||||
writing_controller: IWritingController = Depends(Provide[controller])
|
||||
):
|
||||
difficulty = random.choice(EducationalContent.DIFFICULTIES) if not difficulty else difficulty
|
||||
@@ -33,7 +34,7 @@ async def generate_writing_academic(
|
||||
@inject
|
||||
async def generate_writing(
|
||||
task: int = Path(..., ge=1, le=2),
|
||||
difficulty: str = Query(default=None),
|
||||
difficulty: Optional[str] = None,
|
||||
topic: str = Query(default=None),
|
||||
writing_controller: IWritingController = Depends(Provide[controller])
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user