Content getContentFromFunctionCalls(List<FunctionCall> functionCalls) {
    checkNotNull(functionCalls, "functionCalls cannot be null.");

    List<Object> responseParts = new ArrayList<>();

    for (FunctionCall functionCall : functionCalls) {
      if (remainingFunctionCalls <= 0) {
        throw new IllegalStateException(
            "Exceeded the maximum number of continuous automatic function calls ("
                + maxFunctionCalls
                + "). If more automatic function calls are needed, please call"
                + " `setMaxFunctionCalls() to set a higher number. The last function call is:\n"
                + functionCall);
      }
      remainingFunctionCalls -= 1;
      String functionName = functionCall.getName();
      CallableFunction callableFunction = callableFunctions.get(functionName);
      if (callableFunction == null) {
        throw new IllegalArgumentException(
            "Model has asked to call function \"" + functionName + "\" which was not found.");
      }
      responseParts.add(
          PartMaker.fromFunctionResponse(
              functionName,
              Collections.singletonMap("result", callableFunction.call(functionCall.getArgs()))));
    }

    return ContentMaker.fromMultiModalData(responseParts.toArray());
  }
Automatically calls functions requested by the model and generates a Content that contains the
results.

@param functionCalls a list of {@link com.google.cloud.vertexai.api.FunctionCall} requested by
    the model
@return a {@link com.google.cloud.vertexai.api.Content} that contains the results of the
    function calls
@throws IllegalStateException if the number of automatic calls exceeds the maximum number of
    function calls
@throws IllegalArgumentException if the model has asked to call a function that was not found
    in the responder
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/AutomaticFunctionCallingResponder.java