public static String getText(GenerateContentResponse response) {
    checkFinishReason(getFinishReason(response));

    String text = "";
    List<Part> parts = response.getCandidates(0).getContent().getPartsList();
    for (Part part : parts) {
      text += part.getText();
    }

    return text;
  }
Gets the text message in a GenerateContentResponse.

@param response a {@link com.google.cloud.vertexai.api.GenerateContentResponse} instance
@return a String that aggregates all the text parts in the response
@throws IllegalArgumentException if the response has 0 or more than 1 candidates, or if the
    response is blocked by safety reason or unauthorized citations
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ResponseHandler.java