1919from api .database .sqlalchemy import initialize_db , get_async_session_context , get_user_db_context
2020from api .database .mongodb import init_mongodb
2121from api .enums import OpenaiWebChatStatus
22- from api .exceptions import SelfDefinedException , UserAlreadyExists
22+ from api .exceptions import SelfDefinedException , UserAlreadyExists , ArkoseForwardException
2323from api .middlewares import AccessLoggerMiddleware , StatisticsMiddleware
2424from api .models .db import User
25- from api .response import CustomJSONResponse , handle_exception_response
26- from api .routers import users , conv , chat , system , status , files , logs
25+ from api .response import CustomJSONResponse , handle_exception_response , handle_arkose_forward_exception
26+ from api .routers import users , conv , chat , system , status , files , logs , arkose
2727from api .schemas import UserCreate , UserSettingSchema
2828from api .sources import OpenaiWebChatManager
2929from api .users import get_user_manager_context
@@ -129,8 +129,8 @@ async def lifespan(app: FastAPI):
129129app .include_router (logs .router )
130130app .include_router (status .router )
131131app .include_router (files .router )
132+ app .include_router (arkose .router )
132133
133- # 解决跨站问题
134134app .add_middleware (
135135 CORSMiddleware ,
136136 allow_origins = config .http .cors_allow_origins ,
@@ -151,10 +151,15 @@ async def validation_exception_handler(request, exc):
151151
152152
153153@app .exception_handler (SelfDefinedException )
154- async def validation_exception_handler (request , exc ):
154+ async def self_defined_exception_handler (request , exc ):
155155 return handle_exception_response (exc )
156156
157157
158+ @app .exception_handler (ArkoseForwardException )
159+ async def arkose_forward_exception_handler (request , exc ):
160+ return handle_arkose_forward_exception (exc )
161+
162+
158163if __name__ == "__main__" :
159164 uvicorn .run (app , host = config .http .host ,
160165 port = config .http .port ,
0 commit comments