Edits history of script submission #5819 for ' Create fine tune (openai)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Openai = {
      api_key: string;
      organization_id: string;
    };
    /**
     * Create fine tune
     * Creates a job that fine-tunes a specified model from a given dataset.
    
    Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
    
    Learn more about fine-tuning
    
     */
    export async function main(
      auth: Openai,
      body: {
        training_file: string;
        batch_size?: number;
        classification_betas?: number[];
        classification_n_classes?: number;
        classification_positive_class?: string;
        compute_classification_metrics?: boolean;
        hyperparameters?: { n_epochs?: "auto" | number; [k: string]: unknown };
        learning_rate_multiplier?: number;
        model?: string | ("ada" | "babbage" | "curie" | "davinci");
        prompt_loss_weight?: number;
        suffix?: string;
        validation_file?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.openai.com/v1/fine-tunes`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "OpenAI-Organization": auth.organization_id,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.api_key,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 372 days ago

  • nativets
    type Openai = {
      api_key: string;
      organization_id: string;
    };
    /**
     * Create fine tune
     * Creates a job that fine-tunes a specified model from a given dataset.
    
    Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
    
    Learn more about fine-tuning
    
     */
    export async function main(
      auth: Openai,
      body: {
        training_file: string;
        batch_size?: number;
        classification_betas?: number[];
        classification_n_classes?: number;
        classification_positive_class?: string;
        compute_classification_metrics?: boolean;
        hyperparameters?: { n_epochs?: "auto" | number; [k: string]: unknown };
        learning_rate_multiplier?: number;
        model?: string | ("ada" | "babbage" | "curie" | "davinci");
        prompt_loss_weight?: number;
        suffix?: string;
        validation_file?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.openai.com/v1/fine-tunes`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "OpenAI-Organization": auth.organization_id,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.api_key,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 895 days ago