Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
chat-form-enter-code-block.svelte.test.ts125 linesDownload Raw Back to client
1// Guards the Enter-key contract of the chat form against the2// fenced-code-block flow: while the caret sits inside a fenced3// block region - closed, or still OPEN while the user is typing4// one - plain Enter adds a line instead of submitting the message.5// The textarea path is covered here end-to-end (the contenteditable6// consumes the same case locally; see chat-form-contenteditable).7 8import ChatFormTestWrapper from './components/ChatFormTestWrapper.svelte';9import { SETTINGS_KEYS } from '$lib/constants/settings-keys';10import { settingsStore } from '$lib/stores/settings.svelte';11import { tick } from 'svelte';12import { beforeEach, describe, expect, it, vi } from 'vitest';13import { userEvent } from 'vitest/browser';14import { render } from 'vitest-browser-svelte';15 16function textareaIn(container: HTMLElement): HTMLTextAreaElement {17	const el = container.querySelector('textarea');18 19	if (!(el instanceof HTMLTextAreaElement)) throw new Error('textarea not rendered');20 21	return el;22}23 24describe('ChatForm Enter in code blocks', () => {25	beforeEach(() => {26		settingsStore.updateConfig(SETTINGS_KEYS.SEND_ON_ENTER, true);27	});28 29	it('adds a line after a still-open fence instead of submitting', async () => {30		const onSubmit = vi.fn();31		const { container } = render(ChatFormTestWrapper, { onSubmit });32 33		await tick();34 35		const textarea = textareaIn(container);36 37		await userEvent.click(textarea);38		await userEvent.keyboard('```');39		await tick();40 41		await userEvent.keyboard('{Enter}');42		await tick();43 44		expect(onSubmit).not.toHaveBeenCalled();45		expect(textarea.value).toBe('```\n');46	});47 48	it('keeps adding lines while the block stays open', async () => {49		const onSubmit = vi.fn();50		const { container } = render(ChatFormTestWrapper, { onSubmit });51 52		await tick();53 54		const textarea = textareaIn(container);55 56		await userEvent.click(textarea);57		await userEvent.keyboard('```js');58		await tick();59 60		await userEvent.keyboard('{Enter}');61		await userEvent.keyboard('const a = 1;');62		await userEvent.keyboard('{Enter}');63		await tick();64 65		expect(onSubmit).not.toHaveBeenCalled();66		expect(textarea.value).toBe('```js\nconst a = 1;\n');67	});68 69	it('submits when the caret is before the opening fence', async () => {70		const onSubmit = vi.fn();71		const { container } = render(ChatFormTestWrapper, { onSubmit });72 73		await tick();74 75		const textarea = textareaIn(container);76 77		await userEvent.click(textarea);78		await userEvent.keyboard('```');79		await tick();80 81		textarea.setSelectionRange(0, 0);82 83		await userEvent.keyboard('{Enter}');84		await tick();85 86		expect(onSubmit).toHaveBeenCalledTimes(1);87	});88 89	it('submits on Enter outside a code block', async () => {90		const onSubmit = vi.fn();91		const { container } = render(ChatFormTestWrapper, { onSubmit });92 93		await tick();94 95		const textarea = textareaIn(container);96 97		await userEvent.click(textarea);98		await userEvent.keyboard('hello');99		await tick();100 101		await userEvent.keyboard('{Enter}');102		await tick();103 104		expect(onSubmit).toHaveBeenCalledTimes(1);105	});106 107	it('submits on Ctrl+Enter even inside a code block', async () => {108		const onSubmit = vi.fn();109		const { container } = render(ChatFormTestWrapper, { onSubmit });110 111		await tick();112 113		const textarea = textareaIn(container);114 115		await userEvent.click(textarea);116		await userEvent.keyboard('```');117		await tick();118 119		await userEvent.keyboard('{Control>}{Enter}{/Control}');120		await tick();121 122		expect(onSubmit).toHaveBeenCalledTimes(1);123	});124});125 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai