Skip to content

Commit

Permalink
fix:update indicator formula
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-ckt committed Jul 9, 2024
1 parent 6ee2ba1 commit 0c6344d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions dbgpt/app/scene/chat_knowledge/financial/chat_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ async def map(self, input_value: dict) -> str:
raw_table = match.group(1)
if raw_table:
sql = sql.replace(raw_table, "fin_report")
input_value["sql"] = sql
data_df = await self.blocking_func_to_async(database.run_to_df, sql)
view = await vis.display(chart=input_value, data_df=data_df)
return view
40 changes: 23 additions & 17 deletions dbgpt/app/scene/chat_knowledge/financial/chat_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@
"""

fin_indicator_map = {
"营业成本率": {"公式": "营业成本率=营业成本/营业收入", "数值": ["营业成本", "营业收入"]},
"投资收益占营业收入比率": {"公式": "投资收益占营业收入比率=投资收益/营业收入", "数值": ["投资收益", "营业收入"]},
"管理费用率": {"公式": "管理费用率=管理费用/营业收入", "数值": ["管理费用", "营业收入"]},
"财务费用率": {"公式": "财务费用率=财务费用/营业收入", "数值": ["财务费用", "营业收入"]},
"营业成本率": {"公式": "营业成本率=CAST(营业成本)/CAST(营业收入)", "数值": ["营业成本", "营业收入"]},
"投资收益占营业收入比率": {"公式": "投资收益占营业收入比率=CAST(投资收益)/CAST(营业收入)", "数值": ["投资收益", "营业收入"]},
"管理费用率": {"公式": "管理费用率=CAST(管理费用)/CAST(营业收入)", "数值": ["管理费用", "营业收入"]},
"财务费用率": {"公式": "财务费用率=CAST(财务费用)/CAST(营业收入)", "数值": ["财务费用", "营业收入"]},
"三费比重": {
"公式": "三费比重=(销售费用+管理费用+财务费用)/营业收入",
"公式": "三费比重=(CAST(销售费用+管理费用+财务费用))/营业收入",
"数值": ["销售费用", "管理费用", "财务费用", "营业收入"],
},
"企业研发经费占费用比例": {
"公式": "企业研发经费占费用比例=研发费用/(销售费用+财务费用+管理费用+研发费用)",
"公式": "企业研发经费占费用比例=CAST(研发费用)/CAST((销售费用+财务费用+管理费用+研发费用))",
"数值": ["研发费用", "销售费用", "财务费用", "管理费用"],
},
"企业研发经费与利润比值": {"公式": "企业研发经费与利润比值=研发费用/净利润", "数值": ["研发费用", "净利润"]},
"企业研发经费与营业收入比值": {"公式": "企业研发经费与营业收入比值=研发费用/营业收入", "数值": ["研发费用", "营业收入"]},
"企业研发经费与利润比值": {"公式": "企业研发经费与利润比值=CAST(研发费用)/CAST(净利润)", "数值": ["研发费用", "净利润"]},
"企业研发经费与营业收入比值": {"公式": "企业研发经费与营业收入比值=CAST(研发费用)/CAST(营业收入)", "数值": ["研发费用", "营业收入"]},
"销售人员占比": {"公式": "销售人员占比=销售人员/职工总数", "数值": ["销售人员", "职工总数"]},
"行政人员占比": {"公式": "行政人员占比=行政人员/职工总数", "数值": ["行政人员", "职工总数"]},
"财务人员占比": {"公式": "财务人员占比=财务人员/职工总数", "数值": ["财务人员", "职工总数"]},
Expand All @@ -106,15 +106,21 @@
"公式": "企业硕士及以上人员占职工人数比例=(硕士人员 + 博士及以上人员)/职工总数",
"数值": ["硕士人员", "博士及以上人员", "职工总数"],
},
"毛利率": {"公式": "毛利率=(营业收入-营业成本)/营业收入", "数值": ["营业收入", "营业成本"]},
"营业利润率": {"公式": "营业利润率=营业利润/营业收入", "数值": ["营业利润", "营业收入"]},
"流动比率": {"公式": "流动比率=流动资产合计/流动负债合计", "数值": ["流动资产合计", "流动负债合计"]},
"速动比率": {"公式": "速动比率=(流动资产合计-存货)/流动负债合计", "数值": ["流动资产合计", "存货", "流动负债合计"]},
"资产负债比率": {"公式": "资产负债比率=负债合计/资产总计", "数值": ["负债合计", "资产总计"]},
"现金比率": {"公式": "现金比率=货币资金/流动负债合计", "数值": ["货币资金", "流动负债合计"]},
"非流动负债合计比率": {"公式": "非流动负债合计比率=非流动负债合计/负债合计", "数值": ["非流动负债合计", "负债合计"]},
"流动负债合计比率": {"公式": "流动负债合计比率=流动负债合计/负债合计", "数值": ["流动负债合计", "负债合计"]},
"净利润率": {"公式": "净利润率=净利润/营业收入", "数值": ["净利润", "营业收入"]},
"毛利率": {"公式": "毛利率=(CAST(营业收入)-CAST(营业成本))/CAST(营业收入)", "数值": ["营业收入", "营业成本"]},
"营业利润率": {"公式": "营业利润率=CAST(营业利润)/CAST(营业收入)", "数值": ["营业利润", "营业收入"]},
"流动比率": {"公式": "流动比率=CAST(流动资产合计)/CAST(流动负债合计)", "数值": ["流动资产合计", "流动负债合计"]},
"速动比率": {
"公式": "速动比率=(CAST(流动资产合计)-CAST(存货))/CAST(流动负债合计)",
"数值": ["流动资产合计", "存货", "流动负债合计"],
},
"资产负债比率": {"公式": "资产负债比率=CAST(负债合计)/CAST(资产总计)", "数值": ["负债合计", "资产总计"]},
"现金比率": {"公式": "现金比率=CAST(货币资金)/CAST(流动负债合计)", "数值": ["货币资金", "流动负债合计"]},
"非流动负债合计比率": {
"公式": "非流动负债合计比率=CAST(非流动负债合计)/CAST(负债合计)",
"数值": ["非流动负债合计", "负债合计"],
},
"流动负债合计比率": {"公式": "流动负债合计比率=CAST(流动负债合计)/CAST(负债合计)", "数值": ["流动负债合计", "负债合计"]},
"净利润率": {"公式": "净利润率=CAST(净利润)/CAST(营业收入)", "数值": ["净利润", "营业收入"]},
}

_SHARE_DATA_DATABASE_NAME_KEY = "__database_name__"
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/rag/assembler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
with root_tracer.start_span("BaseAssembler.load_knowledge", metadata=metadata):
self.load_knowledge(self._knowledge)

def load_knowledge(self, knowledge: Optional[Knowledge] = None) -> None:
def load_knowledge(self, knowledge: Knowledge) -> None:
"""Load knowledge Pipeline."""
if not knowledge:
raise ValueError("knowledge must be provided.")
Expand Down
6 changes: 3 additions & 3 deletions dbgpt/rag/assembler/fin_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async def aload_from_knowledge(
)

def load_knowledge(
self, knowledge: Optional[FinReportKnowledge] = None
self, knowledge: FinReportKnowledge # type: ignore
) -> None: # type: ignore
"""Load knowledge Pipeline."""
if not knowledge:
Expand Down Expand Up @@ -208,9 +208,9 @@ def load_knowledge(
with root_tracer.start_span("FinReportAssembler.chunk_manager.split"):
self._chunks = self._chunk_manager.split(page_documents)

def persist(
def persist( # type: ignore
self, db_config: DBConfig, conn_database: RDBMSConnector
) -> List[str]: # type: ignore
) -> List[str]:
"""Persist chunks into store.
Returns:
Expand Down

0 comments on commit 0c6344d

Please sign in to comment.