Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from fastapi import FastAPI, Request, Query
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
-
import src.
|
| 4 |
-
import src.
|
| 5 |
from typing import Optional
|
| 6 |
from fastapi_mcp import FastApiMCP
|
| 7 |
from huggingface_hub import hf_hub_download, list_repo_files
|
|
@@ -60,16 +60,16 @@ def paraphrase(text: str, model: str = MODELS['paraphrase']):
|
|
| 60 |
def listmodels():
|
| 61 |
return {"MODELS": MODELS, "EMBEDDING_MODELS": EMBEDDING_MODELS}
|
| 62 |
|
| 63 |
-
#
|
| 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 =
|
| 68 |
elif 'Helsinki-NLP' in model_name:
|
| 69 |
-
translation =
|
| 70 |
else:
|
| 71 |
-
translation: str = Translate.gemma_direct(text,
|
| 72 |
-
return {"input": text, "result": translation, "model":
|
| 73 |
|
| 74 |
# Keep track of installed (src, tgt) pairs
|
| 75 |
installed_pairs = set()
|
|
|
|
| 1 |
from fastapi import FastAPI, Request, Query
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
+
import src.Translate as 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
|
|
|
|
| 60 |
def listmodels():
|
| 61 |
return {"MODELS": MODELS, "EMBEDDING_MODELS": EMBEDDING_MODELS}
|
| 62 |
|
| 63 |
+
# model: Optional[str] = MODELS['benro']
|
| 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
|
| 75 |
installed_pairs = set()
|