mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-25 03:20:41 +00:00
Gpts app v0.4 (#1169)
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from ..base import Vis
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VisDashboard(Vis):
|
||||
async def generate_content(self, **kwargs) -> Optional[str]:
|
||||
async def generate_param(self, **kwargs) -> Optional[str]:
|
||||
charts = kwargs.get("charts", None)
|
||||
title = kwargs.get("title", None)
|
||||
if not charts:
|
||||
@@ -24,14 +27,14 @@ class VisDashboard(Vis):
|
||||
try:
|
||||
df = chart.get("data", None)
|
||||
err_msg = chart.get("err_msg", None)
|
||||
if not df:
|
||||
if df is None:
|
||||
param["err_msg"] = err_msg
|
||||
else:
|
||||
param["data"] = json.loads(
|
||||
df.to_json(orient="records", date_format="iso", date_unit="s")
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.exception("dashboard chart build faild!")
|
||||
param["data"] = []
|
||||
param["err_msg"] = str(e)
|
||||
chart_items.append(param)
|
||||
|
Reference in New Issue
Block a user