mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
* Self-hosted gpu api * Refactor self-hosted api * Rename model api tests * Use lifespan instead of startup event * Fix self hosted imports * Add newlines * Add response models * Move gpu dir to the root * Add project description * Refactor lifespan * Update env var names for model api tests * Preload diarizarion service * Refactor uploaded file paths
29 lines
634 B
Python
29 lines
634 B
Python
from typing import Dict
|
|
|
|
from fastapi import APIRouter, Body, Depends
|
|
from pydantic import BaseModel
|
|
|
|
from ..auth import apikey_auth
|
|
from ..services.translator import TextTranslatorService
|
|
|
|
router = APIRouter(tags=["translation"])
|
|
|
|
translator = TextTranslatorService()
|
|
|
|
|
|
class TranslationResponse(BaseModel):
|
|
text: Dict[str, str]
|
|
|
|
|
|
@router.post(
|
|
"/translate",
|
|
dependencies=[Depends(apikey_auth)],
|
|
response_model=TranslationResponse,
|
|
)
|
|
def translate(
|
|
text: str,
|
|
source_language: str = Body("en"),
|
|
target_language: str = Body("fr"),
|
|
):
|
|
return translator.translate(text, source_language, target_language)
|