mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-28 04:51:29 +00:00
feat: Add dbgpt client and add api v2
This commit is contained in:
@@ -16,7 +16,16 @@ class BaseServeConfig(BaseParameters):
|
||||
config (AppConfig): Application configuration
|
||||
config_prefix (str): Configuration prefix
|
||||
"""
|
||||
global_prefix = "dbgpt.app.global."
|
||||
global_dict = config.get_all_by_prefix(global_prefix)
|
||||
config_dict = config.get_all_by_prefix(config_prefix)
|
||||
# remove prefix
|
||||
config_dict = {k[len(config_prefix) :]: v for k, v in config_dict.items()}
|
||||
config_dict = {
|
||||
k[len(config_prefix) :]: v
|
||||
for k, v in config_dict.items()
|
||||
if k.startswith(config_prefix)
|
||||
}
|
||||
for k, v in global_dict.items():
|
||||
if k not in config_dict and k[len(global_prefix) :] in cls().__dict__:
|
||||
config_dict[k[len(global_prefix) :]] = v
|
||||
return cls(**config_dict)
|
||||
|
@@ -69,11 +69,11 @@ async def validation_exception_handler(
|
||||
|
||||
async def http_exception_handler(request: Request, exc: HTTPException):
|
||||
res = Result.failed(
|
||||
msg=exc.detail,
|
||||
err_code="E0002",
|
||||
msg=str(exc.detail),
|
||||
err_code=str(exc.status_code),
|
||||
)
|
||||
logger.error(f"http_exception_handler catch HTTPException: {res}")
|
||||
return JSONResponse(status_code=400, content=res.dict())
|
||||
return JSONResponse(status_code=exc.status_code, content=res.dict())
|
||||
|
||||
|
||||
async def common_exception_handler(request: Request, exc: Exception) -> JSONResponse:
|
||||
|
@@ -18,7 +18,7 @@ class BaseServe(BaseComponent, ABC):
|
||||
def __init__(
|
||||
self,
|
||||
system_app: SystemApp,
|
||||
api_prefix: str,
|
||||
api_prefix: str | List[str],
|
||||
api_tags: List[str],
|
||||
db_url_or_db: Union[str, URL, DatabaseManager] = None,
|
||||
try_create_tables: Optional[bool] = False,
|
||||
|
Reference in New Issue
Block a user