char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
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 { 8return 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 { 16if ( useFirstLine ) { 17const firstLine = content . split ( NEWLINE ). find (( line ) => line . trim (). length > 0 ); 18 19return firstLine ?firstLine . trim () :content . trim (); 20} 21 22return content . trim (); 23}