TiberiuCristianLeon commited on
Commit
4c7bc2b
·
verified ·
1 Parent(s): 5a4d394

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -53,6 +53,25 @@ def translate(text: str, model: Optional[str] = MODELS['enro']):
53
  translation: str = Translate.gemma_direct(text, model)
54
  return {"input": text, "result": translation, "model": model}
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  # Create an MCP server based on this app
57
  mcp = FastApiMCP(
58
  app,
 
53
  translation: str = Translate.gemma_direct(text, model)
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(
77
  app,