Skip to content

Commit 0ffd2ba

Browse files
Merge pull request #106 from AssemblyAI/A94C23FD55A9C0ABC92E0EFBBB78972C
4.17.0
2 parents d369441 + e4ff9e5 commit 0ffd2ba

5 files changed

Lines changed: 71 additions & 9 deletions

File tree

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ BUILD.bazel
1616
copy.bara.sky
1717
copybara.sh
1818
.env
19+
**/.env.sample
1920
temp
2021
temp-docs

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "assemblyai",
3-
"version": "4.16.1",
3+
"version": "4.17.0",
44
"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.",
55
"engines": {
66
"node": ">=18"

src/services/lemur/index.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,83 @@ import {
1313
import { BaseService } from "../base";
1414

1515
export class LemurService extends BaseService {
16-
summary(params: LemurSummaryParams): Promise<LemurSummaryResponse> {
16+
summary(
17+
params: LemurSummaryParams,
18+
signal?: AbortSignal,
19+
): Promise<LemurSummaryResponse> {
1720
return this.fetchJson<LemurSummaryResponse>("/lemur/v3/generate/summary", {
1821
method: "POST",
1922
body: JSON.stringify(params),
23+
signal,
2024
});
2125
}
2226

2327
questionAnswer(
2428
params: LemurQuestionAnswerParams,
29+
signal?: AbortSignal,
2530
): Promise<LemurQuestionAnswerResponse> {
2631
return this.fetchJson<LemurQuestionAnswerResponse>(
2732
"/lemur/v3/generate/question-answer",
2833
{
2934
method: "POST",
3035
body: JSON.stringify(params),
36+
signal,
3137
},
3238
);
3339
}
3440

3541
actionItems(
3642
params: LemurActionItemsParams,
43+
signal?: AbortSignal,
3744
): Promise<LemurActionItemsResponse> {
3845
return this.fetchJson<LemurActionItemsResponse>(
3946
"/lemur/v3/generate/action-items",
4047
{
4148
method: "POST",
4249
body: JSON.stringify(params),
50+
signal,
4351
},
4452
);
4553
}
4654

47-
task(params: LemurTaskParams): Promise<LemurTaskResponse> {
55+
task(
56+
params: LemurTaskParams,
57+
signal?: AbortSignal,
58+
): Promise<LemurTaskResponse> {
4859
return this.fetchJson<LemurTaskResponse>("/lemur/v3/generate/task", {
4960
method: "POST",
5061
body: JSON.stringify(params),
62+
signal,
5163
});
5264
}
5365

5466
/**
5567
* Retrieve a LeMUR response that was previously generated.
5668
* @param id - The ID of the LeMUR request you previously made. This would be found in the response of the original request.
69+
* @param signal - Optional AbortSignal to cancel the request
5770
* @returns The LeMUR response.
5871
*/
59-
getResponse<T extends LemurResponse>(id: string): Promise<T>;
60-
getResponse(id: string): Promise<LemurResponse>;
61-
getResponse(id: string): Promise<LemurResponse> {
62-
return this.fetchJson<LemurResponse>(`/lemur/v3/${id}`);
72+
getResponse<T extends LemurResponse>(
73+
id: string,
74+
signal?: AbortSignal,
75+
): Promise<T>;
76+
getResponse(id: string, signal?: AbortSignal): Promise<LemurResponse>;
77+
getResponse(id: string, signal?: AbortSignal): Promise<LemurResponse> {
78+
return this.fetchJson<LemurResponse>(`/lemur/v3/${id}`, { signal });
6379
}
6480

6581
/**
6682
* Delete the data for a previously submitted LeMUR request.
6783
* @param id - ID of the LeMUR request
84+
* @param signal - Optional AbortSignal to cancel the request
6885
*/
69-
purgeRequestData(id: string): Promise<PurgeLemurRequestDataResponse> {
86+
purgeRequestData(
87+
id: string,
88+
signal?: AbortSignal,
89+
): Promise<PurgeLemurRequestDataResponse> {
7090
return this.fetchJson<PurgeLemurRequestDataResponse>(`/lemur/v3/${id}`, {
7191
method: "DELETE",
92+
signal,
7293
});
7394
}
7495
}

src/services/streaming/service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ export class StreamingTranscriber {
118118
}
119119

120120
if (this.params.filterProfanity) {
121-
searchParams.set("filter_profanity", this.params.filterProfanity.toString());
121+
searchParams.set(
122+
"filter_profanity",
123+
this.params.filterProfanity.toString(),
124+
);
122125
}
123126

124127
url.search = searchParams.toString();

tests/integration/lemur.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,41 @@ describe("lemur", () => {
101101
expect(deletionRequest.deleted).toBeTruthy();
102102
expect(deletionRequest.request_id_to_purge).toBe(request_id);
103103
});
104+
105+
it("should abort a summary request", async () => {
106+
const controller = new AbortController();
107+
108+
// Start the request
109+
const promise = client.lemur.summary(
110+
{
111+
final_model: "basic",
112+
transcript_ids: knownTranscriptIds,
113+
answer_format: "one sentence",
114+
},
115+
controller.signal,
116+
);
117+
118+
// Abort immediately
119+
controller.abort();
120+
121+
// Should throw an error
122+
await expect(promise).rejects.toThrow();
123+
});
124+
125+
it("should abort a task request", async () => {
126+
const controller = new AbortController();
127+
128+
const promise = client.lemur.task(
129+
{
130+
final_model: "basic",
131+
transcript_ids: knownTranscriptIds,
132+
prompt: "Write a haiku about this conversation.",
133+
},
134+
controller.signal,
135+
);
136+
137+
controller.abort();
138+
139+
await expect(promise).rejects.toThrow();
140+
});
104141
});

0 commit comments

Comments
 (0)