fix: apiContentForModel 累积所有内容——文字+文件+视频帧+图片,不再只发视频
This commit is contained in:
@@ -1001,7 +1001,13 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
|||||||
}
|
}
|
||||||
const displayContent = displayParts.join('\n');
|
const displayContent = displayParts.join('\n');
|
||||||
|
|
||||||
// Ollama API 用的完整描述(视频带帧序列)
|
// Ollama API 用的完整描述(文字 + 文件 + 视频帧序列 + 图片提示)
|
||||||
|
const apiParts: string[] = [];
|
||||||
|
if (text) apiParts.push(text);
|
||||||
|
if (userFiles.length > 0) {
|
||||||
|
const fileContents = pendingFiles.map(f => ({ language: f.language, content: f.content }));
|
||||||
|
apiParts.push(...buildFileContentParts(fileContents));
|
||||||
|
}
|
||||||
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) {
|
||||||
@@ -1015,13 +1021,13 @@ 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}`);
|
||||||
}
|
}
|
||||||
apiContentForModel = (text || '') + '\n\n' + parts.join('\n\n') + '\n\n上述帧按时间顺序排列,帧间存在时序关系。请分析视频内容。';
|
apiParts.push(parts.join('\n\n'));
|
||||||
|
apiParts.push('上述帧按时间顺序排列,帧间存在时序关系。请分析视频内容。');
|
||||||
|
}
|
||||||
if (pendingImages.length > 0) {
|
if (pendingImages.length > 0) {
|
||||||
apiContentForModel += `\n\n[同时上传了 ${pendingImages.length} 张图片]`;
|
apiParts.push(pendingImages.length === 1 ? `[同时上传了图片: ${pendingImages[0].name}]` : `[同时上传了 ${pendingImages.length} 张图片]`);
|
||||||
}
|
|
||||||
} else if (displayContent) {
|
|
||||||
apiContentForModel = displayContent;
|
|
||||||
}
|
}
|
||||||
|
apiContentForModel = apiParts.join('\n\n');
|
||||||
|
|
||||||
const msg: ChatMessage = {
|
const msg: ChatMessage = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
|||||||
Reference in New Issue
Block a user