Simon-Liu's picture
Add tw-finance-function-call-reasoning (research-only, CC BY-NC 4.0)
7ff93da verified
Raw History Blame Contribute Delete
3.8 kB
# -*- coding: utf-8 -*-
"""模板顯示欄位 -> 實際函式參數的對照。
用途:判斷一個 query 模板是否真的把某個參數「講出來」了。
若題目沒提到,該參數就不應出現在 answer(system prompt 明令不得臆測參數值)。
"""
ALIAS = {
"twse_quote_lookup": {"name": "symbol"},
"stock_trade_cost": {"lots": "shares", "side_zh": "side", "dt_zh": "day_trade",
"disc_zh": "discount"},
"margin_trading_calc": {"lots": "shares", "pct": "financing_ratio"},
"price_limit_range": {},
"securities_transaction_tax": {"type_zh": "security_type", "amt_wan": "amount",
"dt_zh": "day_trade"},
"income_tax_estimate": {"wan": "annual_income", "fs_zh": "filing_status",
"dt_zh": "deduction_type"},
"dividend_tax_compare": {"dw": "dividend_amount", "ow": "other_income",
"fs_zh": "filing_status"},
"house_land_capital_gains_tax": {"gw": "gain", "su_zh": "self_use"},
"estate_tax_calc": {"gw": "gross_estate", "sp_zh": "spouse"},
"gift_tax_calc": {"gw": "gift_amount"},
"labor_insurance_annuity": {"off_zh": "claim_age_offset"},
"labor_pension_fund_projection": {"self_pct": "self_contribution_rate",
"ret_pct": "annual_return"},
"nhi_supplementary_premium": {"type_zh": "income_type", "wan": "amount"},
"mortgage_amortization": {"wan": "principal", "m_zh": "method",
"g_zh": "grace_period_years"},
"time_deposit_interest": {"wan": "principal", "c_zh": "compounding",
"i_zh": "interest_type"},
"credit_card_revolving_interest": {"wan": "balance"},
"deposit_insurance_coverage": {"nw": "ntd_deposit", "fw": "fx_deposit_twd_equiv"},
"etf_dividend_yield": {"name": "symbol", "freq_zh": "frequency"},
"regular_investment_projection": {"name": "symbol", "ret_pct": "annual_return"},
"expense_ratio_drag": {"wan": "principal", "ter_pct": "expense_ratio",
"gr_pct": "gross_annual_return"},
"fx_rate_lookup": {"cz": "base_currency", "rt_zh": "rate_type"},
"foreign_currency_deposit_return": {"cz": "currency", "wan": "amount_twd"},
"bond_price_from_ytm": {"freq_zh": "coupon_frequency"},
"cbc_policy_rate_lookup": {"rt_zh": "rate_type"},
"aml_transaction_screening": {"tt_zh": "transaction_type"},
"kyc_risk_rating": {"ct_zh": "customer_type", "pep_zh": "is_pep"},
"taiwan_regulation_lookup": {},
"credit_capacity_dbr": {"mw": "monthly_income"},
"jcic_credit_report": {"qp_zh": "query_purpose"},
"retirement_gap_analysis": {"mw": "monthly_expense_today", "inf_pct": "inflation_rate",
"ret_pct": "annual_return"},
"emergency_fund_target": {"js_zh": "job_stability"},
"life_insurance_gap": {"iw": "annual_income", "m_zh": "method"},
"financial_term_explain": {"lv_zh": "audience_level"},
"license_exam_question_bank": {},
"market_index_lookup": {"idx_zh": "index_name", "fields_zh": "fields"},
}
def covered_args(tool_name, placeholders, arg_keys):
"""回傳模板實際「提到」的參數集合。"""
a = ALIAS.get(tool_name, {})
out = set()
for p in placeholders:
if p in arg_keys:
out.add(p)
elif p in a:
out.add(a[p])
return out
# 模板以散文帶到、但沒有用 placeholder 表達的參數,需強制保留。
KEEP = {
("labor_pension_fund_projection", 0): {"employer_rate"}, # 「雇主提 6%」
("taiwan_regulation_lookup", 0): {"include_amendments"}, # 「含修正沿革」
("financial_term_explain", 1): {"language"}, # 「麻煩用繁體中文」
}