mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-13 21:21:08 +00:00
fix:client mypy error
This commit is contained in:
@@ -1,21 +1,49 @@
|
||||
"""App Client API."""
|
||||
from dbgpt.client.client import Client
|
||||
from typing import List
|
||||
|
||||
from dbgpt.client.client import Client, ClientException
|
||||
from dbgpt.client.schemas import AppModel
|
||||
from dbgpt.serve.core import Result
|
||||
|
||||
|
||||
async def get_app(client: Client, app_id: str):
|
||||
async def get_app(client: Client, app_id: str) -> AppModel:
|
||||
"""Get an app.
|
||||
|
||||
Args:
|
||||
client (Client): The dbgpt client.
|
||||
app_id (str): The app id.
|
||||
Returns:
|
||||
AppModel: The app model.
|
||||
Raises:
|
||||
ClientException: If the request failed.
|
||||
"""
|
||||
return await client.get("/apps/" + app_id)
|
||||
try:
|
||||
res = await client.get("/apps/" + app_id)
|
||||
result: Result = res.json()
|
||||
if result["success"]:
|
||||
return AppModel(**result["data"])
|
||||
else:
|
||||
raise ClientException(status=result["err_code"], reason=result)
|
||||
except Exception as e:
|
||||
raise ClientException(f"Failed to get app: {e}")
|
||||
|
||||
|
||||
async def list_app(client: Client):
|
||||
async def list_app(client: Client) -> List[AppModel]:
|
||||
"""List apps.
|
||||
|
||||
Args:
|
||||
client (Client): The dbgpt client.
|
||||
Returns:
|
||||
List[AppModel]: The list of app models.
|
||||
Raises:
|
||||
ClientException: If the request failed.
|
||||
"""
|
||||
return await client.get("/apps")
|
||||
try:
|
||||
res = await client.get("/apps")
|
||||
result: Result = res.json()
|
||||
if result["success"]:
|
||||
return [AppModel(**app) for app in result["data"]["app_list"]]
|
||||
else:
|
||||
raise ClientException(status=result["err_code"], reason=result)
|
||||
except Exception as e:
|
||||
raise ClientException(f"Failed to list apps: {e}")
|
||||
|
Reference in New Issue
Block a user