char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Linting & Formatting scripts (#26819)92d1bb0c9

char/aliceai-t5-moe
769 B23 linesraw
1import { NEWLINE } from '$lib/constants';
2
3/**
4 * Returns a shortened preview of the provided content capped at the given length.
5 * Appends an ellipsis when the content exceeds the maximum.
6 */
7export function getPreviewText(content: string, max = 150): string {
8	return content.length > max ? content.slice(0, max) + '...' : content;
9}
10
11/**
12 * Generates a single-line title from a potentially multi-line prompt.
13 * Uses the first non-empty line if `useFirstLine` is true.
14 */
15export function generateConversationTitle(content: string, useFirstLine: boolean = false): string {
16	if (useFirstLine) {
17		const firstLine = content.split(NEWLINE).find((line) => line.trim().length > 0);
18
19		return firstLine ? firstLine.trim() : content.trim();
20	}
21
22	return content.trim();
23}