Knowledge Base Skill
支持图片附件与OCR的文字提取,按业务类型管理问答知识库。
下载 719
从 Gmail 收到的打车发票中提取行程数据,存入本地 SQLite 数据库。
openclaw skills install @tuleyko/ride-insights-test命令、参数、文件名以原文为准
构建一个骑行账单处理流水线,从 Gmail 收到的账单邮件中提取数据,存入 emails.json 文件,将每封邮件发送至本地 OpenClaw Gateway 的 /v1/responses 接口进行结构化信息抽取,生成 rides.json 数组,并将结果插入 SQLite 数据库。
gog CLI 对目标 Gmail 账户完成认证。gog auth list,即使用户已指定账户也需执行。请选择要使用的账户:(A) name1@example.com 或 (B) name2@example.com? 不得简化为“默认”或让用户自行推断账户存在情况。default 的账户一定存在。OPENCLAW_GATEWAY_TOKEN 环境变量或 ~/.openclaw/openclaw.json 文件获取 Gateway 认证令牌。emails.json 会本地存储已获取的账单邮件,可能包含完整的 HTML 账单内容。主要输出文件:
data/gateway-llm/emails.json —— 所有获取的账单邮件,以 JSON 数组形式存储;可能包含完整 HTML 内容data/gateway-llm/rides.json —— 提取后的骑行记录,以 JSON 数组形式存储data/gateway-llm/rides.sqlite —— 可查询的 SQLite 数据库,包含标准化的骑行字段及 extracted_ride_json,但不保留原始邮件 JSON按顺序执行每一步,任一环节失败则停止并报告错误。
PRAGMA table_info(rides) 检查实际表结构,或查阅 references/schema_rides.sql。provider、email_date_text、currency、amount、pickup_city 和 dropoff_city。python3 skills/ride-receipts-gateway-llm/scripts/init_db.py \
--db ./data/gateway-llm/rides.sqlite \
--schema skills/ride-receipts-gateway-llm/references/schema_rides.sqlemails.jsonpython3 skills/ride-receipts-gateway-llm/scripts/fetch_emails_json.py \
--account <gmail-account> \
--after YYYY-MM-DD \
--before YYYY-MM-DD \
--max-per-provider 5000 \
--out ./data/gateway-llm/emails.json说明:
--after / --before 参数。references/provider_queries.json。/v1/responses 接口提取骑行信息至 rides.jsonOPENCLAW_GATEWAY_URL=http://127.0.0.1:18789 \
OPENCLAW_GATEWAY_TOKEN=... \
python3 skills/ride-receipts-gateway-llm/scripts/extract_rides_gateway.py \
--emails-json ./data/gateway-llm/emails.json \
--out ./data/gateway-llm/rides.json说明:
/v1/responses 接口。OPENCLAW_ALLOW_NONLOCAL_GATEWAY=1 强制启用。rides.json,实现进度检查点。rides.json 已存在,将跳过 gmail_message_id 已存在于其中的邮件。--delay-ms <n> 参数增加延迟。rides.json 插入 SQLite 数据库python3 skills/ride-receipts-gateway-llm/scripts/insert_rides_json_sqlite.py \
--db ./data/gateway-llm/rides.sqlite \
--rides-json ./data/gateway-llm/rides.jsonpython3 skills/ride-receipts-gateway-llm/scripts/summary_rides_sqlite.py \
--db ./data/gateway-llm/rides.sqlite说明:
rides 表的实时模式。此步骤应作为代理动作执行,而非独立的洞察脚本。
推荐工作流:
data/gateway-llm/rides.json 可用时,直接读取以保留提取后的骑行对象。data/gateway-llm/rides.sqlite 获取少量基础统计,但不要输出原始 SQL 结果。当用户要求提供匿名化或可共享的乘车报告时,请使用内置的 Python 导出脚本。
python3 skills/ride-receipts-gateway-llm/scripts/export_anonymized_rides_csv.py \
--db ./data/gateway-llm/rides.sqlite \
--out ./data/gateway-llm/anonymized_rides.csv导出规则:
provider, email_month, start_time_15m, end_time_15m, currency, amount, distance_km, duration_min, pickup_city, pickup_country, dropoff_city, dropoff_country。email_date_text 转换为仅保留月份的格式,如 2025-05。start_time_text 和 end_time_text 向上舍入至最近的 15 分钟时段;恰好在整点 15 分钟的时间保持不变。extracted_ride_json 中的标准化数据,导出 distance_km 和 duration_min;若缺失则留空。.csv 文件,不要将 CSV 文本直接粘贴到聊天中。data/gateway-llm/anonymized_rides.csv。MEDIA:./data/gateway-llm/anonymized_rides.csv。 Done — I regenerated the anonymized CSV and attached the updated file.
然后是单独一行的 MEDIA: 指令。
null 表示。skills/ride-receipts-gateway-llm/references/schema_rides.sqlskills/ride-receipts-gateway-llm/references/provider_queries.json已收录 1 个 Skill