Update inference.py
Browse files- inference.py +12 -1
inference.py
CHANGED
|
@@ -61,4 +61,15 @@ def hf_inference_fn(inputs: str):
|
|
| 61 |
embedding_src=embedding_matrix_en,
|
| 62 |
device=device,
|
| 63 |
max_len=max_len
|
| 64 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
embedding_src=embedding_matrix_en,
|
| 62 |
device=device,
|
| 63 |
max_len=max_len
|
| 64 |
+
)
|
| 65 |
+
from fastapi import FastAPI
|
| 66 |
+
from pydantic import BaseModel
|
| 67 |
+
|
| 68 |
+
app = FastAPI()
|
| 69 |
+
|
| 70 |
+
class TranslateRequest(BaseModel):
|
| 71 |
+
text: str
|
| 72 |
+
|
| 73 |
+
@app.post("/translate")
|
| 74 |
+
def translate(req: TranslateRequest):
|
| 75 |
+
return {"translation": hf_inference_fn(req.text)}
|