fix: 独立图片在视频帧之前描述,明确 images 数组索引边界
- 图片: images[0] 请单独分析 - 视频帧: images[1..30] 为帧序列 - 避免模型把独立图片混入视频帧
This commit is contained in:
@@ -1013,6 +1013,13 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
|||||||
apiParts.push(...fileParts);
|
apiParts.push(...fileParts);
|
||||||
logInfo('📄 文件内容已注入', `${fileParts.length} 段, 共 ${fileContents.reduce((s, f) => s + f.content.length, 0)} 字符`);
|
logInfo('📄 文件内容已注入', `${fileParts.length} 段, 共 ${fileContents.reduce((s, f) => s + f.content.length, 0)} 字符`);
|
||||||
}
|
}
|
||||||
|
// 独立图片(与 images 数组前 N 张对应,在视频帧之前描述)
|
||||||
|
if (pendingImages.length === 1) {
|
||||||
|
apiParts.push(`[独立图片: ${pendingImages[0].name}](images[0],请单独分析)`);
|
||||||
|
} else if (pendingImages.length > 1) {
|
||||||
|
const imgNames = pendingImages.map(img => img.name).join(', ');
|
||||||
|
apiParts.push(`[${pendingImages.length} 张独立图片: ${imgNames}](images[0..${pendingImages.length - 1}],请分别分析)`);
|
||||||
|
}
|
||||||
let allVids: Array<{ name: string; count: number; dur: number; frames: Array<{ timestampSeconds: number; name: string }> }> = [];
|
let allVids: Array<{ name: string; count: number; dur: number; frames: Array<{ timestampSeconds: number; name: string }> }> = [];
|
||||||
if (hasVideos) {
|
if (hasVideos) {
|
||||||
if (pendingVideoMeta && pendingVideoFrames.length > 0) {
|
if (pendingVideoMeta && pendingVideoFrames.length > 0) {
|
||||||
@@ -1026,12 +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');
|
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}`);
|
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(parts.join('\n\n'));
|
||||||
apiParts.push('上述帧按时间顺序排列,帧间存在时序关系。请分析视频内容。');
|
apiParts.push('上述帧按时间顺序排列,帧间存在时序关系。请分析视频内容。');
|
||||||
}
|
}
|
||||||
if (pendingImages.length > 0) {
|
|
||||||
apiParts.push(pendingImages.length === 1 ? `[同时上传了图片: ${pendingImages[0].name}]` : `[同时上传了 ${pendingImages.length} 张图片]`);
|
|
||||||
}
|
|
||||||
apiContentForModel = apiParts.join('\n\n');
|
apiContentForModel = apiParts.join('\n\n');
|
||||||
|
|
||||||
const msg: ChatMessage = {
|
const msg: ChatMessage = {
|
||||||
|
|||||||
Reference in New Issue
Block a user