Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI, Request
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
import src.Translate as Translate
|
| 4 |
from typing import Optional
|
|
@@ -56,9 +56,11 @@ def translate(text: str, model: Optional[str] = MODELS['enro']):
|
|
| 56 |
|
| 57 |
@app.get("/bergamot", operation_id="get_bergamot", description="Translate text with Bergamot", tags=["bergamot"], summary="Translate text with Bergamot")
|
| 58 |
# def bergamot(input_text: str, sl: str = 'de', tl: str = 'en', model: Optional[str] = 'bergamot'):
|
| 59 |
-
def bergamot(input_text: Union[str, list[str]], sl: str = 'de', tl: str = 'en', model: Optional[str] = 'bergamot'):
|
| 60 |
try:
|
| 61 |
import bergamot
|
|
|
|
|
|
|
| 62 |
config = bergamot.ServiceConfig(numWorkers=4)
|
| 63 |
service = bergamot.Service(config)
|
| 64 |
models = service.modelFromConfigPath("./deen/bergamot.config.yml")
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request, Query
|
| 2 |
import src.Paraphrase as Paraphrase
|
| 3 |
import src.Translate as Translate
|
| 4 |
from typing import Optional
|
|
|
|
| 56 |
|
| 57 |
@app.get("/bergamot", operation_id="get_bergamot", description="Translate text with Bergamot", tags=["bergamot"], summary="Translate text with Bergamot")
|
| 58 |
# def bergamot(input_text: str, sl: str = 'de', tl: str = 'en', model: Optional[str] = 'bergamot'):
|
| 59 |
+
def bergamot(input_text: Union[str, list[str]] = Query(..., description="One or more input strings"), sl: str = 'de', tl: str = 'en', model: Optional[str] = 'bergamot'):
|
| 60 |
try:
|
| 61 |
import bergamot
|
| 62 |
+
# if isinstance(input_text, str):
|
| 63 |
+
# input_text = [input_text]
|
| 64 |
config = bergamot.ServiceConfig(numWorkers=4)
|
| 65 |
service = bergamot.Service(config)
|
| 66 |
models = service.modelFromConfigPath("./deen/bergamot.config.yml")
|