Spaces:
Runtime error
Runtime error
Added automatic scrolling to bottom of message container when new messages are added.
Browse files83 unmodified lines848586878889909 unmodified lines1001011021031041051061 unmodified line10810911011111211311411511611711811912012112212312412512612712812913083 unmodified lines out += chunk.choices[0].delta.content; streamingMessage.content = out; messages = [...messages]; scrollToBottom(); } } }9 unmodified lines if (response.choices && response.choices.length > 0) { const newMessage = { role: 'assistant', content: response.choices[0].message.content }; messages = [...messages, newMessage]; scrollToBottom(); } } } catch (error) {1 unmodified line } finally { loading = false; streamingMessage = null; scrollToBottom(); } }
$: console.log(messages);
function scrollToBottom() { if (messageContainer) { messageContainer.scrollTop = messageContainer.scrollHeight; } }
$: { if (messages) { scrollToBottom(); } }</script>
<svelte:window on:keydown={onKeydown} />src/lib/components/Playground/Playground.svelte+15