Spaces:
Runtime error
Runtime error
HinaCortus
commited on
Commit
•
5f0a349
1
Parent(s):
b1d7fd2
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
-
from
|
2 |
-
from
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
app
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
)
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from pydantic import BaseModel
|
3 |
+
from app.model.model import predict_pipeline
|
4 |
+
from app.model.model import __version__ as model_version
|
5 |
+
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
|
10 |
+
class TextIn(BaseModel):
|
11 |
+
text: str
|
12 |
+
|
13 |
+
|
14 |
+
class PredictionOut(BaseModel):
|
15 |
+
language: str
|
16 |
+
|
17 |
+
|
18 |
+
@app.get("/")
|
19 |
+
def home():
|
20 |
+
return {"health_check": "OK", "model_version": model_version}
|
21 |
+
|
22 |
+
|
23 |
+
@app.post("/predict", response_model=PredictionOut)
|
24 |
+
def predict(payload: TextIn):
|
25 |
+
language = predict_pipeline(payload.text)
|
26 |
+
return {"language": language}
|