Spaces:
Sleeping
Sleeping
File size: 841 Bytes
d120873 fd2637b d120873 f38941e d120873 2130cf2 9f45cd5 fd2637b d120873 2130cf2 5936387 fd2637b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from fastapi import FastAPI
import src.paraphrase.Paraphrase as Paraphrase
import src.translate.Translate as Translate
app = FastAPI(docs_url="/")
MTMODELS = {'enro': 'BlackKakapo/opus-mt-en-ro', 'roen': 'BlackKakapo/opus-mt-ro-en'}
@app.get("/")
def index():
return {'endpoints': ['/paraphrase', '/translate'], 'mtmodels': MTMODELS}
@app.get("/paraphrase")
def paraphrase(text: str, model: str):
resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model)
return {"input": text, "translation": resultValue, "exception": exception}
@app.get("/translate")
def translate(text: str, model: str):
# resultValue, exception = Translate.paraphraseTranslateMethod(text, model)
resultValue, exception = Translate.gemma(text, model)
return {"input": text, "translation": resultValue, "exception": exception} |