From adb5c6734529b806e0c876239551deb42bcfbf27 Mon Sep 17 00:00:00 2001 From: Benature Date: Fri, 27 Nov 2026 23:13:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A8=A1=E5=9E=8B=E5=92=8C=E6=8C=89=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E9=87=8D=E7=94=9F=E6=88=90=E6=97=A5=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ VERSION | 2 +- backfill_summaries.py | 19 +++++++++++++++++-- lark_snooper.py | 17 +++++++++++++++-- tests/test_backfill.py | 19 +++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 183cf38..1c6b4a8 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,9 @@ VIDEO 消息不设每日数量上限:下载到 `~/.larkx/videos`,每个视 生成日报时会读取前一天和前两天 Markdown(不包含其 frontmatter),在“前日工作延续”中区分继续推进和今日未见延续。前一天文件不存在或为空时,属性添加 `tags: [no_previous_day_log]`,并明确无法判断延续性。周一同时读取周末最后一天(周日)和上周最后一个工作日的日志,工作日判断包含法定节假日和调休。 ```bash +# 图片输入使用独立模型,文本总结仍使用主模型 +./lark_snooper.py summarize --date 2026-10-08 --image-model maqqie/gg-chat-efund/EFundGPT-dsv4-flash-code + # 只检查模型,不同步或读取消息 ./lark_snooper.py summarize --check diff --git a/VERSION b/VERSION index 53a75d6..b003284 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.6 +0.2.7 diff --git a/backfill_summaries.py b/backfill_summaries.py index 155ac5b..c54ac67 100755 --- a/backfill_summaries.py +++ b/backfill_summaries.py @@ -57,6 +57,7 @@ def missing_message_dates( output_for_day, overwrite: bool = False, refresh_tagged_from: date | None = None, + daily_overwrite_from: date | None = None, ): """Yield message days that are missing or explicitly tagged for refresh.""" current = start @@ -68,7 +69,8 @@ def missing_message_dates( and current >= refresh_tagged_from and has_missing_report_tag(output) ) - if (overwrite or not exists or refresh) and has_messages(current): + forced = daily_overwrite_from is not None and current >= daily_overwrite_from + if (overwrite or not exists or refresh or forced) and has_messages(current): yield current current += timedelta(days=1) @@ -102,11 +104,13 @@ def main(): parser.add_argument("--timezone", default=DEFAULT_TIMEZONE) parser.add_argument("--config", default="config.yaml") parser.add_argument("--model", default=os.environ.get("MAGPIE_MODEL", DEFAULT_MODEL)) + parser.add_argument("--image-model", help="图片卡片和视频帧使用的 EFundGPT 模型") parser.add_argument("--base-url", default=os.environ.get("MAGPIE_BASE_URL", DEFAULT_BASE_URL)) parser.add_argument("--timeout", type=int, default=600) parser.add_argument("--overwrite", action="store_true", help="覆盖已有非空日报、周记和月记") parser.add_argument("--weekly-through", help="先仅补齐此日期前已结束周的周记") parser.add_argument("--refresh-tagged-from", help="重新生成此日期起带缺周报/月报标签的日报") + parser.add_argument("--daily-overwrite-from", help="覆盖此日期起的全部已有日报") parser.add_argument("--state", default=str(DEFAULT_STATE_PATH)) args = parser.parse_args() @@ -158,6 +162,10 @@ def main(): resolve_day(args.refresh_tagged_from, args.timezone)[0] if args.refresh_tagged_from else None ) + daily_overwrite_from = ( + resolve_day(args.daily_overwrite_from, args.timezone)[0] + if args.daily_overwrite_from else None + ) daily_start = max(start, refresh_tagged_from) if refresh_tagged_from else start def output_for_day(day: date) -> Path: @@ -267,6 +275,7 @@ def main(): output_for_day, args.overwrite, refresh_tagged_from, + daily_overwrite_from, ): command = [ sys.executable, str(ROOT / "lark_snooper.py"), "summarize", @@ -275,8 +284,14 @@ def main(): "--base-url", args.base_url, "--timeout", str(args.timeout), "--no-fetch", ] + if args.image_model: + command.extend(["--image-model", args.image_model]) output = output_for_day(day) - if args.overwrite or has_missing_report_tag(output): + if ( + args.overwrite + or has_missing_report_tag(output) + or (daily_overwrite_from and day >= daily_overwrite_from) + ): command.append("--overwrite") result = run_step(command, output, f"补日志 {day}") if result: diff --git a/lark_snooper.py b/lark_snooper.py index 0a7b009..57154ea 100755 --- a/lark_snooper.py +++ b/lark_snooper.py @@ -223,8 +223,20 @@ def cmd_summarize(args): ) # The EFundGPT preflight must pass before history sync or storage access. client.assert_model_available() + image_client = client + image_model = getattr(args, "image_model", None) + if image_model and image_model != model: + image_client = MagpieClient( + model=image_model, + base_url=base_url, + api_key=os.environ.get("MAGPIE_API_KEY"), + timeout=args.timeout, + ) + image_client.assert_model_available() if args.check: print(f"OK Magpie 可用模型: {model}(未读取消息)") + if image_client is not client: + print(f"OK Magpie 可用图片模型: {image_model}") return 0 config = load_config(getattr(args, "config", None)) output_config = {} if args.output else config["output"] @@ -318,7 +330,7 @@ def cmd_summarize(args): from snooper_card_images import enrich_card_images image_stats = enrich_card_images( - LarkClient(LarkAuth()), client, rows, max_images=3 + LarkClient(LarkAuth()), image_client, rows, max_images=3 ) if image_stats["candidates"]: print( @@ -330,7 +342,7 @@ def cmd_summarize(args): video_stats = enrich_videos( LarkClient(LarkAuth()), - client, + image_client, rows, max_frames=getattr(args, "video_frames", 12), transcribe_audio=not getattr(args, "no_video_audio", False), @@ -574,6 +586,7 @@ def main(): summarize.add_argument("--timezone", default="Asia/Shanghai", help="统计日边界时区") summarize.add_argument("--chat", action="append", help="只汇总指定 chat_id;可重复") summarize.add_argument("--model", help="实际模型段必须以 EFundGPT 开头;也可设 MAGPIE_MODEL") + summarize.add_argument("--image-model", help="图片卡片和视频帧使用的 EFundGPT 模型;默认同主模型") summarize.add_argument("--base-url", help="Magpie OpenAI 兼容地址") summarize.add_argument("--timeout", type=int, default=180, help="单次 Magpie 请求超时秒数") summarize.add_argument("--max-chars", type=int, default=80000, help="每个对话内每块消息最大字符数") diff --git a/tests/test_backfill.py b/tests/test_backfill.py index 0d44d7a..92ed44d 100644 --- a/tests/test_backfill.py +++ b/tests/test_backfill.py @@ -57,3 +57,22 @@ def test_backfill_refreshes_only_tagged_reports_from_requested_date(tmp_path): assert has_missing_report_tag(tagged) assert has_missing_report_tag(later) assert not has_missing_report_tag(ordinary) + + +def test_backfill_force_refreshes_all_daily_notes_from_requested_date(tmp_path): + before = tmp_path / "2026-10-07.md" + before.write_text("保留日报", encoding="utf-8") + first = tmp_path / "2026-10-08.md" + first.write_text("旧日报", encoding="utf-8") + second = tmp_path / "2026-10-09.md" + second.write_text("旧日报", encoding="utf-8") + + days = list(missing_message_dates( + date(2026, 10, 7), + date(2026, 10, 9), + lambda day: True, + lambda day: tmp_path / f"{day.isoformat()}.md", + daily_overwrite_from=date(2026, 10, 8), + )) + + assert days == [date(2026, 10, 8), date(2026, 10, 9)]