0
Run a task using LeMUR
One script reply has been approved by the moderators Verified

Use the LeMUR task endpoint to input your own LLM prompt.

Created by hugo697 86 days ago Viewed 3607 times
0
Submitted by hugo697 Bun
Verified 86 days ago
1
//native
2
type Assemblyai = {
3
  apiKey: string;
4
};
5
/**
6
 * Run a task using LeMUR
7
 * Use the LeMUR task endpoint to input your own LLM prompt.
8
 */
9
export async function main(
10
  auth: Assemblyai,
11
  body: { prompt: string } & {
12
    transcript_ids?: string[];
13
    input_text?: string;
14
    context?: string | {};
15
    final_model?: string;
16
    max_output_size?: number;
17
    temperature?: number;
18
  },
19
) {
20
  const url = new URL(`https://api.assemblyai.com/lemur/v3/generate/task`);
21

22
  const response = await fetch(url, {
23
    method: "POST",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.apiKey,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36