feat: 支持独立图片模型和按日期重生成日报
This commit is contained in:
@ -126,6 +126,9 @@ VIDEO 消息不设每日数量上限:下载到 `~/.larkx/videos`,每个视
|
|||||||
生成日报时会读取前一天和前两天 Markdown(不包含其 frontmatter),在“前日工作延续”中区分继续推进和今日未见延续。前一天文件不存在或为空时,属性添加 `tags: [no_previous_day_log]`,并明确无法判断延续性。周一同时读取周末最后一天(周日)和上周最后一个工作日的日志,工作日判断包含法定节假日和调休。
|
生成日报时会读取前一天和前两天 Markdown(不包含其 frontmatter),在“前日工作延续”中区分继续推进和今日未见延续。前一天文件不存在或为空时,属性添加 `tags: [no_previous_day_log]`,并明确无法判断延续性。周一同时读取周末最后一天(周日)和上周最后一个工作日的日志,工作日判断包含法定节假日和调休。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 图片输入使用独立模型,文本总结仍使用主模型
|
||||||
|
./lark_snooper.py summarize --date 2026-10-08 --image-model maqqie/gg-chat-efund/EFundGPT-dsv4-flash-code
|
||||||
|
|
||||||
# 只检查模型,不同步或读取消息
|
# 只检查模型,不同步或读取消息
|
||||||
./lark_snooper.py summarize --check
|
./lark_snooper.py summarize --check
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@ def missing_message_dates(
|
|||||||
output_for_day,
|
output_for_day,
|
||||||
overwrite: bool = False,
|
overwrite: bool = False,
|
||||||
refresh_tagged_from: date | None = None,
|
refresh_tagged_from: date | None = None,
|
||||||
|
daily_overwrite_from: date | None = None,
|
||||||
):
|
):
|
||||||
"""Yield message days that are missing or explicitly tagged for refresh."""
|
"""Yield message days that are missing or explicitly tagged for refresh."""
|
||||||
current = start
|
current = start
|
||||||
@ -68,7 +69,8 @@ def missing_message_dates(
|
|||||||
and current >= refresh_tagged_from
|
and current >= refresh_tagged_from
|
||||||
and has_missing_report_tag(output)
|
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
|
yield current
|
||||||
current += timedelta(days=1)
|
current += timedelta(days=1)
|
||||||
|
|
||||||
@ -102,11 +104,13 @@ def main():
|
|||||||
parser.add_argument("--timezone", default=DEFAULT_TIMEZONE)
|
parser.add_argument("--timezone", default=DEFAULT_TIMEZONE)
|
||||||
parser.add_argument("--config", default="config.yaml")
|
parser.add_argument("--config", default="config.yaml")
|
||||||
parser.add_argument("--model", default=os.environ.get("MAGPIE_MODEL", DEFAULT_MODEL))
|
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("--base-url", default=os.environ.get("MAGPIE_BASE_URL", DEFAULT_BASE_URL))
|
||||||
parser.add_argument("--timeout", type=int, default=600)
|
parser.add_argument("--timeout", type=int, default=600)
|
||||||
parser.add_argument("--overwrite", action="store_true", help="覆盖已有非空日报、周记和月记")
|
parser.add_argument("--overwrite", action="store_true", help="覆盖已有非空日报、周记和月记")
|
||||||
parser.add_argument("--weekly-through", help="先仅补齐此日期前已结束周的周记")
|
parser.add_argument("--weekly-through", help="先仅补齐此日期前已结束周的周记")
|
||||||
parser.add_argument("--refresh-tagged-from", help="重新生成此日期起带缺周报/月报标签的日报")
|
parser.add_argument("--refresh-tagged-from", help="重新生成此日期起带缺周报/月报标签的日报")
|
||||||
|
parser.add_argument("--daily-overwrite-from", help="覆盖此日期起的全部已有日报")
|
||||||
parser.add_argument("--state", default=str(DEFAULT_STATE_PATH))
|
parser.add_argument("--state", default=str(DEFAULT_STATE_PATH))
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -158,6 +162,10 @@ def main():
|
|||||||
resolve_day(args.refresh_tagged_from, args.timezone)[0]
|
resolve_day(args.refresh_tagged_from, args.timezone)[0]
|
||||||
if args.refresh_tagged_from else None
|
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
|
daily_start = max(start, refresh_tagged_from) if refresh_tagged_from else start
|
||||||
|
|
||||||
def output_for_day(day: date) -> Path:
|
def output_for_day(day: date) -> Path:
|
||||||
@ -267,6 +275,7 @@ def main():
|
|||||||
output_for_day,
|
output_for_day,
|
||||||
args.overwrite,
|
args.overwrite,
|
||||||
refresh_tagged_from,
|
refresh_tagged_from,
|
||||||
|
daily_overwrite_from,
|
||||||
):
|
):
|
||||||
command = [
|
command = [
|
||||||
sys.executable, str(ROOT / "lark_snooper.py"), "summarize",
|
sys.executable, str(ROOT / "lark_snooper.py"), "summarize",
|
||||||
@ -275,8 +284,14 @@ def main():
|
|||||||
"--base-url", args.base_url, "--timeout", str(args.timeout),
|
"--base-url", args.base_url, "--timeout", str(args.timeout),
|
||||||
"--no-fetch",
|
"--no-fetch",
|
||||||
]
|
]
|
||||||
|
if args.image_model:
|
||||||
|
command.extend(["--image-model", args.image_model])
|
||||||
output = output_for_day(day)
|
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")
|
command.append("--overwrite")
|
||||||
result = run_step(command, output, f"补日志 {day}")
|
result = run_step(command, output, f"补日志 {day}")
|
||||||
if result:
|
if result:
|
||||||
|
|||||||
@ -223,8 +223,20 @@ def cmd_summarize(args):
|
|||||||
)
|
)
|
||||||
# The EFundGPT preflight must pass before history sync or storage access.
|
# The EFundGPT preflight must pass before history sync or storage access.
|
||||||
client.assert_model_available()
|
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:
|
if args.check:
|
||||||
print(f"OK Magpie 可用模型: {model}(未读取消息)")
|
print(f"OK Magpie 可用模型: {model}(未读取消息)")
|
||||||
|
if image_client is not client:
|
||||||
|
print(f"OK Magpie 可用图片模型: {image_model}")
|
||||||
return 0
|
return 0
|
||||||
config = load_config(getattr(args, "config", None))
|
config = load_config(getattr(args, "config", None))
|
||||||
output_config = {} if args.output else config["output"]
|
output_config = {} if args.output else config["output"]
|
||||||
@ -318,7 +330,7 @@ def cmd_summarize(args):
|
|||||||
from snooper_card_images import enrich_card_images
|
from snooper_card_images import enrich_card_images
|
||||||
|
|
||||||
image_stats = 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"]:
|
if image_stats["candidates"]:
|
||||||
print(
|
print(
|
||||||
@ -330,7 +342,7 @@ def cmd_summarize(args):
|
|||||||
|
|
||||||
video_stats = enrich_videos(
|
video_stats = enrich_videos(
|
||||||
LarkClient(LarkAuth()),
|
LarkClient(LarkAuth()),
|
||||||
client,
|
image_client,
|
||||||
rows,
|
rows,
|
||||||
max_frames=getattr(args, "video_frames", 12),
|
max_frames=getattr(args, "video_frames", 12),
|
||||||
transcribe_audio=not getattr(args, "no_video_audio", False),
|
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("--timezone", default="Asia/Shanghai", help="统计日边界时区")
|
||||||
summarize.add_argument("--chat", action="append", help="只汇总指定 chat_id;可重复")
|
summarize.add_argument("--chat", action="append", help="只汇总指定 chat_id;可重复")
|
||||||
summarize.add_argument("--model", help="实际模型段必须以 EFundGPT 开头;也可设 MAGPIE_MODEL")
|
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("--base-url", help="Magpie OpenAI 兼容地址")
|
||||||
summarize.add_argument("--timeout", type=int, default=180, help="单次 Magpie 请求超时秒数")
|
summarize.add_argument("--timeout", type=int, default=180, help="单次 Magpie 请求超时秒数")
|
||||||
summarize.add_argument("--max-chars", type=int, default=80000, help="每个对话内每块消息最大字符数")
|
summarize.add_argument("--max-chars", type=int, default=80000, help="每个对话内每块消息最大字符数")
|
||||||
|
|||||||
@ -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(tagged)
|
||||||
assert has_missing_report_tag(later)
|
assert has_missing_report_tag(later)
|
||||||
assert not has_missing_report_tag(ordinary)
|
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)]
|
||||||
|
|||||||
Reference in New Issue
Block a user