fix: guard WeChat page follow-up context
This commit is contained in:
@@ -8,7 +8,14 @@ import { buildWechatPageImageInstruction } from '../image-generation-policy.mjs'
|
||||
/**
|
||||
* Service-account-only page generation prompt. Does not use H5 buildAutoChatSkillPrefix.
|
||||
*/
|
||||
export function buildPageGenerateAgentPrompt(intent, { wantsDocx = false, imagePolicy = null } = {}) {
|
||||
export function buildPageGenerateAgentPrompt(
|
||||
intent,
|
||||
{
|
||||
wantsDocx = false,
|
||||
imagePolicy = null,
|
||||
preferImmediateContext = false,
|
||||
} = {},
|
||||
) {
|
||||
const topic = String(intent?.agentText ?? intent?.displayText ?? '').trim();
|
||||
const pageDataTask = isPageDataIntent(topic) || isPageDataDevIntent(topic);
|
||||
const scheduleTimezone = process.env.H5_DEFAULT_TIMEZONE || 'Asia/Shanghai';
|
||||
@@ -22,6 +29,14 @@ export function buildPageGenerateAgentPrompt(intent, { wantsDocx = false, imageP
|
||||
const imageBlock = buildWechatPageImageInstruction(imagePolicy, {
|
||||
sourceMessageId: intent?.msgId,
|
||||
});
|
||||
const immediateContextBlock = preferImmediateContext
|
||||
? [
|
||||
'【即时上下文优先】当前需求是对本会话紧邻内容的续作。',
|
||||
'“这个/刚才/做成页面”等指代只能解析为当前会话最近一轮内容,禁止用长期记忆、历史偏好或旧任务替换主题。',
|
||||
'如果当前会话没有可辨识的紧邻内容,必须请用户补充主题,禁止猜测并生成其他页面。',
|
||||
'',
|
||||
].join('\n')
|
||||
: '';
|
||||
const coverExample = imageBlock
|
||||
? '<本轮 generate_image 返回的 asset.htmlSrc>'
|
||||
: 'assets/hero.jpg';
|
||||
@@ -42,6 +57,7 @@ export function buildPageGenerateAgentPrompt(intent, { wantsDocx = false, imageP
|
||||
'',
|
||||
docxBlock,
|
||||
imageBlock,
|
||||
immediateContextBlock,
|
||||
pageDataBlock,
|
||||
'步骤(必须全部完成):',
|
||||
pageDataTask
|
||||
|
||||
Reference in New Issue
Block a user