0
Ask questions using LeMUR
One script reply has been approved by the moderators Verified

Question & Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.

Created by hugo697 23 days ago Viewed 2014 times
0
Submitted by hugo697 Bun
Verified 23 days ago
1
//native
2
type Assemblyai = {
3
  apiKey: string;
4
};
5
/**
6
 * Ask questions using LeMUR
7
 * Question & Answer allows you to ask free-form questions about a single transcript or a group of transcripts.
8
The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
9

10
 */
11
export async function main(
12
  auth: Assemblyai,
13
  body: {
14
    transcript_ids?: string[];
15
    input_text?: string;
16
    context?: string | {};
17
    final_model?: string;
18
    max_output_size?: number;
19
    temperature?: number;
20
  } & {
21
    questions: {
22
      question: string;
23
      context?: string | {};
24
      answer_format?: string;
25
      answer_options?: string[];
26
    }[];
27
  },
28
) {
29
  const url = new URL(
30
    `https://api.assemblyai.com/lemur/v3/generate/question-answer`,
31
  );
32

33
  const response = await fetch(url, {
34
    method: "POST",
35
    headers: {
36
      "Content-Type": "application/json",
37
      Authorization: "Bearer " + auth.apiKey,
38
    },
39
    body: JSON.stringify(body),
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47