Skip to content

Commit 7147f47

Browse files
committed
Improve formatting
1 parent 8a7b8f4 commit 7147f47

4 files changed

Lines changed: 47 additions & 23 deletions

File tree

apps/api/src/nodes/3d/dem-to-buffergeometry-node.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ describe("DemToBufferGeometryNode", () => {
4747
const result = await node.execute(context);
4848

4949
expect(result.status).toBe("error");
50-
expect(result.error).toContain("Invalid input: expected object, received undefined");
50+
expect(result.error).toContain(
51+
"Invalid input: expected object, received undefined"
52+
);
5153
});
5254

5355
it("handles missing bounds parameter", async () => {
@@ -61,7 +63,9 @@ describe("DemToBufferGeometryNode", () => {
6163
const result = await node.execute(context);
6264

6365
expect(result.status).toBe("error");
64-
expect(result.error).toContain("Invalid input: expected tuple, received undefined");
66+
expect(result.error).toContain(
67+
"Invalid input: expected tuple, received undefined"
68+
);
6569
});
6670

6771
it("handles invalid image format", async () => {
@@ -89,7 +93,9 @@ describe("DemToBufferGeometryNode", () => {
8993
const result = await node.execute(context);
9094

9195
expect(result.status).toBe("error");
92-
expect(result.error).toContain("Invalid input: expected number, received undefined");
96+
expect(result.error).toContain(
97+
"Invalid input: expected number, received undefined"
98+
);
9399
});
94100

95101
it("handles invalid martini error", async () => {

apps/api/src/nodes/audio/aura-1-node.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ export class Aura1Node extends ExecutableNode {
116116
if (container && encoding && !["mp3", "opus", "aac"].includes(encoding)) {
117117
params.container = container;
118118
}
119-
119+
120120
// Sample rate and bit rate are only valid for certain encodings
121121
// According to the documentation, these parameters depend on the encoding type
122-
if (sample_rate && encoding && !["mp3", "opus", "aac"].includes(encoding)) {
122+
if (
123+
sample_rate &&
124+
encoding &&
125+
!["mp3", "opus", "aac"].includes(encoding)
126+
) {
123127
params.sample_rate = sample_rate;
124128
}
125129
if (bit_rate && encoding && !["mp3", "opus", "aac"].includes(encoding)) {

apps/api/src/nodes/audio/nova-3-node.integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ describe("Nova3Node", () => {
102102
expect(result.status).toBe("error");
103103
expect(result.error).toContain("AI service is not available");
104104
});
105-
});
105+
});

apps/api/src/nodes/audio/nova-3-node.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ export class Nova3Node extends ExecutableNode {
4141
{
4242
name: "detect_language",
4343
type: "boolean",
44-
description: "Identifies the dominant language spoken in submitted audio",
44+
description:
45+
"Identifies the dominant language spoken in submitted audio",
4546
value: true,
4647
},
4748
{
4849
name: "diarize",
4950
type: "boolean",
50-
description: "Recognize speaker changes. Each word will be assigned a speaker number",
51+
description:
52+
"Recognize speaker changes. Each word will be assigned a speaker number",
5153
value: false,
5254
},
5355
{
@@ -71,7 +73,8 @@ export class Nova3Node extends ExecutableNode {
7173
{
7274
name: "smart_format",
7375
type: "boolean",
74-
description: "Apply formatting to transcript output for improved readability",
76+
description:
77+
"Apply formatting to transcript output for improved readability",
7578
value: true,
7679
},
7780
{
@@ -83,7 +86,8 @@ export class Nova3Node extends ExecutableNode {
8386
{
8487
name: "paragraphs",
8588
type: "boolean",
86-
description: "Splits audio into paragraphs to improve transcript readability",
89+
description:
90+
"Splits audio into paragraphs to improve transcript readability",
8791
value: false,
8892
},
8993
{
@@ -113,19 +117,22 @@ export class Nova3Node extends ExecutableNode {
113117
{
114118
name: "measurements",
115119
type: "boolean",
116-
description: "Convert spoken measurements to their corresponding abbreviations",
120+
description:
121+
"Convert spoken measurements to their corresponding abbreviations",
117122
value: false,
118123
},
119124
{
120125
name: "language",
121126
type: "string",
122-
description: "The BCP-47 language tag that hints at the primary spoken language",
127+
description:
128+
"The BCP-47 language tag that hints at the primary spoken language",
123129
value: "",
124130
},
125131
{
126132
name: "mode",
127133
type: "string",
128-
description: "Mode of operation for the model (general, medical, finance)",
134+
description:
135+
"Mode of operation for the model (general, medical, finance)",
129136
value: "general",
130137
},
131138
{
@@ -149,7 +156,8 @@ export class Nova3Node extends ExecutableNode {
149156
{
150157
name: "keywords",
151158
type: "string",
152-
description: "Keywords to boost or suppress specialized terminology and brands",
159+
description:
160+
"Keywords to boost or suppress specialized terminology and brands",
153161
value: "",
154162
},
155163
{
@@ -180,7 +188,8 @@ export class Nova3Node extends ExecutableNode {
180188
{
181189
name: "words",
182190
type: "json",
183-
description: "Detailed word timing information with speaker assignments",
191+
description:
192+
"Detailed word timing information with speaker assignments",
184193
hidden: true,
185194
},
186195
{
@@ -246,7 +255,7 @@ export class Nova3Node extends ExecutableNode {
246255
start(controller) {
247256
controller.enqueue(audio.data);
248257
controller.close();
249-
}
258+
},
250259
});
251260

252261
const params: any = {
@@ -257,17 +266,20 @@ export class Nova3Node extends ExecutableNode {
257266
};
258267

259268
// Add optional parameters only if they are provided and not default values
260-
if (detect_language !== undefined) params.detect_language = detect_language;
269+
if (detect_language !== undefined)
270+
params.detect_language = detect_language;
261271
if (diarize !== undefined) params.diarize = diarize;
262272
if (sentiment !== undefined) params.sentiment = sentiment;
263273
if (topics !== undefined) params.topics = topics;
264-
if (detect_entities !== undefined) params.detect_entities = detect_entities;
274+
if (detect_entities !== undefined)
275+
params.detect_entities = detect_entities;
265276
if (smart_format !== undefined) params.smart_format = smart_format;
266277
if (punctuate !== undefined) params.punctuate = punctuate;
267278
if (paragraphs !== undefined) params.paragraphs = paragraphs;
268279
if (utterances !== undefined) params.utterances = utterances;
269280
if (filler_words !== undefined) params.filler_words = filler_words;
270-
if (profanity_filter !== undefined) params.profanity_filter = profanity_filter;
281+
if (profanity_filter !== undefined)
282+
params.profanity_filter = profanity_filter;
271283
if (numerals !== undefined) params.numerals = numerals;
272284
if (measurements !== undefined) params.measurements = measurements;
273285
if (language && language.trim()) params.language = language;
@@ -276,8 +288,10 @@ export class Nova3Node extends ExecutableNode {
276288
if (channels && channels !== 1) params.channels = channels;
277289
if (multichannel !== undefined) params.multichannel = multichannel;
278290
if (keywords && keywords.trim()) params.keywords = keywords;
279-
if (custom_topic && custom_topic.trim()) params.custom_topic = custom_topic;
280-
if (custom_intent && custom_intent.trim()) params.custom_intent = custom_intent;
291+
if (custom_topic && custom_topic.trim())
292+
params.custom_topic = custom_topic;
293+
if (custom_intent && custom_intent.trim())
294+
params.custom_intent = custom_intent;
281295

282296
// Call Cloudflare AI Nova-3 model
283297
const response = await context.env.AI.run(
@@ -294,7 +308,7 @@ export class Nova3Node extends ExecutableNode {
294308

295309
const channel = results.channels[0];
296310
const alternative = channel.alternatives?.[0];
297-
311+
298312
if (!alternative) {
299313
throw new Error("No transcription alternatives found in response");
300314
}
@@ -310,7 +324,7 @@ export class Nova3Node extends ExecutableNode {
310324
if (results.summary) {
311325
output.summary = results.summary;
312326
}
313-
327+
314328
if (results.sentiments) {
315329
output.sentiments = results.sentiments;
316330
}

0 commit comments

Comments
 (0)