v2.5.4 — Portrait-Bilder bleiben beim Reload erhalten
- Portrait wird als [PORTRAIT]path[/PORTRAIT] in DB gespeichert - Serverseitiges Jinja2-Rendering zeigt Bild beim Reload - JS loadHistory() rendert PORTRAIT-Marker als <img> - Ollama bekommt keine PORTRAIT-Nachrichten (skip in build_prompt)
This commit is contained in:
+22
-2
@@ -82,7 +82,14 @@
|
||||
<div class="msg msg-greeting">{{ character.greeting }}</div>
|
||||
{% endif %}
|
||||
{% for h in history %}
|
||||
{% if '[PORTRAIT]' in h.content %}
|
||||
<div class="msg msg-bot" style="padding: 0; overflow: hidden;">
|
||||
<img src="{{ h.content | replace('[PORTRAIT]', '') | replace('[/PORTRAIT]', '') }}?t={{ range(1000, 9999) | random }}" style="width: 100%; max-width: 400px; border-radius: 16px 16px 16px 4px; display: block;">
|
||||
<div style="padding: 8px 12px; font-size: 0.8rem; color: var(--muted);">🖼️ Neues Portrait generiert</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="msg {{ 'msg-user' if h.role == 'user' else 'msg-bot' }}">{{ h.content }}</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -272,8 +279,21 @@
|
||||
for (let i = currentMsgs; i < data.history.length; i++) {
|
||||
const h = data.history[i];
|
||||
const div = document.createElement('div');
|
||||
div.className = `msg ${h.role === 'user' ? 'msg-user' : 'msg-bot'}`;
|
||||
div.textContent = h.content;
|
||||
|
||||
// Check if it's a portrait message
|
||||
const portraitMatch = h.content && h.content.match(/^\[PORTRAIT\](.+)\[\/PORTRAIT\]$/);
|
||||
if (portraitMatch) {
|
||||
div.className = 'msg msg-bot';
|
||||
div.style.padding = '0';
|
||||
div.style.overflow = 'hidden';
|
||||
div.innerHTML = `
|
||||
<img src="${portraitMatch[1]}?t=${Date.now()}" style="width: 100%; max-width: 400px; border-radius: 16px 16px 16px 4px; display: block;">
|
||||
<div style="padding: 8px 12px; font-size: 0.8rem; color: var(--muted);">🖼️ Neues Portrait generiert</div>
|
||||
`;
|
||||
} else {
|
||||
div.className = `msg ${h.role === 'user' ? 'msg-user' : 'msg-bot'}`;
|
||||
div.textContent = h.content;
|
||||
}
|
||||
chat.appendChild(div);
|
||||
}
|
||||
chat.scrollTop = chat.scrollHeight;
|
||||
|
||||
Reference in New Issue
Block a user