zk-Armor's picture
download
raw
769 Bytes
import { NEWLINE } 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).find((line) => line.trim().length > 0);
return firstLine ? firstLine.trim() : content.trim();
}
return content.trim();
}

Xet Storage Details

Size:
769 Bytes
·
Xet hash:
322cc5e5b09b20c33282d0a048fbd35a1de51f0a3848af3c6c3ae626fddb4af6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.