@promptbook/google
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
48 lines (47 loc) • 1.84 kB
TypeScript
/**
* Options that customize how streaming message content is sanitized.
*/
type SanitizeStreamingMessageContentOptions = {
/**
* Whether the chat message has finished streaming.
*/
isComplete?: boolean;
};
type FenceDelimiter = '```' | '~~~';
type CodeFenceStreamingBoundary = {
readonly kind: 'codeFence';
readonly index: number;
readonly delimiter: FenceDelimiter;
};
type MathStreamingBoundary = {
readonly kind: 'math';
readonly index: number;
};
type ImagePromptStreamingBoundary = {
readonly kind: 'imagePrompt';
readonly index: number;
};
/**
* Metadata describing the most-recently introduced rich feature that is still streaming.
*
* @private internal helper of <ChatMessageItem/>
*/
export type StreamingFeatureBoundary = CodeFenceStreamingBoundary | MathStreamingBoundary | ImagePromptStreamingBoundary;
/**
* Examines the latest streaming feature boundary so rich placeholders can be rendered while content is still being produced.
*
* @param content - Message text that may still be streaming.
* @returns Metadata describing the richest streaming feature or `null` when nothing is being hidden.
* @private internal helper of <ChatMessageItem/>
*/
export declare function getLatestStreamingFeatureBoundary(content: string): StreamingFeatureBoundary | null;
/**
* Trims trailing rich-feature markup from streaming messages so users do not see the raw source while the feature loads.
*
* @param content - Full markdown text produced by the assistant.
* @param options - Sanitization options (streaming state).
* @returns Text that is safe to render during streaming.
* @private internal helper of <ChatMessageItem/>
*/
export declare function sanitizeStreamingMessageContent(content: string, options?: SanitizeStreamingMessageContentOptions): string;
export {};