Edits history of script submission #5848 for ' Delete assistant file (openai)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Openai = {
      api_key: string;
      organization_id: string;
    };
    /**
     * Delete assistant file
     * Delete an assistant file.
     */
    export async function main(
      auth: Openai,
      assistant_id: string,
      file_id: string
    ) {
      const url = new URL(
        `https://api.openai.com/v1/assistants/${assistant_id}/files/${file_id}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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;
    };
    /**
     * Delete assistant file
     * Delete an assistant file.
     */
    export async function main(
      auth: Openai,
      assistant_id: string,
      file_id: string
    ) {
      const url = new URL(
        `https://api.openai.com/v1/assistants/${assistant_id}/files/${file_id}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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