Sami Bouhussein commited on
Commit
f7ee775
·
1 Parent(s): e255913

healthcheck endpoint

Browse files
Files changed (2) hide show
  1. .DS_Store +0 -0
  2. main.py +9 -0
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
main.py CHANGED
@@ -33,3 +33,12 @@ def translate(req: TranslationRequest):
33
  translated = model.generate(**inputs)
34
  result = tokenizer.decode(translated[0], skip_special_tokens=True)
35
  return {"translation": result}
 
 
 
 
 
 
 
 
 
 
33
  translated = model.generate(**inputs)
34
  result = tokenizer.decode(translated[0], skip_special_tokens=True)
35
  return {"translation": result}
36
+
37
+ @app.get("/healthcheck")
38
+ def healthcheck():
39
+ # Run a dummy translation to warm up the model
40
+ test_text = "Hello"
41
+ inputs = tokenizer([test_text], return_tensors="pt", padding=True, truncation=True)
42
+ translated = model.generate(**inputs)
43
+ result = tokenizer.decode(translated[0], skip_special_tokens=True)
44
+ return {"status": "ok", "test_translation": result}