<commit_before>var Multipart = require('multipart-stream');

/**
 * Create and make a request to the Google API
 * @param {object}   context  self from the context of the method calling this
 * @param {object}   params   parameters passed from the method call
 * @param {object}   options  options generated by the method call
 * @param {Boolean}  isMedia  whether the request requires media upload
 * @param {Function} callback Callback function
 */
function createAPIRequest(context, params, options, isMedia, callback) {
  var req;
  options = options || {};

  /**
   * If the params are not present, and callback was passed instead,
   * use params as the callback and create empty params.
   */
  if (typeof(params) === 'function') {
    callback = params;
    params = {};
  } else {
    params = params || {};
  }

  /**
   * If apiKey is set in auth, add it as a parameter to request
   */
  if (context.auth && context.auth.apiKey) {
    params.key = context.auth.apiKey; // set key as param if present
  }

  if(isMedia) {
    var media = params.media || {};
    delete params.media;

    /**
     * Create a boundary identifier and multipart read stream
     * @type {[type]}
     */
    var boundary = Math.random().toString(36).slice(2);
    var mp = new Multipart(boundary);

    params.uploadType = 'multipart';

    options.headers = {
      'Content-Type': 'multipart/related; boundary="' + boundary + '"'
    };

    // Add parts to multipart request
    mp.addPart({<commit_msg>If key specified in request params, do not use auth apiKey<commit_after>var Multipart = require('multipart-stream');

/**
 * Create and make a request to the Google API
 * @param {object}   context  self from the context of the method calling this
 * @param {object}   params   parameters passed from the method call
 * @param {object}   options  options generated by the method call
 * @param {Boolean}  isMedia  whether the request requires media upload
 * @param {Function} callback Callback function
 */
function createAPIRequest(context, params, options, isMedia, callback) {
  var req;
  options = options || {};

  /**
   * If the params are not present, and callback was passed instead,
   * use params as the callback and create empty params.
   */
  if (typeof(params) === 'function') {
    callback = params;
    params = {};
  } else {
    params = params || {};
  }

  /**
   * If apiKey is set in auth, add it as a parameter to request
   */
  if (context.auth && context.auth.apiKey && !params.key) {
    params.key = context.auth.apiKey; // set key as param if present
  }

  if(isMedia) {
    var media = params.media || {};
    delete params.media;

    /**
     * Create a boundary identifier and multipart read stream
     * @type {[type]}
     */
    var boundary = Math.random().toString(36).slice(2);
    var mp = new Multipart(boundary);

    params.uploadType = 'multipart';

    options.headers = {
      'Content-Type': 'multipart/related; boundary="' + boundary + '"'
    };

    // Add parts to multipart request
    mp.addPart({
{'fraction_non_alphanumeric': 0.1174738219895288, 'fraction_numerical': 0.001963350785340314, 'mean_word_length': 2.98046875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3577192', 'n_tokens_mistral': 874, 'n_tokens_neox': 853, 'n_words': 320}