TiberiuCristianLeon commited on
Commit
a5013c0
·
verified ·
1 Parent(s): 45fb578

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -54,23 +54,23 @@ def translate(text: str, model: Optional[str] = MODELS['enro']):
54
  return {"input": text, "result": translation, "model": model}
55
 
56
  @app.get("/test", operation_id="get_test", description="Test text", tags=["test"], summary="Test text")
57
- def test(text: str, model: Optional[str] = 'bergamot'):
58
- import bergamot
59
- config = bergamot.ServiceConfig(numWorkers=2)
60
- service = bergamot.Service(config)
61
- model = service.modelFromConfigPath("bergamot.config.yaml")
62
- options = bergamot.ResponseOptions(
63
- alignment=False, qualityScores=False, HTML=False
64
- )
65
- response = service.translate(model, bergamot.VectorString([
66
- "Ovechkin’s first assist of the night was on the game-winning goal by rookie Nicklas Backstrom",
67
- "In the last 3 months, over 80 arrestees were released from the Central Booking facility without being formally charged.",
68
- "Since its inception, The Onion has become a veritable news parody empire, with a print edition, a website that drew 5,000,000 unique visitors in the month of October.",
69
- ]), options)
70
-
71
- for r in response:
72
- print(r.target.text)
73
- return {"input": text, "result": response, "model": model}
74
 
75
  # Create an MCP server based on this app
76
  mcp = FastApiMCP(
 
54
  return {"input": text, "result": translation, "model": model}
55
 
56
  @app.get("/test", operation_id="get_test", description="Test text", tags=["test"], summary="Test text")
57
+ def test(text: str, model: Optional[str] = 'bergamot'):
58
+ import bergamot
59
+ config = bergamot.ServiceConfig(numWorkers=2)
60
+ service = bergamot.Service(config)
61
+ model = service.modelFromConfigPath("bergamot.config.yaml")
62
+ options = bergamot.ResponseOptions(
63
+ alignment=False, qualityScores=False, HTML=False
64
+ )
65
+ response = service.translate(model, bergamot.VectorString([
66
+ "Das ist ein deutscher Text",
67
+ "In the last 3 months, over 80 arrestees were released.",
68
+ text,
69
+ ]), options)
70
+
71
+ for r in response:
72
+ print(r.target.text)
73
+ return {"input": text, "result": response, "model": model}
74
 
75
  # Create an MCP server based on this app
76
  mcp = FastApiMCP(