Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Thomas G. Lopes
commited on
Commit
·
28afdf5
1
Parent(s):
00d40c6
fix msg layout
Browse files
src/lib/components/inference-playground/message.svelte
CHANGED
|
@@ -117,63 +117,64 @@
|
|
| 117 |
{message?.role}
|
| 118 |
</div>
|
| 119 |
|
| 120 |
-
<div class="flex w-full
|
| 121 |
-
<!--
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
| 143 |
</div>
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
:
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
{/if}
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
{/if}
|
| 174 |
|
| 175 |
-
|
| 176 |
-
<div class="flex w-full gap-4">
|
| 177 |
{#if conversation.data.parseMarkdown && message?.role === "assistant"}
|
| 178 |
<div
|
| 179 |
class="relative max-w-none grow rounded-lg bg-transparent px-2 py-2.5 ring-gray-100 outline-none group-hover/message:ring-3 hover:bg-white @2xl:px-3 dark:ring-gray-600 dark:hover:bg-gray-900"
|
|
@@ -256,6 +257,7 @@
|
|
| 256 |
></textarea>
|
| 257 |
{/if}
|
| 258 |
</div>
|
|
|
|
| 259 |
<!-- Sticky wrapper for action buttons -->
|
| 260 |
<div
|
| 261 |
class={[
|
|
@@ -360,40 +362,40 @@
|
|
| 360 |
</div>
|
| 361 |
</div>
|
| 362 |
</div>
|
|
|
|
| 363 |
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
</div>
|
| 398 |
</div>
|
| 399 |
</div>
|
|
|
|
| 117 |
{message?.role}
|
| 118 |
</div>
|
| 119 |
|
| 120 |
+
<div class="flex w-full gap-4">
|
| 121 |
+
<!-- Content column (reasoning + main content) -->
|
| 122 |
+
<div class="flex w-full flex-col gap-2">
|
| 123 |
+
<!-- Reasoning section (if present) -->
|
| 124 |
+
{#if parsedMessage.thinking && message?.role === "assistant"}
|
| 125 |
+
<div class="flex w-full flex-col gap-2">
|
| 126 |
+
<button
|
| 127 |
+
onclick={() => (isReasoningExpanded = !isReasoningExpanded)}
|
| 128 |
+
class="flex items-center gap-2 self-start rounded-md px-2 py-1 text-sm font-medium text-gray-600 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"
|
| 129 |
+
>
|
| 130 |
+
{#if isReasoningExpanded}
|
| 131 |
+
<IconChevronDown class="size-4" />
|
| 132 |
+
{:else}
|
| 133 |
+
<IconChevronRight class="size-4" />
|
| 134 |
+
{/if}
|
| 135 |
+
Reasoning
|
| 136 |
+
</button>
|
| 137 |
|
| 138 |
+
{#if isReasoningExpanded}
|
| 139 |
+
{#if conversation.data.parseMarkdown && !isEditing}
|
| 140 |
+
<div
|
| 141 |
+
class="relative w-full max-w-none rounded-lg bg-transparent px-2 py-2.5 ring-gray-100 outline-none group-hover/message:ring-3 hover:bg-white @2xl:px-3 dark:ring-gray-600 dark:hover:bg-gray-900"
|
| 142 |
+
>
|
| 143 |
+
<div class="prose prose-sm dark:prose-invert">
|
| 144 |
+
{@html parsedReasoning}
|
| 145 |
+
</div>
|
| 146 |
</div>
|
| 147 |
+
{:else}
|
| 148 |
+
<textarea
|
| 149 |
+
value={parsedMessage.thinking}
|
| 150 |
+
onchange={e => {
|
| 151 |
+
const el = e.target as HTMLTextAreaElement;
|
| 152 |
+
const reasoningContent = el?.value ?? "";
|
| 153 |
+
if (!message) return;
|
| 154 |
+
// Reconstruct the full message with updated reasoning
|
| 155 |
+
const newContent = reasoningContent
|
| 156 |
+
? `<think>${reasoningContent}</think>\n\n${parsedMessage.content}`
|
| 157 |
+
: parsedMessage.content;
|
| 158 |
+
conversation.updateMessage({ index, message: { ...message, content: newContent } });
|
| 159 |
+
}}
|
| 160 |
+
onkeydown={e => {
|
| 161 |
+
if ((e.ctrlKey || e.metaKey) && e.key === "g") {
|
| 162 |
+
e.preventDefault();
|
| 163 |
+
e.stopPropagation();
|
| 164 |
+
onRegen?.();
|
| 165 |
+
}
|
| 166 |
+
}}
|
| 167 |
+
placeholder="Enter reasoning content"
|
| 168 |
+
class="w-full resize-none overflow-hidden rounded-lg bg-transparent px-2 py-2.5 ring-gray-100 outline-none group-hover/message:ring-3 hover:bg-white focus:bg-white focus:ring-3 @2xl:px-3 dark:ring-gray-600 dark:hover:bg-gray-900 dark:focus:bg-gray-900"
|
| 169 |
+
rows="1"
|
| 170 |
+
{@attach reasoningAutosized.attachment}
|
| 171 |
+
></textarea>
|
| 172 |
+
{/if}
|
| 173 |
{/if}
|
| 174 |
+
</div>
|
| 175 |
+
{/if}
|
|
|
|
| 176 |
|
| 177 |
+
<!-- Main content section -->
|
|
|
|
| 178 |
{#if conversation.data.parseMarkdown && message?.role === "assistant"}
|
| 179 |
<div
|
| 180 |
class="relative max-w-none grow rounded-lg bg-transparent px-2 py-2.5 ring-gray-100 outline-none group-hover/message:ring-3 hover:bg-white @2xl:px-3 dark:ring-gray-600 dark:hover:bg-gray-900"
|
|
|
|
| 257 |
></textarea>
|
| 258 |
{/if}
|
| 259 |
</div>
|
| 260 |
+
|
| 261 |
<!-- Sticky wrapper for action buttons -->
|
| 262 |
<div
|
| 263 |
class={[
|
|
|
|
| 362 |
</div>
|
| 363 |
</div>
|
| 364 |
</div>
|
| 365 |
+
</div>
|
| 366 |
|
| 367 |
+
<div class="mt-2">
|
| 368 |
+
<div class="flex items-center gap-2">
|
| 369 |
+
{#each message.images ?? [] as imgKey (imgKey)}
|
| 370 |
+
{#await images.get(imgKey)}
|
| 371 |
+
<!-- nothing -->
|
| 372 |
+
{:then imgSrc}
|
| 373 |
+
<div class="group/img relative">
|
| 374 |
+
<button
|
| 375 |
+
aria-label="expand"
|
| 376 |
+
class="absolute inset-0 z-10 grid place-items-center bg-gray-800/70 opacity-0 group-hover/img:opacity-100"
|
| 377 |
+
onclick={() => previewImage(imgSrc)}
|
| 378 |
+
>
|
| 379 |
+
<IconMaximize />
|
| 380 |
+
</button>
|
| 381 |
+
<img src={imgSrc} alt="uploaded" class="size-12 rounded-md object-cover" />
|
| 382 |
+
<button
|
| 383 |
+
aria-label="remove"
|
| 384 |
+
type="button"
|
| 385 |
+
onclick={async e => {
|
| 386 |
+
e.stopPropagation();
|
| 387 |
+
await conversation.updateMessage({
|
| 388 |
+
index,
|
| 389 |
+
message: { images: message.images?.filter(i => i !== imgKey) },
|
| 390 |
+
});
|
| 391 |
+
images.delete(imgKey);
|
| 392 |
+
}}
|
| 393 |
+
class="invisible absolute -top-1 -right-1 z-20 grid size-5 place-items-center rounded-full bg-gray-800 text-xs text-white group-hover/img:visible hover:bg-gray-700"
|
| 394 |
+
>
|
| 395 |
+
✕
|
| 396 |
+
</button>
|
| 397 |
+
</div>
|
| 398 |
+
{/await}
|
| 399 |
+
{/each}
|
|
|
|
| 400 |
</div>
|
| 401 |
</div>
|