feat:更新智能体工具

This commit is contained in:
2026-07-13 22:06:05 +08:00
parent 900d5bd774
commit 5213897bbd
14 changed files with 672 additions and 157 deletions

17
domain/base.py Normal file
View File

@@ -0,0 +1,17 @@
from config.domain import register_domain, DomainConfig
from domain.bill import *
def init_domains():
register_domain(DomainConfig(
name="bill",
api_url=f"{BILL_BASE_URL}bill/summary",
entity_name="账单",
field_name_map=BILL_FIELD_NAME_MAP,
detail_fields=BILL_DETAIL_FIELDS,
search_fields=BILL_SEARCH_FIELDS,
metrics=BILL_METRICS,
token_getter=get_bill_token,
auth_header="satoken",
date_field="date",
))

40
domain/bill.py Normal file
View File

@@ -0,0 +1,40 @@
import requests
from config.domain import MetricConfig
BILL_BASE_URL = "https://cxx0822.s.3q.hair/home-api/"
USERNAME = "Cxx0822"
PASSWORD = "19940822Cxx"
_BILL_RAW_CACHE = None
_BILL_FILTERED_CACHE = None
def get_bill_token():
resp = requests.post(
f"{BILL_BASE_URL}session",
params={"name": USERNAME, "password": PASSWORD},
timeout=10,
)
resp.raise_for_status()
return resp.json()["saToken"]["tokenValue"]
BILL_FIELD_NAME_MAP = {
"date": "账单日期",
"bookName": "账本名称",
"type": "账单类型",
"category": "账单类别",
"location": "账单地点",
"payAccount": "支付账户",
"amount": "金额",
"content": "账单内容",
"remark": "备注",
}
BILL_DETAIL_FIELDS = ["date", "bookName", "type", "customer", "category",
"location", "payAccount", "amount", "content", "remark"]
BILL_SEARCH_FIELDS = ["location", "content", "remark"]
BILL_METRICS = [MetricConfig("amount", "金额", agg="sum", format="money")]