* rename webui.py to run_webui.py * remove unused imports * remove unsued code * move inference code and fix all warnings * move web app code * make code easier to read * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove unused function * remove msgpack_api.py * rename API files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * finish updating the doc with the new file names * finish updating the doc with the new file names * fix CPU use in the API * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor WebUIinference in a class with submodules * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * re-enable streaming in webui inference code * generalize inference code in webui * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor fix * make a unique inference engine class * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor fix * cleaning code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * implement new structure of the API (not working) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor API * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * minor fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * reimplement chat endpoint * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
28 lines
729 B
Python
28 lines
729 B
Python
import traceback
|
|
from http import HTTPStatus
|
|
|
|
from kui.asgi import HTTPException, JSONResponse
|
|
|
|
|
|
class ExceptionHandler:
|
|
|
|
async def http_exception_handler(self, exc: HTTPException):
|
|
return JSONResponse(
|
|
dict(
|
|
statusCode=exc.status_code,
|
|
message=exc.content,
|
|
error=HTTPStatus(exc.status_code).phrase,
|
|
),
|
|
exc.status_code,
|
|
exc.headers,
|
|
)
|
|
|
|
async def other_exception_handler(self, exc: Exception):
|
|
traceback.print_exc()
|
|
|
|
status = HTTPStatus.INTERNAL_SERVER_ERROR
|
|
return JSONResponse(
|
|
dict(statusCode=status, message=str(exc), error=status.phrase),
|
|
status,
|
|
)
|