Skip to content

API Routers

audio_router

This module defines the audio_router of the Mirumoji API.

Attributes:

Name Type Description
LOGGER Logger

Module's Logging object.

audio_router APIRouter

The FastAPI Router Object.

transcribe_from_audio(file=Depends(get_stream_file), clean_audio_str=Header('false', alias='X-Clean-Audio'), gpt_explain_str=Header('false', alias='X-Gpt-Explain'), profile_id=Header(..., alias='X-Profile-ID')) async

POST endpoint for transcribing an audio file using faster whisper.

Parameters:

Name Type Description Default
file Path

Path where streamed file was saved

Depends(get_stream_file)
clean_audio_str str

Whether to filter the audio or not.

Header('false', alias='X-Clean-Audio')
gpt_explain_str str

Whether to call OpenAI API for explanation.

Header('false', alias='X-Gpt-Explain')
profile_id str

Profile ID from Header.

Header(..., alias='X-Profile-ID')

Returns:

Name Type Description
dict dict

Response with keys transcript and gpt_explanation

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error transcribing audio.

dict_router

This module defines the dict_router of the Mirumoji API.

Attributes:

Name Type Description
LOGGER Logger

Router Logging Object.

dict_router APIRouter

The FastAPI Router object.

explain_sentence(sentence=Query(...)) async

Endpoint returning enriched tokens without gpt explanation.

Parameters:

Name Type Description Default
sentence str

Sentence to return tokens from.

Query(...)

Returns:

Name Type Description
dict dict

Dictionary containg 'sentence' and 'tokens' fields.

Raises:

Type Description
HTTPException

If lookup fails.

query_word(word=Query(...)) async

Endpoint returning dictionary information for a single word

Parameters:

Name Type Description Default
word str

Sentence to return tokens from.

Query(...)

Returns:

Name Type Description
DictLookup DictLookup

Pydantic Model containing word information

Raises:

Type Description
HTTPException

If lookup fails.

wildcard_query(pattern=Query(...)) async

Endpoint returning dictionary information for a wildcard pattern lookup

Parameters:

Name Type Description Default
pattern str

Sentence to return tokens from.

Query(...)

Returns:

Name Type Description
DictWildcardLookup DictWildcardLookup

Pydantic Model containing wildcard pattern lookup information

Raises:

Type Description
HTTPException

If lookup fails.

gpt_router

This module defines the gpt_router of the Mirumoji API.

Attributes:

Name Type Description
LOGGER Logger

Module's Logging object.

gpt_router APIRouter

The FastAPI Router Object.

breakdown(req, profile_id=Depends(get_profile_id_optional)) async

POST endpoint for analysing a Japanese sentence.

Parameters:

Name Type Description Default
req BreakdownRequest

JSON request matching BreakdownRequest model.

required
profile_id (str, optinoal)

Profile ID Header.

Depends(get_profile_id_optional)

Returns:

Name Type Description
dict BreakdownResponse

Dictionary containing fields of BreakdownResonse model.

Raises:

Type Description
HTTPException

Status code 500 if breakdown fails.

chat_stream(req) async

POST endpoint for streaming an OpenAI API call response.

Parameters:

Name Type Description Default
req ChatRequest

JSON request containing fields of ChatRequest model.

required

Returns:

Name Type Description
StreamingResponse StreamingResponse

Stream of the model's response

Raises:

Type Description
HTTPException

Status code 500 if call fails.

custom_breakdown(req, profile_id=Depends(get_profile_id_optional)) async

POST endpoint for analysing a Japanese sentence with custom system message and prompt.

Parameters:

Name Type Description Default
req CustomBreakdownRequest

JSON request matching CustomBreakdownRequest model.

required
profile_id (str, optinoal)

Profile ID Header.

Depends(get_profile_id_optional)

Returns:

Name Type Description
dict BreakdownResponse

Dictionary containing fields of BreakdownResonse model.

Raises:

Type Description
HTTPException

Status code 500 if breakdown fails.

explain_sentence(sentence=Query(...)) async

GET endpoint for analysing a Japanese sentence without a focus word.

Parameters:

Name Type Description Default
sentence str

Sentence to breakdown

Query(...)

Returns:

Name Type Description
dict Dict

Dictionary containing fields 'sentence' and 'explanation'

Raises:

Type Description
HTTPException

Status code 500 if breakdown fails.

health_router

This module defines the health_router of the Mirumoji API.

Attributes:

Name Type Description
health_router APIRouter

The FastAPI Router Object.

gpu_check() async

Endpoint for checking information about the system running the API

Returns:

Name Type Description
dict dict

Information about the system running the API.

health_check() async

Endpoint for checking if API is running.

Returns:

Name Type Description
dict dict

Up status confirmation.

profile_router

This module defines the profile_router of the Mirumoji API.

Attributes:

Name Type Description
LOGGER Logger

Module's Logging object.

profile_router APIRouter

The FastAPI Router Object.

delete_gpt_template(profile_id=Depends(ensure_profile_exists)) async

DELETE endpoint for deleting the active profile's GPT Template.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
dict dict

