Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,18 @@ import nltk
|
|
5 |
nltk.download('punkt')
|
6 |
|
7 |
app = FastAPI(docs_url="/")
|
|
|
8 |
|
9 |
@app.get("/")
|
10 |
def index():
|
11 |
-
return {"
|
12 |
|
13 |
@app.get("/paraphrase")
|
14 |
def paraphrase(text: str, model: str):
|
15 |
resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model)
|
16 |
-
return {"
|
17 |
|
18 |
@app.get("/translate")
|
19 |
def translate(text: str, model: str):
|
20 |
resultValue, exception = Translate.paraphraseTranslateMethod(text, model)
|
21 |
-
return {"
|
|
|
5 |
nltk.download('punkt')
|
6 |
|
7 |
app = FastAPI(docs_url="/")
|
8 |
+
MTMODELS = {'enro': 'BlackKakapo/opus-mt-en-ro', 'roen': 'BlackKakapo/opus-mt-ro-en'}
|
9 |
|
10 |
@app.get("/")
|
11 |
def index():
|
12 |
+
return {"endpoints": ['/paraphrase', '/translate']. 'mtmodels': MTMODELS}
|
13 |
|
14 |
@app.get("/paraphrase")
|
15 |
def paraphrase(text: str, model: str):
|
16 |
resultValue, exception = Paraphrase.paraphraseParaphraseMethod(text, model)
|
17 |
+
return {"input": text, "translation": resultValue, "exception": exception}
|
18 |
|
19 |
@app.get("/translate")
|
20 |
def translate(text: str, model: str):
|
21 |
resultValue, exception = Translate.paraphraseTranslateMethod(text, model)
|
22 |
+
return {"input": text, "translation": resultValue, "exception": exception}
|