Restore chat thumbnails and gallery OCR captions
This commit is contained in:
parent
4d90eb3d44
commit
3b6d771be9
3 changed files with 5 additions and 20 deletions
|
|
@ -99,6 +99,7 @@ def _image_to_dict(img: GalleryImage, session_name: str = None) -> Dict[str, Any
|
||||||
"filename": img.filename,
|
"filename": img.filename,
|
||||||
"url": f"/api/generated-image/{img.filename}",
|
"url": f"/api/generated-image/{img.filename}",
|
||||||
"prompt": img.prompt,
|
"prompt": img.prompt,
|
||||||
|
"caption": img.caption or "",
|
||||||
"model": img.model,
|
"model": img.model,
|
||||||
"size": img.size,
|
"size": img.size,
|
||||||
"quality": img.quality,
|
"quality": img.quality,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ function _formatSize(bytes) {
|
||||||
// Build the `.attach-cards` element for a message's attachment list. Shared by
|
// Build the `.attach-cards` element for a message's attachment list. Shared by
|
||||||
// addMessage and updateMessageAttachments so a live (optimistic) user bubble
|
// addMessage and updateMessageAttachments so a live (optimistic) user bubble
|
||||||
// can be re-rendered with real upload ids once the upload resolves.
|
// can be re-rendered with real upload ids once the upload resolves.
|
||||||
function buildAttachCards(attachments) {
|
export function buildAttachCards(attachments) {
|
||||||
const attachWrap = document.createElement('div');
|
const attachWrap = document.createElement('div');
|
||||||
attachWrap.className = 'attach-cards';
|
attachWrap.className = 'attach-cards';
|
||||||
for (const att of attachments) {
|
for (const att of attachments) {
|
||||||
|
|
@ -2672,6 +2672,7 @@ const chatRenderer = {
|
||||||
createMsgFooter,
|
createMsgFooter,
|
||||||
displayMetrics,
|
displayMetrics,
|
||||||
addMessage,
|
addMessage,
|
||||||
|
buildAttachCards,
|
||||||
updateMessageAttachments,
|
updateMessageAttachments,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,26 +168,9 @@ function _renderHistoryMessage(msg, modelName) {
|
||||||
markdownModule.squashOutsideCode(markdownModule.renderContent(displayContent || ''))
|
markdownModule.squashOutsideCode(markdownModule.renderContent(displayContent || ''))
|
||||||
);
|
);
|
||||||
if (msg.role === 'user' && Array.isArray(meta?.attachments) && meta.attachments.length) {
|
if (msg.role === 'user' && Array.isArray(meta?.attachments) && meta.attachments.length) {
|
||||||
const cards = document.createElement('div');
|
if (chatRenderer.buildAttachCards) {
|
||||||
cards.className = 'attach-cards history-attach-cards';
|
body.appendChild(chatRenderer.buildAttachCards(meta.attachments));
|
||||||
for (const att of meta.attachments) {
|
|
||||||
const card = document.createElement('div');
|
|
||||||
card.className = 'attach-card history-attach-card';
|
|
||||||
const icon = document.createElement('span');
|
|
||||||
icon.className = 'attach-card-icon';
|
|
||||||
icon.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>';
|
|
||||||
const name = document.createElement('span');
|
|
||||||
name.className = 'attach-card-name';
|
|
||||||
name.textContent = att.name || 'Image attached';
|
|
||||||
const size = document.createElement('span');
|
|
||||||
size.className = 'attach-card-size';
|
|
||||||
size.textContent = 'image';
|
|
||||||
card.appendChild(icon);
|
|
||||||
card.appendChild(name);
|
|
||||||
card.appendChild(size);
|
|
||||||
cards.appendChild(card);
|
|
||||||
}
|
}
|
||||||
body.appendChild(cards);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap.appendChild(roleEl);
|
wrap.appendChild(roleEl);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue