fix: 修复图片传输 + 记忆开关 + 统一图标
1. fix: 开启工具调用后图片无法传给AI - agent-engine.ts: images 为空文字时自动生成分析提示 - input-area.ts: 图片+文字合并为单条消息,避免历史消息中图片丢失 2. fix: 记忆弹框自动记忆开关点击无响应 - memory-modal.ts: CSS 类名 memory-toggle → toggle-label,启用完整滑块样式 3. chore: 统一应用图标为科技感羊驼 - llama.png / llama.ico: 霓虹电路风格羊驼图标
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 21 KiB |
@@ -547,15 +547,19 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
||||
const images = pendingImages.map(img => img.base64);
|
||||
|
||||
if (pendingImages.length > 0) {
|
||||
msgsToAdd.push({
|
||||
const imgDesc = pendingImages.length === 1 ? `[上传了图片: ${pendingImages[0].name}]` : `[上传了 ${pendingImages.length} 张图片]`;
|
||||
const msg: ChatMessage = {
|
||||
role: 'user',
|
||||
content: pendingImages.length === 1 ? `[上传了图片: ${pendingImages[0].name}]` : `[上传了 ${pendingImages.length} 张图片]`,
|
||||
content: text ? `${text}\n\n${imgDesc}` : imgDesc,
|
||||
images,
|
||||
timestamp: now
|
||||
});
|
||||
};
|
||||
if (userFiles.length > 0) {
|
||||
msg.files = userFiles;
|
||||
msg._fileContents = pendingFiles.map(f => ({ language: f.language, content: f.content }));
|
||||
}
|
||||
|
||||
if (text || pendingFiles.length > 0) {
|
||||
msgsToAdd.push(msg);
|
||||
} else if (text || pendingFiles.length > 0) {
|
||||
const msg: ChatMessage = {
|
||||
role: 'user',
|
||||
content: text || '',
|
||||
|
||||
@@ -28,7 +28,7 @@ export function initMemoryModal(): void {
|
||||
<div class="modal-header">
|
||||
<h3>🧠 Agent 记忆</h3>
|
||||
<div style="display:flex;align-items:center;gap:8px;">
|
||||
<label class="memory-toggle" title="自动记忆">
|
||||
<label class="toggle-label" title="自动记忆">
|
||||
<input type="checkbox" id="memoryModalToggle" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
|
||||
@@ -102,8 +102,11 @@ export async function runAgentLoop(
|
||||
});
|
||||
}
|
||||
|
||||
const userMsg: OllamaMessage = { role: 'user', content: userContent };
|
||||
if (images?.length) userMsg.images = images;
|
||||
const userMsg: OllamaMessage = {
|
||||
role: 'user',
|
||||
content: userContent || (images?.length ? (images.length > 1 ? `请分析这 ${images.length} 张图片` : '请分析这张图片') : ''),
|
||||
...(images?.length && { images })
|
||||
};
|
||||
messages.push(userMsg);
|
||||
|
||||
const tools = getEnabledToolDefinitions();
|
||||
|
||||
Reference in New Issue
Block a user