TiberiuCristianLeon commited on
Commit
564da3b
·
verified ·
1 Parent(s): eaf1d7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from fastapi import FastAPI, Request, Query
2
  import src.Paraphrase as Paraphrase
3
- import src.Translation as Translation
4
- import src.Translate as Cltranslate
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
- # text: str, 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 = Translation.paraphraseTranslateMethod(text, model_name)
68
  elif 'Helsinki-NLP' in model_name:
69
- translation = Cltranslate.HelsinkiNLP_mulroa(model_name, sl, tl, input_text)
70
  else:
71
- translation: str = Translate.gemma_direct(text, model)
72
- return {"input": text, "result": translation, "model": 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()