Theia API Documentation v1.76.0
    Preparing search index...

    Utility class for handling OpenAI Response API requests and tool calling cycles.

    This class encapsulates the complexity of the Response API's multi-turn conversation patterns for tool calling, keeping the main language model class clean and focused.

    Index

    Constructors

    Properties

    logger: ILogger
    reasoningSummaryRejectedModels: Set<string> = ...

    Model ids whose organization rejected reasoning.summary (OpenAI requires a verified organization for summaries). Later requests to these models omit the field.

    Methods

    • Returns true and remembers the rejection when error is the 400 an unverified organization gets for reasoning.summary, so the request can be sent once more without it.

      Parameters

      • error: unknown
      • sentSettings: Record<string, unknown>
      • modelId: string

      Returns boolean

    • Processes the provided list of messages by applying system message adjustments and converting them directly to the format expected by the OpenAI Response API.

      This method converts messages directly without going through ChatCompletionMessageParam types.

      Parameters

      • messages: LanguageModelMessage[]

        the list of messages to process.

      • developerMessageSettings: DeveloperMessageSettings

        how system and developer messages are handled during processing.

      • model: string

        the OpenAI model identifier. Currently not used, but allows subclasses to implement model-specific behavior.

      Returns { input: ResponseInputItem[]; instructions?: string }

      an object containing instructions and input formatted for the Response API.

    • Sends a Responses API request, retrying once without reasoning.summary if the organization is not allowed to request it.

      Type Parameters

      • T

      Parameters

      • settings: Record<string, unknown>
      • modelId: string
      • send: (settings: Record<string, unknown>) => Promise<T>

      Returns Promise<T>

    • Streaming counterpart of sendWithReasoningSummaryFallback. The rejection arrives before any event, so nothing is emitted twice.

      Parameters

      • settings: Record<string, unknown>
      • modelId: string
      • open: (settings: Record<string, unknown>) => AsyncIterable<ResponseStreamEvent>

      Returns AsyncIterable<ResponseStreamEvent>