/
vshmidt
/
llama.cpp
Обзор
Документация
Войти
/
vshmidt
/
llama.cpp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tools/server/webui/src/lib/utils/text.ts
22 строки
788 B
Rohan Jain
webui: add setting for first-line chat titles (#21797)
13 апр 2026, 10:30
Не верифицирован
13 апр 2026, 10:30
974c8c9
Код
Авторство
О чём код?
import { NEWLINE_SEPARATOR } from '$lib/constants'; /** * Returns a shortened preview of the provided content capped at the given length. * Appends an ellipsis when the content exceeds the maximum. */ export function getPreviewText(content: string, max = 150): string { return content.length > max ? content.slice(0, max) + '...' : content; } /** * Generates a single-line title from a potentially multi-line prompt. * Uses the first non-empty line if `useFirstLine` is true. */ export function generateConversationTitle(content: string, useFirstLine: boolean = false): string { if (useFirstLine) { const firstLine = content.split(NEWLINE_SEPARATOR).find((line) => line.trim().length > 0); return firstLine ? firstLine.trim() : content.trim(); } return content.trim(); }