Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ BUILD.bazel
copy.bara.sky
copybara.sh
.env
**/.env.sample
temp
temp-docs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "assemblyai",
"version": "4.16.1",
"version": "4.17.0",
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
"engines": {
"node": ">=18"
Expand Down
35 changes: 28 additions & 7 deletions src/services/lemur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,83 @@ import {
import { BaseService } from "../base";

export class LemurService extends BaseService {
summary(params: LemurSummaryParams): Promise<LemurSummaryResponse> {
summary(
params: LemurSummaryParams,
signal?: AbortSignal,
): Promise<LemurSummaryResponse> {
return this.fetchJson<LemurSummaryResponse>("/lemur/v3/generate/summary", {
method: "POST",
body: JSON.stringify(params),
signal,
});
}

questionAnswer(
params: LemurQuestionAnswerParams,
signal?: AbortSignal,
): Promise<LemurQuestionAnswerResponse> {
return this.fetchJson<LemurQuestionAnswerResponse>(
"/lemur/v3/generate/question-answer",
{
method: "POST",
body: JSON.stringify(params),
signal,
},
);
}

actionItems(
params: LemurActionItemsParams,
signal?: AbortSignal,
): Promise<LemurActionItemsResponse> {
return this.fetchJson<LemurActionItemsResponse>(
"/lemur/v3/generate/action-items",
{
method: "POST",
body: JSON.stringify(params),
signal,
},
);
}

task(params: LemurTaskParams): Promise<LemurTaskResponse> {
task(
params: LemurTaskParams,
signal?: AbortSignal,
): Promise<LemurTaskResponse> {
return this.fetchJson<LemurTaskResponse>("/lemur/v3/generate/task", {
method: "POST",
body: JSON.stringify(params),
signal,
});
}

/**
* Retrieve a LeMUR response that was previously generated.
* @param id - The ID of the LeMUR request you previously made. This would be found in the response of the original request.
* @param signal - Optional AbortSignal to cancel the request
* @returns The LeMUR response.
*/
getResponse<T extends LemurResponse>(id: string): Promise<T>;
getResponse(id: string): Promise<LemurResponse>;
getResponse(id: string): Promise<LemurResponse> {
return this.fetchJson<LemurResponse>(`/lemur/v3/${id}`);
getResponse<T extends LemurResponse>(
id: string,
signal?: AbortSignal,
): Promise<T>;
getResponse(id: string, signal?: AbortSignal): Promise<LemurResponse>;
getResponse(id: string, signal?: AbortSignal): Promise<LemurResponse> {
return this.fetchJson<LemurResponse>(`/lemur/v3/${id}`, { signal });
}

/**
* Delete the data for a previously submitted LeMUR request.
* @param id - ID of the LeMUR request
* @param signal - Optional AbortSignal to cancel the request
*/
purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse> {
purgeRequestData(
id: string,
signal?: AbortSignal,
): Promise<PurgeLemurRequestDataResponse> {
return this.fetchJson<PurgeLemurRequestDataResponse>(`/lemur/v3/${id}`, {
method: "DELETE",
signal,
});
}
}
5 changes: 4 additions & 1 deletion src/services/streaming/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ export class StreamingTranscriber {
}

if (this.params.filterProfanity) {
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
searchParams.set(
"filter_profanity",
this.params.filterProfanity.toString(),
);
}

url.search = searchParams.toString();
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/lemur.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,41 @@ describe("lemur", () => {
expect(deletionRequest.deleted).toBeTruthy();
expect(deletionRequest.request_id_to_purge).toBe(request_id);
});

it("should abort a summary request", async () => {
const controller = new AbortController();

// Start the request
const promise = client.lemur.summary(
{
final_model: "basic",
transcript_ids: knownTranscriptIds,
answer_format: "one sentence",
},
controller.signal,
);

// Abort immediately
controller.abort();

// Should throw an error
await expect(promise).rejects.toThrow();
});

it("should abort a task request", async () => {
const controller = new AbortController();

const promise = client.lemur.task(
{
final_model: "basic",
transcript_ids: knownTranscriptIds,
prompt: "Write a haiku about this conversation.",
},
controller.signal,
);

controller.abort();

await expect(promise).rejects.toThrow();
});
});
Loading