Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, Request, Query
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
-
import src.Translate
|
| 4 |
-
import src.Translators as Translators
|
| 5 |
from typing import Optional
|
| 6 |
from fastapi_mcp import FastApiMCP
|
| 7 |
from huggingface_hub import hf_hub_download, list_repo_files
|
|
@@ -64,11 +63,11 @@ def listmodels():
|
|
| 64 |
@app.get("/translate", operation_id="get_translate", description="Translate text", tags=["translate"], summary="Translate text")
|
| 65 |
def translate(input_text: str, model_name: str = MODELS['mttcbig'], sl: str = 'en', tl: str = 'ro'):
|
| 66 |
if 'BlackKakapo' in model_name:
|
| 67 |
-
translation = Translate.paraphraseTranslateMethod(text, model_name)
|
| 68 |
elif 'Helsinki-NLP' in model_name:
|
| 69 |
-
translation = Translators.HelsinkiNLP_mulroa(model_name, sl, tl, input_text)
|
| 70 |
else:
|
| 71 |
-
translation: str = Translate.gemma_direct(text, model_name)
|
| 72 |
return {"input": text, "result": translation, "model": model_name}
|
| 73 |
|
| 74 |
# Keep track of installed (src, tgt) pairs
|
|
|
|
| 1 |
from fastapi import FastAPI, Request, Query
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
+
import src.Translate
|
|
|
|
| 4 |
from typing import Optional
|
| 5 |
from fastapi_mcp import FastApiMCP
|
| 6 |
from huggingface_hub import hf_hub_download, list_repo_files
|
|
|
|
| 63 |
@app.get("/translate", operation_id="get_translate", description="Translate text", tags=["translate"], summary="Translate text")
|
| 64 |
def translate(input_text: str, model_name: str = MODELS['mttcbig'], sl: str = 'en', tl: str = 'ro'):
|
| 65 |
if 'BlackKakapo' in model_name:
|
| 66 |
+
translation = src.Translate.paraphraseTranslateMethod(text, model_name)
|
| 67 |
elif 'Helsinki-NLP' in model_name:
|
| 68 |
+
translation = src.Translate.Translators.HelsinkiNLP_mulroa(model_name, sl, tl, input_text)
|
| 69 |
else:
|
| 70 |
+
translation: str = src.Translate.gemma_direct(text, model_name)
|
| 71 |
return {"input": text, "result": translation, "model": model_name}
|
| 72 |
|
| 73 |
# Keep track of installed (src, tgt) pairs
|