Edits history of script submission #5854 for ' List fine tuning events (openai)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Openai = {
      api_key: string;
      organization_id: string;
    };
    /**
     * List fine tuning events
     * Get status updates for a fine-tuning job.
    
     */
    export async function main(
      auth: Openai,
      fine_tuning_job_id: string,
      after: string | undefined,
      limit: string | undefined
    ) {
      const url = new URL(
        `https://api.openai.com/v1/fine_tuning/jobs/${fine_tuning_job_id}/events`
      );
      for (const [k, v] of [
        ["after", after],
        ["limit", limit],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          "OpenAI-Organization": auth.organization_id,
          Authorization: "Bearer " + auth.api_key,
        },
        body: undefined,
      });
      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;
    };
    /**
     * List fine tuning events
     * Get status updates for a fine-tuning job.
    
     */
    export async function main(
      auth: Openai,
      fine_tuning_job_id: string,
      after: string | undefined,
      limit: string | undefined
    ) {
      const url = new URL(
        `https://api.openai.com/v1/fine_tuning/jobs/${fine_tuning_job_id}/events`
      );
      for (const [k, v] of [
        ["after", after],
        ["limit", limit],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          "OpenAI-Organization": auth.organization_id,
          Authorization: "Bearer " + auth.api_key,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 895 days ago