Skip to content

Commit

Permalink
feat(agent):Agent App
Browse files Browse the repository at this point in the history
1.Fix the display problem under dashboboard
2.Support Awel Agent to arrange fixed targets
  • Loading branch information
yhjun1026 committed Feb 19, 2024
1 parent 37f7ad1 commit ba57257
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
8 changes: 5 additions & 3 deletions dbgpt/agent/actions/dashboard_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ async def a_run(
sql_df = await resource_db_client.a_query_to_df(
resource.value, chart_item.sql
)
chart_item["data"] = sql_df
chart_dict = chart_item.dict()

chart_dict["data"] = sql_df
except Exception as e:
logger.warn(f"Sql excute Failed!{str(e)}")
chart_item["err_msg"] = str(e)
chart_params.append(chart_item)
chart_dict["err_msg"] = str(e)
chart_params.append(chart_dict)
view = await self.render_protocal.disply(charts=chart_params)
return ActionOutput(
is_exe_success=True,
Expand Down
1 change: 1 addition & 0 deletions dbgpt/agent/agents/expand/dashboard_assistant_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DashboardAssistantAgent(ConversableAgent):
constraints: List[str] = [
"You are only responsible for collecting and sorting out the analysis SQL that already exists in historical messages, and do not generate any analysis sql yourself.",
"In order to build a report with rich display types, you can appropriately adjust the display type of the charts you collect so that you can build a better report. Of course, you can choose from the following available display types: {display_type}",
"Please read and completely collect all analysis sql in the historical conversation, and do not omit or modify the content of the analysis sql.",
]
desc: str = "Observe and organize various analysis results and construct professional reports"

Expand Down
20 changes: 11 additions & 9 deletions dbgpt/agent/agents/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ class Role(ABC, BaseModel):

expand_prompt: str = ""

fixed_subgoal: Optional[str] = None

constraints: List[str] = []
examples: str = ""
desc: str = ""
language: str = "en"
is_human: bool = False
is_team: bool = False

def __init__(self, **kwargs):
super().__init__(**kwargs)
class Config:
arbitrary_types_allowed = True

def prompt_template(
self,
Expand All @@ -32,16 +34,16 @@ def prompt_template(
template = f"""
{self.role_prompt}
Please think step by step to achieve the goal. You can use the resources given below. At the same time, please strictly abide by the constraints and specifications in IMPORTANT REMINDER.
{{resource_prompt}}
{self.expand_prompt if len(self.expand_prompt)>0 else ""}
{self.expand_prompt if len(self.expand_prompt) > 0 else ""}
*** IMPORTANT REMINDER ***
{self.language_require_prompt}
{self.constraints_prompt}
{'You can refer to the following examples:' if len(self.examples) > 0 else ""}
{'You can refer to the following examples:' if len(self.examples) > 0 else ""}
{self.examples if len(self.examples) > 0 else ""}
{{out_schema}}
Expand All @@ -61,7 +63,7 @@ def role_prompt(self):
def constraints_prompt(self):
if len(self.constraints) > 0:
return "\n".join(
f"{i+1}. {item}" for i, item in enumerate(self.constraints)
f"{i + 1}. {item}" for i, item in enumerate(self.constraints)
)

@property
Expand Down
9 changes: 6 additions & 3 deletions dbgpt/vis/tags/vis_dashboard.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -24,14 +27,14 @@ async def generate_content(self, **kwargs) -> Optional[str]:
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)
Expand Down

0 comments on commit ba57257

Please sign in to comment.