mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2026-02-03 11:40:39 +03:00
add api exception handler (#74)
* try to add exception handler * improve server error test * fix lint * add build_uri util * fix header file path --------- Co-authored-by: Dmitry Afanasyev <afanasiev@litres.ru>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqladmin import Admin, ModelView
|
||||
|
||||
from core.bot.models.chatgpt import ChatGptModels
|
||||
from core.utils import build_uri
|
||||
from settings.config import settings
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -21,12 +21,11 @@ class ChatGptAdmin(ModelView, model=ChatGptModels):
|
||||
|
||||
|
||||
def create_admin(application: "Application") -> Admin:
|
||||
base_url = os.path.join(settings.URL_PREFIX, "admin")
|
||||
admin = Admin(
|
||||
title="Chat GPT admin",
|
||||
app=application.fastapi_app,
|
||||
engine=application.db.async_engine,
|
||||
base_url=base_url if base_url.startswith("/") else "/" + base_url,
|
||||
base_url=build_uri([settings.URL_PREFIX, "admin"]),
|
||||
authentication_backend=None,
|
||||
)
|
||||
admin.add_view(ChatGptAdmin)
|
||||
|
||||
Reference in New Issue
Block a user