@promptbook/utils
Version:
Promptbook: Turn your company's scattered knowledge into AI ready books
54 lines (53 loc) • 1.53 kB
TypeScript
import type { ChatMessage } from '../types/ChatMessage';
/**
* Type representing a parsed citation from RAG sources
*/
export type ParsedCitation = {
/**
* The unique identifier for the citation (e.g., "5:13")
*/
id: string;
/**
* The source document name (e.g., "document.pdf")
*/
source: string;
/**
* Optional URL to the source document
*/
url?: string;
/**
* Optional preview/excerpt from the source
*/
excerpt?: string;
};
/**
* Parses OpenAI Assistant-style citations from message content
* Matches patterns like: 【5:13†document.pdf】
*
* @param content - The markdown content that may contain citations
* @returns Array of parsed citations
*
* @private utility for internal use
*/
export declare function parseCitationsFromContent(content: string): ParsedCitation[];
/**
* Removes citation markers from content and returns clean text
*
* @param content - The markdown content with citations
* @returns Content with citation markers removed
*
* @private utility for internal use
*/
export declare function stripCitationsFromContent(content: string): string;
/**
* Extracts citations from a chat message if not already present
*
* @param message - The chat message to extract citations from
* @returns The message with citations array populated
*
* @private utility for internal use
*/
export declare function extractCitationsFromMessage(message: ChatMessage): ChatMessage;
/**
* TODO: Maybe spread into multiple files
*/