feat: 优化日报总结与延续性跟踪
This commit is contained in:
@ -194,7 +194,9 @@ def cmd_summarize(args):
|
||||
configured_output_path,
|
||||
default_dry_run_path,
|
||||
default_summary_path,
|
||||
escape_obsidian_tags,
|
||||
load_config,
|
||||
load_previous_summary,
|
||||
resolve_chat_rules,
|
||||
resolve_day,
|
||||
resolve_people_aliases,
|
||||
@ -273,6 +275,7 @@ def cmd_summarize(args):
|
||||
int(end.timestamp()),
|
||||
chat_ids=args.chat,
|
||||
exclude_chat_ids=exclude_chat_ids,
|
||||
include_outgoing=True,
|
||||
)
|
||||
if args.dry_run:
|
||||
records = [serialize_message(row, tz) for row in rows]
|
||||
@ -286,15 +289,21 @@ def cmd_summarize(args):
|
||||
)
|
||||
print(
|
||||
f"DRY RUN 已导出: {output}"
|
||||
f"({target_day.isoformat()},收到消息 {len(rows)} 条,未发送给模型)"
|
||||
f"({target_day.isoformat()},纳入消息 {len(rows)} 条,未发送给模型)"
|
||||
)
|
||||
return 0
|
||||
previous_summary, previous_day_missing = load_previous_summary(
|
||||
config["output"], target_day
|
||||
)
|
||||
contacts = None
|
||||
sender_types = {}
|
||||
if rows and not args.no_contacts:
|
||||
from snooper_contacts import ContactsError, fetch_contacts
|
||||
|
||||
try:
|
||||
contacts = fetch_contacts(LarkClient(LarkAuth()), rows)
|
||||
contacts = fetch_contacts(
|
||||
LarkClient(LarkAuth()), rows, sender_types=sender_types
|
||||
)
|
||||
except ContactsError as error:
|
||||
raise SummaryError(str(error)) from error
|
||||
content = summarize_messages(
|
||||
@ -306,15 +315,19 @@ def cmd_summarize(args):
|
||||
contacts=contacts,
|
||||
chat_prompts=chat_prompts,
|
||||
people_aliases=people_aliases,
|
||||
sender_types=sender_types,
|
||||
previous_summary=previous_summary,
|
||||
)
|
||||
output_path = (
|
||||
args.output
|
||||
or configured_output_path(output_config, "summary", target_day)
|
||||
or default_summary_path(target_day)
|
||||
)
|
||||
content = add_obsidian_properties(
|
||||
content, {"model": model.rsplit("/", 1)[-1], "is_read": False}
|
||||
)
|
||||
content = escape_obsidian_tags(content)
|
||||
properties = {"model": model.rsplit("/", 1)[-1], "is_read": False}
|
||||
if previous_day_missing:
|
||||
properties["tags"] = ["no_previous_day_log"]
|
||||
content = add_obsidian_properties(content, properties)
|
||||
output = write_summary(output_path, content)
|
||||
dry_run_path = configured_output_path(
|
||||
config["output"], "dry_run", target_day
|
||||
@ -331,7 +344,7 @@ def cmd_summarize(args):
|
||||
else:
|
||||
cleanup_note = ",已清理 dry-run JSON"
|
||||
print(
|
||||
f"已生成: {output}({target_day.isoformat()},收到消息 {len(rows)} 条,"
|
||||
f"已生成: {output}({target_day.isoformat()},纳入消息 {len(rows)} 条,"
|
||||
f"模型 {model}{cleanup_note})"
|
||||
)
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user