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:
@@ -109,7 +109,7 @@ MORE_REPLIES_PROMPT_SHORT = """你是一个邮件回复助手。根据以下邮
|
|||||||
MORE_REPLIES_PROMPT_FULL = """你是一个邮件回复助手。根据以下邮件内容生成3个不同的正式邮件回复。
|
MORE_REPLIES_PROMPT_FULL = """你是一个邮件回复助手。根据以下邮件内容生成3个不同的正式邮件回复。
|
||||||
|
|
||||||
规则:
|
规则:
|
||||||
- 完整模式:生成完整的邮件格式,包括称呼(如 Dear xxx,)和正文,结尾只写问候语逗号(如 Best regards,)不写落款,用户会自己编辑添加。
|
- 完整模式:生成完整的邮件格式,包括称呼(如 Dear xxx,)和正文,结尾只写问候语逗号,不写落款,用户会自己编辑添加。
|
||||||
- 必须使用与邮件相同的语言回复(英文邮件用英文,中文邮件用中文)。
|
- 必须使用与邮件相同的语言回复(英文邮件用英文,中文邮件用中文)。
|
||||||
- 语气正式专业,适合商务邮件。
|
- 语气正式专业,适合商务邮件。
|
||||||
|
|
||||||
|
|||||||
@@ -362,33 +362,19 @@ 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)
|
||||||
# 缓存为空时重新生成
|
_tg_req(tg_cfg, "editMessageText", {
|
||||||
if not suggestions:
|
"chat_id": chat_id, "message_id": msg_id,
|
||||||
logger.info(" 缓存为空,重新生成 AI 回复 (style=%s)", style)
|
"text": "🤖 *AI思考中…*", "parse_mode": "MarkdownV2",
|
||||||
_tg_req(tg_cfg, "editMessageText", {
|
|
||||||
"chat_id": chat_id, "message_id": msg_id,
|
|
||||||
"text": "🤖 *AI思考中…*", "parse_mode": "MarkdownV2",
|
|
||||||
})
|
|
||||||
conv = load_conversation(chat_id) or {}
|
|
||||||
conv["state"] = "ai_reply_selection"
|
|
||||||
conv["summary_msg_id"] = msg_id
|
|
||||||
conv["reply_style"] = style
|
|
||||||
conv["all_suggestions"] = []
|
|
||||||
save_conversation(chat_id, 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)
|
conv = load_conversation(chat_id) or {}
|
||||||
_show_ai_suggestions(tg_cfg, chat_id, msg_id, suggestions)
|
conv["state"] = "ai_reply_selection"
|
||||||
|
conv["summary_msg_id"] = msg_id
|
||||||
|
conv["reply_style"] = style
|
||||||
|
conv["all_suggestions"] = []
|
||||||
|
save_conversation(chat_id, conv)
|
||||||
|
_ai_pool.submit(_do_regen, cfg, chat_id, msg_id, ctx, conv)
|
||||||
|
|
||||||
elif action == CALLBACK_SEND_REPLY and ctx:
|
elif action == CALLBACK_SEND_REPLY and ctx:
|
||||||
idx = int(parts[2])
|
idx = int(parts[2])
|
||||||
|
|||||||
Reference in New Issue
Block a user