fix: 去掉硬编码索引,用自然语言分隔图片和视频帧
图片和视频始终分块描述,最后追加'请分别分析,不要混淆'提示
This commit is contained in:
@@ -1013,12 +1013,12 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
||||
apiParts.push(...fileParts);
|
||||
logInfo('📄 文件内容已注入', `${fileParts.length} 段, 共 ${fileContents.reduce((s, f) => s + f.content.length, 0)} 字符`);
|
||||
}
|
||||
// 独立图片(与 images 数组前 N 张对应,在视频帧之前描述)
|
||||
// 图片和视频帧按顺序分块描述(images 数组:图片在前,视频帧在后)
|
||||
if (pendingImages.length === 1) {
|
||||
apiParts.push(`[独立图片: ${pendingImages[0].name}](images[0],请单独分析)`);
|
||||
apiParts.push(`[独立图片: ${pendingImages[0].name}](请单独分析该图片,勿与视频帧混淆)`);
|
||||
} else if (pendingImages.length > 1) {
|
||||
const imgNames = pendingImages.map(img => img.name).join(', ');
|
||||
apiParts.push(`[${pendingImages.length} 张独立图片: ${imgNames}](images[0..${pendingImages.length - 1}],请分别分析)`);
|
||||
apiParts.push(`[${pendingImages.length} 张独立图片: ${imgNames}](请分别分析每张图片,勿与视频帧混淆)`);
|
||||
}
|
||||
let allVids: Array<{ name: string; count: number; dur: number; frames: Array<{ timestampSeconds: number; name: string }> }> = [];
|
||||
if (hasVideos) {
|
||||
@@ -1033,10 +1033,11 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
||||
const fl = v.frames.map(f => ` ${String(f.timestampSeconds).padStart(4, ' ')}s — ${f.name}`).join('\n');
|
||||
parts.push(`[视频帧序列 · ${v.name} · ${v.count}帧 · 1fps · ${v.dur.toFixed(0)}s]\n${fl}`);
|
||||
}
|
||||
const offset = pendingImages.length;
|
||||
apiParts.push(`以下 images[${offset}..${offset + allVids.reduce((s, v) => s + v.count, 0) - 1}] 为视频帧序列:`);
|
||||
apiParts.push(parts.join('\n\n'));
|
||||
apiParts.push('上述帧按时间顺序排列,帧间存在时序关系。请分析视频内容。');
|
||||
apiParts.push('以上为视频帧序列,按时间顺序排列,帧间存在时序关系。请分析视频内容。');
|
||||
}
|
||||
if (pendingImages.length > 0 && hasVideos) {
|
||||
apiParts.push('注意:独立图片和视频帧是不同的内容,请分别分析,不要混淆。');
|
||||
}
|
||||
apiContentForModel = apiParts.join('\n\n');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user