Skip to content

Commit

Permalink
ENH: Improve internal server error (#2009)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingl2k1 authored Aug 4, 2024
1 parent 8e292b9 commit a5e827d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doc/source/models/model_abilities/audio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Speech API use non-stream by default as
-H 'Content-Type: application/json' \
-d '{
"model": "<MODEL_UID>",
"text": "<The text to generate audio for>",
"input": "<The text to generate audio for>",
"voice": "echo",
"stream": True,
}'
Expand Down Expand Up @@ -245,7 +245,7 @@ Basic usage, launch model ``CosyVoice-300M-SFT``.
-H 'Content-Type: application/json' \
-d '{
"model": "<MODEL_UID>",
"text": "<The text to generate audio for>",
"input": "<The text to generate audio for>",
# ['中文女', '中文男', '日语男', '粤语女', '英文女', '英文男', '韩语女']
"voice": "中文女"
}'
Expand Down
9 changes: 8 additions & 1 deletion xinference/api/restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from PIL import Image
from sse_starlette.sse import EventSourceResponse
from starlette.responses import JSONResponse as StarletteJSONResponse
from starlette.responses import RedirectResponse
from starlette.responses import PlainTextResponse, RedirectResponse
from uvicorn import Config, Server
from xoscar.utils import get_next_port

Expand Down Expand Up @@ -235,6 +235,13 @@ def serve(self, logging_conf: Optional[dict] = None):
allow_headers=["*"],
)

@self._app.exception_handler(500)
async def internal_exception_handler(request: Request, exc: Exception):
logger.exception("Handling request %s failed: %s", request.url, exc)
return PlainTextResponse(
status_code=500, content=f"Internal Server Error: {exc}"
)

# internal interface
self._router.add_api_route("/status", self.get_status, methods=["GET"])
# conflict with /v1/models/{model_uid} below, so register this first
Expand Down

0 comments on commit a5e827d

Please sign in to comment.