Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Thomas G. Lopes
commited on
Commit
·
1c8490e
1
Parent(s):
4148351
fix auto resize
Browse files
src/lib/components/inference-playground/message.svelte
CHANGED
|
@@ -28,11 +28,7 @@
|
|
| 28 |
const { index, conversation, message, autofocus, onDelete, onRegen }: Props = $props();
|
| 29 |
const isLast = $derived(index === conversation.data.messages.length - 1);
|
| 30 |
|
| 31 |
-
|
| 32 |
-
const autosized = new TextareaAutosize({
|
| 33 |
-
element: () => element,
|
| 34 |
-
input: () => message?.content ?? "",
|
| 35 |
-
});
|
| 36 |
const shouldStick = $derived(autosized.textareaHeight > 92);
|
| 37 |
|
| 38 |
const canUploadImgs = $derived(
|
|
@@ -99,7 +95,6 @@
|
|
| 99 |
</div>
|
| 100 |
<div class="flex w-full gap-4">
|
| 101 |
<textarea
|
| 102 |
-
bind:this={element}
|
| 103 |
value={message?.content}
|
| 104 |
onchange={e => {
|
| 105 |
const el = e.target as HTMLTextAreaElement;
|
|
@@ -112,6 +107,7 @@
|
|
| 112 |
rows="1"
|
| 113 |
data-message
|
| 114 |
{@attach autofocusAction(autofocus)}
|
|
|
|
| 115 |
></textarea>
|
| 116 |
|
| 117 |
<!-- Sticky wrapper for action buttons -->
|
|
|
|
| 28 |
const { index, conversation, message, autofocus, onDelete, onRegen }: Props = $props();
|
| 29 |
const isLast = $derived(index === conversation.data.messages.length - 1);
|
| 30 |
|
| 31 |
+
const autosized = new TextareaAutosize();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
const shouldStick = $derived(autosized.textareaHeight > 92);
|
| 33 |
|
| 34 |
const canUploadImgs = $derived(
|
|
|
|
| 95 |
</div>
|
| 96 |
<div class="flex w-full gap-4">
|
| 97 |
<textarea
|
|
|
|
| 98 |
value={message?.content}
|
| 99 |
onchange={e => {
|
| 100 |
const el = e.target as HTMLTextAreaElement;
|
|
|
|
| 107 |
rows="1"
|
| 108 |
data-message
|
| 109 |
{@attach autofocusAction(autofocus)}
|
| 110 |
+
{@attach autosized.attachment}
|
| 111 |
></textarea>
|
| 112 |
|
| 113 |
<!-- Sticky wrapper for action buttons -->
|
src/lib/data/context_length.json
CHANGED
|
@@ -225,9 +225,7 @@
|
|
| 225 |
"mistralai/Mistral-7B-Instruct-v0.1": 32768,
|
| 226 |
"Qwen/Qwen2.5-7B-Instruct-Turbo": 32768,
|
| 227 |
"Qwen/Qwen2.5-72B-Instruct-Turbo": 131072,
|
| 228 |
-
"meta-llama/Llama-3.3-70B-Instruct-Turbo": 131072,
|
| 229 |
"Qwen/QwQ-32B": 131072,
|
| 230 |
-
"meta-llama/Llama-3-70b-chat-hf": 8192,
|
| 231 |
"mistralai/Mixtral-8x7B-Instruct-v0.1": 32768,
|
| 232 |
"google/gemma-2-27b-it": 8192,
|
| 233 |
"Qwen/Qwen2-VL-72B-Instruct": 32768,
|
|
@@ -255,6 +253,7 @@
|
|
| 255 |
"arcee-ai/virtuoso-large": 131072,
|
| 256 |
"arcee-ai/virtuoso-medium-v2": 131072,
|
| 257 |
"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo": 131072,
|
|
|
|
| 258 |
"meta-llama/Llama-3-8b-chat-hf": 8192,
|
| 259 |
"mistralai/Mistral-Small-24B-Instruct-2501": 32768,
|
| 260 |
"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8": 1048576,
|
|
@@ -279,6 +278,8 @@
|
|
| 279 |
"meta-llama/Llama-Vision-Free": 131072,
|
| 280 |
"meta-llama/Llama-Guard-3-11B-Vision-Turbo": 131072,
|
| 281 |
"meta-llama/Llama-3.2-3B-Instruct-Turbo": 131072,
|
|
|
|
|
|
|
| 282 |
"meta-llama/Llama-2-70b-hf": 4096
|
| 283 |
},
|
| 284 |
"fireworks-ai": {
|
|
|
|
| 225 |
"mistralai/Mistral-7B-Instruct-v0.1": 32768,
|
| 226 |
"Qwen/Qwen2.5-7B-Instruct-Turbo": 32768,
|
| 227 |
"Qwen/Qwen2.5-72B-Instruct-Turbo": 131072,
|
|
|
|
| 228 |
"Qwen/QwQ-32B": 131072,
|
|
|
|
| 229 |
"mistralai/Mixtral-8x7B-Instruct-v0.1": 32768,
|
| 230 |
"google/gemma-2-27b-it": 8192,
|
| 231 |
"Qwen/Qwen2-VL-72B-Instruct": 32768,
|
|
|
|
| 253 |
"arcee-ai/virtuoso-large": 131072,
|
| 254 |
"arcee-ai/virtuoso-medium-v2": 131072,
|
| 255 |
"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo": 131072,
|
| 256 |
+
"meta-llama/Llama-3-70b-chat-hf": 8192,
|
| 257 |
"meta-llama/Llama-3-8b-chat-hf": 8192,
|
| 258 |
"mistralai/Mistral-Small-24B-Instruct-2501": 32768,
|
| 259 |
"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8": 1048576,
|
|
|
|
| 278 |
"meta-llama/Llama-Vision-Free": 131072,
|
| 279 |
"meta-llama/Llama-Guard-3-11B-Vision-Turbo": 131072,
|
| 280 |
"meta-llama/Llama-3.2-3B-Instruct-Turbo": 131072,
|
| 281 |
+
"arcee_ai/arcee-spotlight": 131072,
|
| 282 |
+
"meta-llama/Llama-3.3-70B-Instruct-Turbo": 131072,
|
| 283 |
"meta-llama/Llama-2-70b-hf": 4096
|
| 284 |
},
|
| 285 |
"fireworks-ai": {
|
src/lib/spells/textarea-autosize.svelte.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
| 1 |
-
import type { Getter } from "melt";
|
| 2 |
import { extract } from "./extract.svelte.js";
|
| 3 |
import { useResizeObserver, watch } from "runed";
|
| 4 |
import { onDestroy, tick } from "svelte";
|
|
|
|
|
|
|
| 5 |
|
| 6 |
export interface TextareaAutosizeOptions {
|
| 7 |
-
/** Textarea element to autosize. */
|
| 8 |
-
element: Getter<HTMLElement | undefined>;
|
| 9 |
-
/** Textarea content. */
|
| 10 |
-
input: Getter<string>;
|
| 11 |
/** Function called when the textarea size changes. */
|
| 12 |
onResize?: () => void;
|
| 13 |
/**
|
|
@@ -27,14 +24,14 @@ export class TextareaAutosize {
|
|
| 27 |
#resizeTimeout: number | null = null;
|
| 28 |
#hiddenTextarea: HTMLTextAreaElement | null = null;
|
| 29 |
|
| 30 |
-
element = $
|
| 31 |
-
input = $
|
| 32 |
styleProp = $derived.by(() => extract(this.#options.styleProp, "height"));
|
| 33 |
maxHeight = $derived.by(() => extract(this.#options.maxHeight, undefined));
|
| 34 |
textareaHeight = $state(0);
|
| 35 |
textareaOldWidth = $state(0);
|
| 36 |
|
| 37 |
-
constructor(options: TextareaAutosizeOptions) {
|
| 38 |
this.#options = options;
|
| 39 |
|
| 40 |
// Create hidden textarea for measurements
|
|
@@ -158,4 +155,17 @@ export class TextareaAutosize {
|
|
| 158 |
this.element.style[this.styleProp] = `${newHeight}px`;
|
| 159 |
}
|
| 160 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
}
|
|
|
|
|
|
|
| 1 |
import { extract } from "./extract.svelte.js";
|
| 2 |
import { useResizeObserver, watch } from "runed";
|
| 3 |
import { onDestroy, tick } from "svelte";
|
| 4 |
+
import type { Attachment } from "svelte/attachments";
|
| 5 |
+
import { on } from "svelte/events";
|
| 6 |
|
| 7 |
export interface TextareaAutosizeOptions {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
/** Function called when the textarea size changes. */
|
| 9 |
onResize?: () => void;
|
| 10 |
/**
|
|
|
|
| 24 |
#resizeTimeout: number | null = null;
|
| 25 |
#hiddenTextarea: HTMLTextAreaElement | null = null;
|
| 26 |
|
| 27 |
+
element = $state<HTMLTextAreaElement>();
|
| 28 |
+
input = $state("");
|
| 29 |
styleProp = $derived.by(() => extract(this.#options.styleProp, "height"));
|
| 30 |
maxHeight = $derived.by(() => extract(this.#options.maxHeight, undefined));
|
| 31 |
textareaHeight = $state(0);
|
| 32 |
textareaOldWidth = $state(0);
|
| 33 |
|
| 34 |
+
constructor(options: TextareaAutosizeOptions = {}) {
|
| 35 |
this.#options = options;
|
| 36 |
|
| 37 |
// Create hidden textarea for measurements
|
|
|
|
| 155 |
this.element.style[this.styleProp] = `${newHeight}px`;
|
| 156 |
}
|
| 157 |
};
|
| 158 |
+
|
| 159 |
+
attachment: Attachment<HTMLTextAreaElement> = node => {
|
| 160 |
+
this.element = node;
|
| 161 |
+
this.input = node.value;
|
| 162 |
+
const removeListener = on(node, "input", _ => {
|
| 163 |
+
this.input = node.value;
|
| 164 |
+
});
|
| 165 |
+
|
| 166 |
+
return () => {
|
| 167 |
+
removeListener();
|
| 168 |
+
this.element = undefined;
|
| 169 |
+
};
|
| 170 |
+
};
|
| 171 |
}
|