/** * Utilities for parsing OpenAI response items into Entry objects and formatting them. * * It provides: * - Entry: a record of role and content. * - parseResponseItems: flatten responses into entries with optional filtering. * - formatEntries: render entries as JSON or plain text. */ import type { OpenAI } from 'openai'; /** * Parsed text entry with role metadata. */ export interface Entry { /** The role of the message (e.g., 'user', 'assistant'). */ role: string; /** The content of the message. */ content: string; } /** * Type aliases for OpenAI response types. */ export type TResponse = OpenAI.Completions.Completion | OpenAI.Chat.Completions.ChatCompletion | OpenAI.Chat.Completions.ChatCompletionChunk | OpenAI.Responses.Response; export type TResponseInputItem = OpenAI.Chat.Completions.ChatCompletionMessageParam; export type TResponseOutputItem = OpenAI.Chat.Completions.ChatCompletionMessage; export type TResponseStreamEvent = OpenAI.Chat.Completions.ChatCompletionChunk; /** * Parse response items into Entry objects. * * @param response - The response to parse. * @param filterFn - Optional filter function for entries. * @returns Array of parsed entries. */ export declare function parseResponseItems(response: TResponse, filterFn?: (entry: Entry) => boolean): Entry[]; /** * Parse response items as JSON. * * @param response - The response to parse. * @returns Array of parsed entries. */ export declare function parseResponseItemsAsJson(response: TResponse): Entry[]; /** * Format entries as JSON. * * @param entries - The entries to format. * @returns JSON string representation. */ export declare function formatEntriesAsJson(entries: Entry[]): string; /** * Format entries as plain text. * * @param entries - The entries to format. * @returns Plain text representation. */ export declare function formatEntriesAsText(entries: Entry[]): string; /** * Format entries in the specified format. * * @param entries - The entries to format. * @param format - The format to use ('json' or 'text'). * @param options - Formatting options. * @returns Formatted string representation. */ export declare function formatEntries(entries: Entry[], format?: 'json' | 'text'): string; /** * Extract text content from a response. * * @param response - The response to extract text from. * @returns Extracted text content. */ export declare function extractTextContent(response: TResponse): string; /** * Extract JSON content from a response. * * @param response - The response to extract JSON from. * @returns Extracted JSON content or null if parsing fails. */ export declare function extractJsonContent(response: TResponse): Record | null; //# sourceMappingURL=parsing.d.ts.map