Spaces:
Running
Running
| from fastapi import FastAPI | |
| import src.paraphrase.Paraphrase as Paraphrase | |
| import src.translate.Translate as Translate | |
| import nltk | |
| nltk.download('punkt') | |
| nltk.download('punkt_tab') | |
| app = FastAPI(docs_url="/") | |
| MTMODELS = {'enro': 'BlackKakapo/opus-mt-en-ro', 'roen': 'BlackKakapo/opus-mt-ro-en'} | |
| def index(): | |
| return {'endpoints': ['/paraphrase', '/translate'], 'mtmodels': MTMODELS} | |
| def paraphrase(text: str, model: str): | |
| resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model) | |
| return {"input": text, "translation": resultValue, "exception": exception} | |
| 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} |