Skip to content

Commit 059b2ae

Browse files
committed
Add audio remix
1 parent 64d3dd8 commit 059b2ae

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

llms/extensions/gallery/ui/index.mjs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ const GalleryPage = {
9090
</svg>
9191
</div>
9292
<div class="flex-1 min-w-0">
93-
<div class="flex justify-between items-baseline mb-1">
94-
<h3 class="text-gray-900 dark:text-white font-medium truncate pr-4">{{ item.name || 'Untitled' }}</h3>
93+
<div class="flex justify-between items-center mb-1">
94+
<h3 class="text-gray-900 dark:text-white font-medium truncate pr-4">{{ item.caption || item.prompt || 'Untitled' }}</h3>
9595
<span class="text-xs text-gray-500 shrink-0">{{ $fmt.formatDate(item.created) }}</span>
9696
</div>
97-
<div class="text-xs text-blue-600 dark:text-blue-300/80 mb-2">{{ item.model }}</div>
98-
<audio controls class="w-full h-8 opacity-90" :src="item.url"></audio>
97+
<div class="flex justify-between items-center mb-2">
98+
<div class="text-xs text-blue-600 dark:text-blue-300/80">{{ item.model }}</div>
99+
</div>
100+
<div class="flex items-center gap-2">
101+
<audio controls class="w-full h-8 opacity-90" :src="item.url"></audio>
102+
<button type="button" @click="remixAudio(item)" class="px-3 py-1 bg-fuchsia-700 text-white border border-fuchsia-600 hover:bg-fuchsia-600 hover:border-fuchsia-400 rounded-full text-[10px] font-bold uppercase tracking-wider shadow-lg shadow-fuchsia-500/10 hover:shadow-fuchsia-500/40 transition-all duration-200 shrink-0">
103+
Remix
104+
</button>
105+
</div>
99106
</div>
100107
</div>
101108
</div>
@@ -161,7 +168,7 @@ const GalleryPage = {
161168
<div>
162169
<div class="flex justify-between">
163170
<h3 class="text-xs uppercase tracking-widest text-gray-500 font-semibold mb-3">Prompt</h3>
164-
<button type="button" @click="remixPrompt" class="mb-2 px-3 py-1 bg-fuchsia-700 text-white border border-fuchsia-600 hover:bg-fuchsia-600 hover:border-fuchsia-400 rounded-full text-xs font-bold uppercase tracking-wider shadow-lg shadow-fuchsia-500/10 hover:shadow-fuchsia-500/40 transition-all duration-200">
171+
<button type="button" @click="remixImage" class="mb-2 px-3 py-1 bg-fuchsia-700 text-white border border-fuchsia-600 hover:bg-fuchsia-600 hover:border-fuchsia-400 rounded-full text-xs font-bold uppercase tracking-wider shadow-lg shadow-fuchsia-500/10 hover:shadow-fuchsia-500/40 transition-all duration-200">
165172
Remix
166173
</button>
167174
</div>
@@ -361,10 +368,8 @@ const GalleryPage = {
361368
if (e.key === 'Escape') closeLightbox()
362369
}
363370

364-
function remixPrompt() {
371+
function remixImage() {
365372
const selected = lightboxItem.value
366-
console.log(ctx.state.selectedAspectRatio)
367-
console.log(JSON.stringify(selected, null, 2))
368373
closeLightbox()
369374
ctx.chat.setSelectedModel(ctx.chat.getModel(selected.model))
370375
ctx.chat.messageText.value = selected.prompt
@@ -375,6 +380,18 @@ const GalleryPage = {
375380
})
376381
}
377382

383+
function remixAudio(item) {
384+
const selected = item || lightboxItem.value
385+
if (lightboxItem.value) closeLightbox()
386+
387+
ctx.chat.setSelectedModel(ctx.chat.getModel(selected.model))
388+
ctx.chat.messageText.value = selected.prompt
389+
ctx.threads.startNewThread({
390+
title: selected.prompt,
391+
model: ctx.chat.getSelectedModel(),
392+
})
393+
}
394+
378395
return {
379396
ext,
380397
items,
@@ -394,7 +411,8 @@ const GalleryPage = {
394411
prevItem,
395412
hasNext,
396413
hasPrev,
397-
remixPrompt,
414+
remixImage,
415+
remixAudio,
398416
}
399417
}
400418
}

0 commit comments

Comments
 (0)