UNPKG

@promptbook/remote-client

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

62 lines (61 loc) 1.88 kB
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 both: * - Full notation: `【5:13†document.pdf】` * - Simplified notation: `【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; /** * Deduplicates citations by source while preserving the first-seen order. * * @param citations - Parsed citations to deduplicate. * @returns Deduplicated citations in original order. * * @private utility for internal use */ export declare function dedupeCitationsBySource(citations: ReadonlyArray<ParsedCitation>): ParsedCitation[]; /** * 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;