/** * OpenAI-specific message builders for OTel gen_ai attributes. * * OpenAI's API has a different structure from block-based providers: * - Input messages have typed content parts (user only), but system/developer/tool * messages need special handling * - Response messages are flat (content is string, tool_calls/refusal/audio are separate fields) * * These builders convert OpenAI SDK shapes into OTel-shaped objects, * which are then serialized by the shared serializers in instrumentation-utils. */ interface OTelChatMessage { role: string; parts: object[]; } interface OTelOutputMessage { role: string; finish_reason: string; parts: object[]; } /** * Maps OpenAI-specific finish reasons to OTel standard values. */ export declare const openaiFinishReasonMap: Record; /** * Converts OpenAI SDK request messages into OTel-shaped input messages. * * Per the OTel spec: "Instructions that are part of the chat history SHOULD be * recorded in gen_ai.input.messages attribute instead [of gen_ai.system_instructions]." * * OpenAI puts system/developer messages IN the chat history (messages array), * not as a separate parameter, so they stay in gen_ai.input.messages. * * @param messages - The messages array from the OpenAI chat completion request * @returns Array of OTel-shaped chat messages */ export declare function buildOpenAIInputMessages(messages: any[]): OTelChatMessage[]; /** * Assembles an OTel output message from OpenAI's flat response fields. * * OpenAI's ChatCompletionMessage has: * content: string | null → TextPart * refusal: string | null → GenericPart {type: "refusal"} * tool_calls: ToolCall[] → ToolCallRequestPart[] * audio: {data, transcript} → BlobPart {modality: "audio"} * function_call: {name, args} → ToolCallRequestPart (deprecated) * * @param choice - A single ChatCompletion.Choice * @param finishReasonMap - Mapping of OpenAI finish reasons to OTel standard values * @returns Array with a single OTelOutputMessage */ export declare function buildOpenAIOutputMessage(choice: any, finishReasonMap: Record): OTelOutputMessage[]; /** * Assembles an OTel output message from an OpenAI text completion response. * * @param choice - A single Completion.Choice (has .text and .finish_reason) * @param finishReasonMap - Mapping of OpenAI finish reasons to OTel standard values * @returns Array with a single OTelOutputMessage */ export declare function buildOpenAICompletionOutputMessage(choice: any, finishReasonMap: Record): OTelOutputMessage[]; export {}; //# sourceMappingURL=message-helpers.d.ts.map