Spaces:
Runtime error
Runtime error
loading state
Browse files14 unmodified lines15161718192021222324252625 unmodified lines52535455565758596061626364656667682 unmodified lines717273747576777879808136 unmodified lines11811912012112212312412512614 unmodified lines'mistralai/Mistral-7B-Instruct-v0.3'];let hfToken: string | null;let currentModel = compatibleModels[0];let systemMessage: Message = { role: 'system', content: '' };let messages: Message[] = startMessages;function addMessage() {messages = [...messages,25 unmodified lineshfToken = token;}(document.activeElement as HTMLElement).blur();const hf = new HfInference(hfToken);const out = await hf.chatCompletion({model: currentModel,messages: systemMessage.content ? [systemMessage, ...messages] : messages,max_tokens: 500,temperature: 0.1,seed: 0});messages = [...messages, ...out.choices.map((o) => o.message)];}$: console.log(messages);2 unmodified lines<svelte:window on:keydown={onKeydown} /><divclass="grid h-dvh divide-gray-200 overflow-hidden max-md:grid-cols-1 max-md:divide-y md:grid-cols-[260px,1fr,260px] md:divide-x"><div class="relative flex flex-col overflow-y-auto p-5 pb-24"><div class="pb-2 text-sm font-semibold">SYSTEM</div><textareaname=""id=""placeholder="Enter a custom prompt"36 unmodified lines<buttonon:click={submit}type="button"class="rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700">Submit</button></div></div><div class="flex flex-col gap-6 p-5">14 unmodified lines1516171819202122232425262725 unmodified lines53545556575859606162636465666768697071727374752 unmodified lines78798081828384858687888936 unmodified lines12612712812913013113213313413513613713813914014114214314414514614714814915015115214 unmodified lines'mistralai/Mistral-7B-Instruct-v0.3'];let hfToken: string | null = '';let currentModel = compatibleModels[0];let systemMessage: Message = { role: 'system', content: '' };let messages: Message[] = startMessages;let loading = false;function addMessage() {messages = [...messages,25 unmodified lineshfToken = token;}(document.activeElement as HTMLElement).blur();loading = true;try {const hf = new HfInference(hfToken);const out = await hf.chatCompletion({model: currentModel,messages: systemMessage.content ? [systemMessage, ...messages] : messages,max_tokens: 500,temperature: 0.1,seed: 0});messages = [...messages, ...out.choices.map((o) => o.message)];} catch (error) {alert('error: ' + error.message);}loading = false;}$: console.log(messages);2 unmodified lines<svelte:window on:keydown={onKeydown} /><divclass="grid h-dvh max-h-dvh divide-gray-200 overflow-hidden max-md:grid-cols-1 max-md:divide-y md:grid-cols-[260px,1fr,260px] md:divide-x"><div class="relative flex flex-col overflow-y-auto p-5 pb-24"><div class="pb-2 text-sm font-semibold">SYSTEM</div><textareadisabledname=""id=""placeholder="Enter a custom prompt"36 unmodified lines<buttonon:click={submit}type="button"class="flex h-[42px] w-24 items-center justify-center rounded-lg bg-black px-5 py-2.5 text-sm font-medium text-white hover:bg-gray-900 focus:outline-none focus:ring-4 focus:ring-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700">{#if loading}<div class="flex flex-none items-center gap-[3px]"><divclass="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-400"style="animation-delay: 0.25s;"/><divclass="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-400"style="animation-delay: 0.5s;"/><divclass="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-400"style="animation-delay: 0.75s;"/></div>{:else}Submit{/if}</button></div></div><div class="flex flex-col gap-6 p-5">
src/lib/components/Playground/Playground.svelte+42-16