Edits history of script submission #11522 for ' Run a task using LeMUR (assemblyai)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Assemblyai = {
      apiKey: string;
    };
    /**
     * Run a task using LeMUR
     * Use the LeMUR task endpoint to input your own LLM prompt.
     */
    export async function main(
      auth: Assemblyai,
      body: { prompt: string } & {
        transcript_ids?: string[];
        input_text?: string;
        context?: string | {};
        final_model?: string;
        max_output_size?: number;
        temperature?: number;
      },
    ) {
      const url = new URL(`https://api.assemblyai.com/lemur/v3/generate/task`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        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 423 days ago