fix: always regenerate AI replies when selecting style, ignore summary cache The cached reply_suggestions from summarization use a generic prompt, not matching full/short style. Now always triggers fresh generation.

This commit is contained in:
2026-07-17 21:01:03 +08:00
parent 1d70fe2491
commit 8386ab3c89
2 changed files with 13 additions and 27 deletions

View File

@@ -109,7 +109,7 @@ MORE_REPLIES_PROMPT_SHORT = """你是一个邮件回复助手。根据以下邮
MORE_REPLIES_PROMPT_FULL = """你是一个邮件回复助手。根据以下邮件内容生成3个不同的正式邮件回复。 MORE_REPLIES_PROMPT_FULL = """你是一个邮件回复助手。根据以下邮件内容生成3个不同的正式邮件回复。
规则: 规则:
- 完整模式:生成完整的邮件格式,包括称呼(如 Dear xxx,)和正文,结尾只写问候语逗号(如 Best regards,不写落款,用户会自己编辑添加。 - 完整模式:生成完整的邮件格式,包括称呼(如 Dear xxx,)和正文,结尾只写问候语逗号不写落款,用户会自己编辑添加。
- 必须使用与邮件相同的语言回复(英文邮件用英文,中文邮件用中文)。 - 必须使用与邮件相同的语言回复(英文邮件用英文,中文邮件用中文)。
- 语气正式专业,适合商务邮件。 - 语气正式专业,适合商务邮件。

View File

@@ -362,11 +362,8 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
elif action in (CALLBACK_AI_REPLY_FULL, CALLBACK_AI_REPLY_SHORT) and ctx: elif action in (CALLBACK_AI_REPLY_FULL, CALLBACK_AI_REPLY_SHORT) and ctx:
style = "full" if action == CALLBACK_AI_REPLY_FULL else "short" style = "full" if action == CALLBACK_AI_REPLY_FULL else "short"
suggestions = ctx["summary_data"].get("reply_suggestions", []) # 总是用对应风格重新生成,不使用摘要时的通用缓存
logger.info(" 重新生成 AI 回复 (style=%s)", style)
# 缓存为空时重新生成
if not suggestions:
logger.info(" 缓存为空,重新生成 AI 回复 (style=%s)", style)
_tg_req(tg_cfg, "editMessageText", { _tg_req(tg_cfg, "editMessageText", {
"chat_id": chat_id, "message_id": msg_id, "chat_id": chat_id, "message_id": msg_id,
"text": "🤖 *AI思考中…*", "parse_mode": "MarkdownV2", "text": "🤖 *AI思考中…*", "parse_mode": "MarkdownV2",
@@ -378,17 +375,6 @@ def _handle_callback(tg_cfg: TelegramConfig, cfg: Config, cb: dict):
conv["all_suggestions"] = [] conv["all_suggestions"] = []
save_conversation(chat_id, conv) save_conversation(chat_id, conv)
_ai_pool.submit(_do_regen, cfg, chat_id, msg_id, ctx, conv) _ai_pool.submit(_do_regen, cfg, chat_id, msg_id, ctx, conv)
return
save_conversation(chat_id, {
"state": "ai_reply_selection",
"summary_msg_id": msg_id,
"ai_suggestions": suggestions,
"all_suggestions": list(suggestions),
"reply_style": style,
})
logger.info(" 显示 AI 回复建议 (%d 条, style=%s)", len(suggestions), style)
_show_ai_suggestions(tg_cfg, chat_id, msg_id, suggestions)
elif action == CALLBACK_SEND_REPLY and ctx: elif action == CALLBACK_SEND_REPLY and ctx:
idx = int(parts[2]) idx = int(parts[2])