Skip to content

Commit

Permalink
Hotfix: Language code for audio request.
Browse files Browse the repository at this point in the history
  • Loading branch information
conor-f committed Oct 14, 2023
1 parent 7ccc23e commit 6b4e617
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fia_api/web/api/teacher/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, UploadFile
from fastapi.responses import StreamingResponse

from fia_api.db.models.user_model import UserModel
from fia_api.web.api.teacher.schema import (
ConverseResponse,
ConverseWithAudioRequest,
GetAudioRequest,
TeacherConverseRequest,
)
Expand Down Expand Up @@ -47,30 +46,31 @@ async def converse(

@router.post("/converse-with-audio", response_model=ConverseResponse)
async def converse_with_audio(
converse_with_audio_request: ConverseWithAudioRequest,
conversation_id: str,
language_code: str,
audio_file: UploadFile,
user: AuthenticatedUser = Depends(get_current_user),
) -> ConverseResponse:
"""
Starts or continues a conversation with the Teacher with audio.
:param converse_with_audio_request: The request object.
:param conversation_id: The conversation ID.
:param language_code: The language of the uploaded audio.
:param audio_file: The actual audio file.
:param user: The AuthenticatedUser making the request.
:returns: ConverseResponse of mistakes and conversation.
"""
# TODO: Should be the same endpoint as above.
message = await get_text_from_audio(
converse_with_audio_request.audio_file,
converse_with_audio_request.language_code,
)
message = await get_text_from_audio(audio_file, language_code)

if converse_with_audio_request.conversation_id == "new":
if conversation_id == "new":
return await initialize_conversation(
await UserModel.get(username=user.username),
message,
)

return await get_response(
converse_with_audio_request.conversation_id,
conversation_id,
message,
await UserModel.get(username=user.username),
)
Expand Down

0 comments on commit 6b4e617

Please sign in to comment.