Function getTextOfResponse

  • Retrieves the text content from a LanguageModelResponse object.

    Important: For stream responses, the stream can only be consumed once. Calling this function multiple times on the same stream response will return an empty string ('') on subsequent calls, as the stream will have already been consumed.

    Parameters

    Returns Promise<string>

    • A promise that resolves to the text content of the response.

    Throws

    • Throws an error if the response type is not supported or does not contain valid text content.