Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,179 Bytes
b2ecf7d 94753b6 3f534ed b2ecf7d 02898cb b2ecf7d 3f534ed b2ecf7d 3f534ed efa0b5c b2ecf7d 7026e84 94753b6 b2ecf7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<script lang="ts">
import { afterUpdate } from "svelte";
import { isFullyScrolled, scrollToMax } from "../../../../utils/ViewUtils.js";
import WidgetOutputConvoBubble from "../WidgetOuputConvoBubble/WidgetOutputConvoBubble.svelte";
import type { ChatMessage } from "@huggingface/tasks";
import { widgetStates } from "../../stores.js";
export let modelId: string;
export let messages: ChatMessage[];
let wrapperEl: HTMLElement;
$: isMaximized = $widgetStates?.[modelId]?.isMaximized;
afterUpdate(() => {
if (wrapperEl && !isFullyScrolled(wrapperEl)) {
scrollToMax(wrapperEl);
}
});
</script>
<div
bind:this={wrapperEl}
class="overflow-y-auto rounded-t-lg border border-b-0 leading-tight {isMaximized ? 'flex-1' : 'h-64'}"
>
<div class="p-3 pt-6 text-center text-sm text-gray-400 text-balance">
Input a message to start chatting with
<strong>{modelId}</strong>.
</div>
<div class="flex flex-col items-end space-y-4 p-3">
{#each messages as message}
{@const position = message.role === "user" ? "right" : message.role === "assistant" ? "left" : "center"}
<WidgetOutputConvoBubble {position} text={message.content} />
{/each}
</div>
</div>
|