Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,7 +87,7 @@ installed_pairs = set()
|
|
| 87 |
|
| 88 |
# https://tiberiucristianleon-fastapimt.hf.space/bergamot?input_text=das%20ist%20keine%20gute%20Frau&input_text=das%20ist%20eine%20gute%20Nachricht&sl=de&tl=en&model=bergamot
|
| 89 |
@app.get("/bergamot", operation_id="get_bergamot", description="Translate text with Bergamot", tags=["bergamot"], summary="Translate text with Bergamot")
|
| 90 |
-
def bergamot(input_text: str = Query(description="Input strings"), sl: str = 'de', tl: str = 'en', model_name: Optional[str] = 'deen'):
|
| 91 |
"""
|
| 92 |
Translates the input text from the source language to the target language using a specified model.
|
| 93 |
Parameters:
|
|
@@ -127,7 +127,7 @@ def bergamot(input_text: str = Query(description="Input strings"), sl: str = 'de
|
|
| 127 |
if subfolder not in installed_pairs:
|
| 128 |
local_path = hf_hub_download(repo_id=repo_id, subfolder=model_name, filename=file_path, local_dir=subfolder)
|
| 129 |
print(f"Downloaded to: {local_path}") # Downloaded to: deen/base/deen/config.yml
|
| 130 |
-
localfolder = local_path.
|
| 131 |
else:
|
| 132 |
localfolder = f"{subfolder}/{model_name}"
|
| 133 |
installed_pairs.add(subfolder)
|
|
|
|
| 87 |
|
| 88 |
# https://tiberiucristianleon-fastapimt.hf.space/bergamot?input_text=das%20ist%20keine%20gute%20Frau&input_text=das%20ist%20eine%20gute%20Nachricht&sl=de&tl=en&model=bergamot
|
| 89 |
@app.get("/bergamot", operation_id="get_bergamot", description="Translate text with Bergamot", tags=["bergamot"], summary="Translate text with Bergamot")
|
| 90 |
+
def bergamot(input_text: str = Query(description="Input strings"), sl: str = 'de', tl: str = 'en', model_name: Optional[str] = 'base/deen'):
|
| 91 |
"""
|
| 92 |
Translates the input text from the source language to the target language using a specified model.
|
| 93 |
Parameters:
|
|
|
|
| 127 |
if subfolder not in installed_pairs:
|
| 128 |
local_path = hf_hub_download(repo_id=repo_id, subfolder=model_name, filename=file_path, local_dir=subfolder)
|
| 129 |
print(f"Downloaded to: {local_path}") # Downloaded to: deen/base/deen/config.yml
|
| 130 |
+
localfolder = local_path.rsplit('/', 1)[0]
|
| 131 |
else:
|
| 132 |
localfolder = f"{subfolder}/{model_name}"
|
| 133 |
installed_pairs.add(subfolder)
|