merge: honor explicit WeChat page generation negation
Memind CI / Test, build, and release guards (push) Successful in 2m49s
Memind CI / Test, build, and release guards (push) Successful in 2m49s
Merge real-WeChat acceptance fix after successful CI.
This commit was merged in pull request #19.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
resolveWechatImageGenerationPolicy,
|
||||
WECHAT_PAGE_THUMBNAIL_MODE,
|
||||
} from './image-generation-policy.mjs';
|
||||
import { classifyWechatIntent } from './intent/classifier.mjs';
|
||||
|
||||
test('service-account page always requires a fresh thumbnail without forcing body images', () => {
|
||||
const policy = resolveWechatImageGenerationPolicy({
|
||||
@@ -47,3 +48,17 @@ test('standalone image intent gets an inline_image tool contract', () => {
|
||||
assert.match(instruction, /purpose=`inline_image`/);
|
||||
assert.match(instruction, /idempotency_key=wechat-msg-1-image/);
|
||||
});
|
||||
|
||||
test('explicitly declining a page keeps standalone image generation out of page flow', () => {
|
||||
const text = '请生成一张雨夜橘猫插画,只生成图片,不要生成页面';
|
||||
const intent = classifyWechatIntent({ msgType: 'text', agentText: text });
|
||||
assert.equal(intent.kind, 'chat.general');
|
||||
|
||||
const policy = resolveWechatImageGenerationPolicy({
|
||||
text,
|
||||
isPageGenerate: intent.kind === 'page.generate',
|
||||
requireFreshPageThumbnail: true,
|
||||
});
|
||||
assert.equal(policy.pageThumbnailMode, 'auto');
|
||||
assert.equal(policy.standaloneImageMode, 'required');
|
||||
});
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
export const PAGE_GENERATE_PATTERN =
|
||||
/(?:生成|创建|做|写|帮我.*(?:生成|创建|做|写)).*(?:html|页面|网页|page|文件)/iu;
|
||||
|
||||
export const PAGE_GENERATE_NEGATION_PATTERN =
|
||||
/(?:不要|无需|不用|别|不需要)\s*(?:再\s*)?(?:生成|创建|制作|做|写)\s*(?:任何|一个|新的)?\s*(?:html|页面|网页|page|文件)/iu;
|
||||
|
||||
export const DOCX_DOWNLOAD_PATTERN =
|
||||
/(?:(?:word|docx|\.docx|\.doc|文档).*(?:下载|链接|导出|给我)|(?:下载|导出|提供|给我).*(?:word|docx|\.docx|\.doc|文档))/iu;
|
||||
|
||||
@@ -21,6 +24,7 @@ export const CONNECTIVITY_TEST_PATTERN = /^(测试\s*\d*|test\s*\d*)[!!。.\s]
|
||||
export function isPageGenerateText(text) {
|
||||
const normalized = String(text ?? '').trim();
|
||||
if (!normalized) return false;
|
||||
if (PAGE_GENERATE_NEGATION_PATTERN.test(normalized)) return false;
|
||||
return PAGE_GENERATE_PATTERN.test(normalized);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user