fix: allow page clarification turns without delivery error

This commit is contained in:
john
2026-07-24 17:37:05 +08:00
parent 54637beffb
commit 412e5f149b
5 changed files with 103 additions and 2 deletions
+20
View File
@@ -108,6 +108,26 @@ export function isPageGenerationIntent(text) {
return PAGE_GENERATION_INTENT_PATTERNS.some((pattern) => pattern.test(normalized));
}
const GENERIC_PAGE_REQUEST_FILLER_RE =
/(?:请|麻烦|能否|可以|可不可以|帮我|给我|我想要?|想要|生成|做|制作|创建|设计|写|出|一个|一份|个|页面|网页|H5|HTML|活动页|宣传页|落地页|分享页|吧|呢|好吗|谢谢)/giu;
const GENERIC_PAGE_REQUEST_ENGLISH_FILLER_RE =
/\b(?:please|can|could|would|you|help|me|i|want|to|publish|create|generate|make|build|design|a|an|one|html|web|page|landing|h5|thanks?)\b/giu;
/**
* A bare request such as “帮我生成一个页面吧” names no subject or content.
* It is a valid page intent, but the current turn can only clarify requirements;
* the delivery guard must not require public HTML until the user supplies details.
*/
export function isGenericPageGenerationRequest(text) {
const normalized = String(text ?? '').trim();
if (!normalized || !isPageGenerationIntent(normalized)) return false;
const remainder = normalized
.replace(GENERIC_PAGE_REQUEST_FILLER_RE, '')
.replace(GENERIC_PAGE_REQUEST_ENGLISH_FILLER_RE, '')
.replace(/[\s,。!?、,.!?;:'"“”‘’()()[\]{}_-]+/gu, '');
return remainder.length === 0;
}
export function isProductCampaignIntent(text) {
const normalized = String(text ?? '').trim();
if (!normalized) return false;