UNPKG

@maximai/maxim-js

Version:

Maxim AI JS SDK. Visit https://getmaxim.ai for more info.

48 lines (47 loc) 2.09 kB
import type OpenAI from "openai"; import type { ChatCompletionMessage, CompletionRequest } from "../../models/prompt"; import type { ChatCompletionResult } from "../components/generation"; type ChatCompletionMessageParam = OpenAI.Chat.Completions.ChatCompletionMessageParam; type ChatCompletion = OpenAI.Chat.Completions.ChatCompletion; type ChatCompletionChunk = OpenAI.Chat.Completions.ChatCompletionChunk; /** * Utility functions for OpenAI integration with Maxim logging. */ export declare class OpenAIUtils { /** * Parse OpenAI message params to Maxim's message format. */ static parseMessageParam(messages: ChatCompletionMessageParam[], overrideRole?: string): (CompletionRequest | ChatCompletionMessage)[]; /** * Extract model parameters from OpenAI request options. */ static getModelParams(options: Record<string, any>): Record<string, any>; /** * Parse a non-streaming ChatCompletion response to Maxim's result format. */ static parseCompletion(completion: ChatCompletion): ChatCompletionResult; /** * Parse streaming chunks into a combined ChatCompletionResult. */ static parseCompletionFromChunks(chunks: ChatCompletionChunk[]): ChatCompletionResult; /** * Extract combined text content from streaming chunks. */ static extractTextFromChunks(chunks: ChatCompletionChunk[]): string; /** * Parse Responses API input to generation messages format. * Handles both simple string inputs and complex ResponseInputParam arrays. */ static parseResponsesInputToMessages(inputValue: any): (CompletionRequest | ChatCompletionMessage)[]; /** * Extract model parameters from Responses API request options. * Skips input, extra_headers, and model. */ static getResponsesModelParams(options: Record<string, any>): Record<string, any>; /** * Extract text output from a Responses API response. * Returns the output_text property if available, or null. */ static extractResponsesOutputText(response: any): string | null; } export {};