public static Part fromFunctionResponse(String name, Map<String, Object> response) {
    Struct.Builder structBuilder = Struct.newBuilder();
    response.forEach(
        (key, value) -> {
          if (value instanceof String) {
            String stringValue = (String) value;
            structBuilder.putFields(key, Value.newBuilder().setStringValue(stringValue).build());
          } else if (value instanceof Number) {
            // Convert a number to a double value since the proto only supports double.
            double doubleValue = ((Number) value).doubleValue();
            structBuilder.putFields(key, Value.newBuilder().setNumberValue(doubleValue).build());
          } else if (value instanceof Boolean) {
            Boolean boolValue = (Boolean) value;
            structBuilder.putFields(key, Value.newBuilder().setBoolValue(boolValue).build());
          } else if (value == null) {
            structBuilder.putFields(
                key, Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build());
          } else {
            throw new IllegalArgumentException(
                "The value in the map can only be one of the following format: "
                    + "String, Number, Boolean, null.");
          }
        });

    return Part.newBuilder()
        .setFunctionResponse(FunctionResponse.newBuilder().setName(name).setResponse(structBuilder))
        .build();
  }
Makes a {@link com.google.cloud.vertexai.api.Part} from the result output of {@link
com.google.cloud.vertexai.api.FunctionCall}.

@param name a string represents the name of the {@link
    com.google.cloud.vertexai.api.FunctionDeclaration}
@param response a map containing the output from the function call, supported output type:
    String, Double, Boolean, null
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/PartMaker.java