Conirmation response with keys success and message.

Raises:

Type Description
HTTPException

If no profile ID was provided or no template was found.

delete_profile_file(fileId=FastAPIPath(...), profile_id=Depends(ensure_profile_exists)) async

DELETE endpoint for deleting a specific saved file for a profile.

Parameters:

Name Type Description Default
fileId str

ID of the file to be deleted.

Path(...)
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
dict dict

Confirmation response with keys success and message.

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error deleting the file

delete_profile_transcript(transcriptId=FastAPIPath(...), profile_id=Depends(ensure_profile_exists)) async

DELETE endpoint for deleting a specific transcript for a profile.

Parameters:

Name Type Description Default
transcriptId str

ID of the transcript to delete.

Path(...)
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
dict dict

Confirmation response with keys success and message.

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error deleting the transcript.

delete_saved_clip(clipId=FastAPIPath(...), profile_id=Depends(ensure_profile_exists)) async

DELETE endpoint for deleting a profile's specific saved clip.

Parameters:

Name Type Description Default
clipId str

The ID of the clip to delete.

Path(...)
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
dict dict

Confirmation response with keys success and message

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error deleting the clip.

export_anki_deck(profile_id=Depends(ensure_profile_exists)) async

GET endpoint for exporting profile's saved clips as an Anki Deck.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
AnkiExportResponse AnkiExportResponse

AnkiExportResponse model.

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error generating the Anki deck.

get_gpt_template(profile_id=Depends(ensure_profile_exists)) async

GET endpoint for retrieving the active profile's GPT Template.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Name Type Description
GptTemplateResponse GptTemplateResponse

GptTemplateResponse model with fetched info.

Raises:

Type Description
HTTPException

If no profile ID was provided or no record was found.

get_profile_files(profile_id=Depends(ensure_profile_exists)) async

GET endpoint for getting a profile's saved files.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Type Description
List[ProfileFileResponse]

List[ProfileFileResponse]: List of ProfileFileResponse models

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error getting files.

get_profile_transcripts(profile_id=Depends(ensure_profile_exists)) async

GET endpoint for retrieving profile transcripts.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Type Description
List[ProfileTranscriptResponse]

List[ProfileTranscriptResponse]: List of ProfileTranscriptResponse models.

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error retrieving transcripts

get_saved_clips(profile_id=Depends(ensure_profile_exists)) async

GET endpoint for getting a profile's saved clips.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)

Returns:

Type Description
List[ClipResponse]

List[ClipResponse]: List of ClipResponse models

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error getting saved clips.

save_video_clip(video_clip=Depends(get_stream_file), profile_id=Header(..., alias='X-Profile-ID'), clip_start_time=Header(...), clip_end_time=Header(...), gpt_breakdown_response=Header(...), original_video_file_name=Header(None), original_video_url=Header(None)) async

POST endpoint for saving a new clip for the active profile

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Header(..., alias='X-Profile-ID')
clip_start_time str

Original video clip start time.

Header(...)
clip_end_time str

Original video clip end time.

Header(...)
gpt_breakdown_response str

JSON string of BreakdownResponse model.

Header(...)
video_clip Path

Clip file sent through endpoint.

Depends(get_stream_file)
original_video_file_name str

Original video's name

Header(None)
original_video_url str

URL where FastAPI is serving the original video's static file.

Header(None)

Returns:

Name Type Description
dict dict

Conirmation response with keys success and message and c_id

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error saving the clip.

upsert_gpt_template(template_data, profile_id=Depends(ensure_profile_exists)) async

POST endpoint for creating or updating the active profile's GPT Template.

Parameters:

Name Type Description Default
profile_id str

Profile ID from Header.

Depends(ensure_profile_exists)
template_data GptTemplateBase

Data to insert into template.

required

Returns:

Name Type Description
GptTemplateResponse GptTemplateResponse

GptTemplateResponse model with fetched info.

Raises:

Type Description
HTTPException

If no profile ID was provided.

video_router

This module defines the video_router of the Mirumoji API.

Attributes:

Name Type Description
LOGGER Logger

Module's Logging object.

video_router APIRouter

The FastAPI Router Object.

convert_to_mp4(video_file=Depends(get_stream_file), profile_id=Header(..., alias='X-Profile-ID')) async

POST endpoint for converting a video file to MP4 format.

Parameters:

Name Type Description Default
video_file Path

Path where the streamed file was saved

Depends(get_stream_file)
profile_id str

Profile ID from Header.

Header(..., alias='X-Profile-ID')

Returns:

Name Type Description
dict dict

Response with key converted_video_url

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error converting the video

generate_srt(video_file=Depends(get_stream_file), profile_id=Header(..., alias='X-Profile-ID')) async

POST endpoint for generating an SRT string from a video file.

Parameters:

Name Type Description Default
video_file Path

Path of where the streamed file was saved

Depends(get_stream_file)
profile_id str

Profile ID from Header.

Header(..., alias='X-Profile-ID')

Returns:

Name Type Description
dict dict

Response with key srt_content

Raises:

Type Description
HTTPException

If no profile ID was provided or there was an error generating the SRT