first commit

This commit is contained in:
2026-03-09 14:46:56 +08:00
commit 62236eb80e
63 changed files with 6143 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
"""Prompt for extracting transactions from billing screenshots."""
EXTRACT_TRANSACTION_SYSTEM = """你是一个专业的金融交易数据提取助手专门用于从手机APP账单或交易记录截图中提取结构化信息。"""
EXTRACT_TRANSACTION_USER = """请分析这张手机APP账单/交易记录截图,提取所有可见的交易记录。
要求:
1. 只返回一个JSON数组不要包含其他说明文字。
2. 数组的每个元素是一条交易,包含以下字段(若截图中无该信息则填 null
- app_source: stringAPP来源"微信支付""支付宝""XX银行""XX钱包"
- transaction_type: string交易类型"转出""转入""消费""收款""提现""充值"
- amount: number金额数字不含货币符号
- currency: string币种"CNY""USDT",默认 "CNY"
- counterparty_name: string | null对方名称/姓名
- counterparty_account: string | null对方账号、卡号尾号、钱包地址等
- order_number: string | null订单号/交易号
- transaction_time: string | null交易时间请用 ISO 8601 格式,如 "2024-01-15T14:30:00"
- remark: string | null备注/摘要
- confidence: string识别置信度"high""medium""low" 之一
3. 注意区分转入和转出方向;金额统一为正数,方向由 transaction_type 体现。
4. 若截图中没有交易记录或无法识别,返回空数组 []。
直接输出JSON数组不要用 markdown 代码块包裹。"""
def get_extract_messages(image_b64: str) -> list[dict]:
"""Build messages for vision API: system + user with image."""
return [
{"role": "system", "content": EXTRACT_TRANSACTION_SYSTEM},
{
"role": "user",
"content": [
{"type": "text", "text": EXTRACT_TRANSACTION_USER},
{
"type": "image_url",
"image_url": {"url": f"data:image/jpeg;base64,{image_b64}"},
},
],
},
]