fix: route WeChat media through shared vision pipeline

This commit is contained in:
john
2026-07-18 18:15:22 +08:00
parent 8ccaf3b39d
commit 8eaf4d23f3
4 changed files with 369 additions and 19 deletions
+61
View File
@@ -898,6 +898,67 @@ test('submitSessionReplyForUser adds goose metadata visibility flags before repl
});
});
test('submitSessionReplyForUser applies the shared Qwen vision preprocessing path', async () => {
await withFakeGoosedSession(async ({ apiTarget, workingDir, replyBodies }) => {
const proxy = createTkmindProxy({
apiTarget,
apiSecret: 'test-secret',
userAuth: {
...createMemoryTestUserAuth(workingDir),
async ownsSession() {
return true;
},
async canUseChat() {
return { ok: true };
},
async getUserById() {
return { id: 'user-1' };
},
async getUserPublishLayout() {
return { publicUrl: 'https://example.com/MindSpace/user-1' };
},
async resolveUserPolicies() {
return { unrestricted: true, policies: {} };
},
},
localFetchAsset: async () => ({
buffer: Buffer.from('fake-image'),
mimeType: 'image/jpeg',
}),
llmProviderService: {
async applyBestProviderForSession() {
return { ok: true };
},
async hasVisionKey() {
return true;
},
async analyzeImagesWithVision() {
return '一件蓝色产品,白色背景,竖版构图。';
},
},
});
await proxy.submitSessionReplyForUser(
'user-1',
'session-1',
'request-qwen-vision',
{
id: 'message-qwen-vision',
role: 'user',
content: [{ type: 'text', text: '请分析这张图片' }],
metadata: {
imageUrls: ['/api/mindspace/v1/assets/asset-1/download?inline=1'],
displayText: '请分析这张图片',
},
},
);
const forwardedText = replyBodies[0]?.user_message?.content?.[0]?.text ?? '';
assert.match(forwardedText, /Qwen VL 图片描述/);
assert.match(forwardedText, /一件蓝色产品/);
});
});
test('submitSessionReplyForUser passes current prompt to Memory V2 resolve before existing reply path', async () => {
let resolveInput = null;
await withFakeGoosedSession(async ({ apiTarget, workingDir }) => {