CallbackHandler class to be used with callbacks provided by user in requests. Manages request and response lifecycle callbacks for API operations.

CallbackHandler

Constructors

Properties

requestCallback: undefined | WatsonXAI.InvokeRequestCallback

Callback function to be invoked before sending a request.

responseCallback: undefined | WatsonXAI.ReceiveResponseCallback<any>

Callback function to be invoked after receiving a response.

Methods

  • Handles the request callback by invoking it with sanitized parameters. Removes headers from the parameters before passing to the callback.

    Parameters

    Returns void

  • Handles the response callback by invoking it with the resolved response. Waits for the response promise to resolve before invoking the callback.

    Type Parameters

    • T

      The type of the response

    Parameters

    • response: Promise<T>

      The response promise to handle

    Returns Promise<void>

    A promise that resolves when the callback completes