Skip to content

Commit 5389974

Browse files
committed
Fix JSON parsing before it gets passed to predict (#865)
(cherry picked from commit f8ad61f)
1 parent 45c7433 commit 5389974

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/workloads/cortex/serve/serve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import threading
2222
import math
2323
import asyncio
24-
from typing import Union, Any
24+
from typing import Any
2525

26-
from fastapi import FastAPI
26+
from fastapi import Body, FastAPI
2727
from fastapi.exceptions import RequestValidationError
2828
from starlette.requests import Request
2929
from starlette.responses import Response
@@ -147,7 +147,7 @@ def apply_cors_headers(request: Request, response: Response):
147147

148148

149149
@app.post("/predict")
150-
def predict(request: Union[dict, list, Any], debug=False):
150+
def predict(request: Any = Body(..., media_type="application/json"), debug=False):
151151
api = local_cache["api"]
152152
predictor_impl = local_cache["predictor_impl"]
153153

0 commit comments

Comments
 (0)