Skip to content

Commit

Permalink
solver
Browse files Browse the repository at this point in the history
  • Loading branch information
sjnn12138 committed Jan 13, 2025
1 parent e5037d8 commit f16d148
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions kag/examples/FinState/solver/solver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from kag.interface import LLMClient
from kag.solver.logic.solver_pipeline import SolverPipeline
from kag.solver.implementation.table.table_reasoner import TableReasoner

llm_config = {
"type": "ant_deepseek",
"model": "deepseek-chat",
"key": "gs540iivzezmidi3",
"url": "https://zdfmng.alipay.com/commonQuery/queryData",
"visitDomain": "BU_altas",
"visitBiz": "BU_altas_tianchang",
"visitBizLine": "BU_altas_tianchang_line",
}
class FinStateSolver(SolverPipeline):
"""
solver
"""

def __init__(
self, max_run=3, reflector=None, reasoner=None, generator=None, **kwargs
):
super().__init__(max_run, reflector, reasoner, generator, **kwargs)
llm: LLMClient = LLMClient.from_config(llm_config)
self.table_reasoner = TableReasoner(llm_module = llm)

def run(self, question, **kwargs):
"""
Executes the core logic of the problem-solving system.
Parameters:
- question (str): The question to be answered.
Returns:
- tuple: answer, trace log
"""
return self.table_reasoner.reason(question, llm_module=None)


if __name__ == "__main__":
solver = FinStateSolver(KAG_PROJECT_ID=1)
#question = "阿里巴巴最新的营业收入是多少,哪个部分收入占比最高,占了百分之多少?"
#question = "阿里国际数字商业集团24年截至9月30日止六个月的收入是多少?它的经营利润率是多少?"
question1 = "阿里巴巴财报中,2024年-截至9月30日止六个月的收入是多少?收入中每个部分分别占比多少?"
#question = "可持续发展委员会有哪些成员组成"
#question = "公允价值计量表中,24年9月30日,第二级资产各项目哪个占比最高,占了百分之多少?"
# question = "231243423乘以13334233等于多少?"
#question = "李妈妈有12个糖果,她给李明了3个,李红4个,那么李妈妈还剩下多少个糖果?"
#response = solver.run(question)
response = solver.run(question1)
print("*" * 80)
print(question1)
print("*" * 40)
print(response)
print("*" * 80)

0 comments on commit f16d148

Please sign in to comment.