feat(wechat): add image generation delivery policy
Memind CI / Test, build, and release guards (pull_request) Successful in 2m45s
Memind CI / Test, build, and release guards (pull_request) Successful in 2m45s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
buildWechatPageImageInstruction,
|
||||
buildWechatStandaloneImageInstruction,
|
||||
resolveWechatImageGenerationPolicy,
|
||||
WECHAT_PAGE_THUMBNAIL_MODE,
|
||||
} from './image-generation-policy.mjs';
|
||||
|
||||
test('service-account page always requires a fresh thumbnail without forcing body images', () => {
|
||||
const policy = resolveWechatImageGenerationPolicy({
|
||||
text: '请做一个苏州旅行页面',
|
||||
isPageGenerate: true,
|
||||
requireFreshPageThumbnail: true,
|
||||
});
|
||||
assert.equal(policy.pageThumbnailMode, WECHAT_PAGE_THUMBNAIL_MODE.REQUIRED_FRESH);
|
||||
assert.equal(policy.imageGenerationMode, 'required');
|
||||
assert.equal(policy.inlineImageMode, 'auto');
|
||||
assert.equal(policy.standaloneImageMode, 'auto');
|
||||
assert.match(buildWechatPageImageInstruction(policy), /每个本轮交付给用户的正式内容页面/);
|
||||
});
|
||||
|
||||
test('no-image page request disables body images but keeps required fresh thumbnail', () => {
|
||||
const policy = resolveWechatImageGenerationPolicy({
|
||||
text: '生成一个活动页面,只要文字,不要图片',
|
||||
isPageGenerate: true,
|
||||
requireFreshPageThumbnail: true,
|
||||
});
|
||||
assert.equal(policy.pageThumbnailMode, 'required_fresh');
|
||||
assert.equal(policy.inlineImageMode, 'disabled');
|
||||
assert.match(buildWechatPageImageInstruction(policy), /正文和 Hero 不展示图片/);
|
||||
});
|
||||
|
||||
test('explicit body illustration request is independent from the page thumbnail', () => {
|
||||
const policy = resolveWechatImageGenerationPolicy({
|
||||
text: '生成一个科普页面,每个章节都要正文插图',
|
||||
isPageGenerate: true,
|
||||
requireFreshPageThumbnail: true,
|
||||
});
|
||||
assert.equal(policy.inlineImageMode, 'required');
|
||||
});
|
||||
|
||||
test('standalone image intent gets an inline_image tool contract', () => {
|
||||
const policy = resolveWechatImageGenerationPolicy({ text: '帮我生成一张雨夜橘猫图片' });
|
||||
assert.equal(policy.standaloneImageMode, 'required');
|
||||
const instruction = buildWechatStandaloneImageInstruction(policy, { sourceMessageId: 'msg-1' });
|
||||
assert.match(instruction, /purpose=`inline_image`/);
|
||||
assert.match(instruction, /idempotency_key=wechat-msg-1-image/);
|
||||
});
|
||||
Reference in New Issue
Block a user