Skip to content

Commit 8a7b8f4

Browse files
committed
feat(api): integrate Nova3Node into CloudflareNodeRegistry and update tests for successful execution
1 parent 69d9721 commit 8a7b8f4

3 files changed

Lines changed: 34 additions & 22 deletions

File tree

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NodeContext } from "../types";
77
import { Nova3Node } from "./nova-3-node";
88

99
describe("Nova3Node", () => {
10-
it("should return expected error due to AI Gateway incompatibility", async () => {
10+
it("should execute successfully with basic parameters", async () => {
1111
const nodeId = "nova-3";
1212
const node = new Nova3Node({
1313
nodeId,
@@ -24,13 +24,17 @@ describe("Nova3Node", () => {
2424
} as unknown as NodeContext;
2525

2626
const result = await node.execute(context);
27-
// Note: Nova-3 is currently not supported by Cloudflare AI Gateway
28-
// due to incompatible audio format requirements
29-
expect(result.status).toBe("error");
30-
expect(result.error).toContain("required properties at '/audio' are 'body,contentType'");
27+
expect(result.status).toBe("completed");
28+
expect(result.outputs).toBeDefined();
29+
expect(result.outputs?.text).toBeDefined();
30+
expect(typeof result.outputs?.text).toBe("string");
31+
expect(result.outputs?.confidence).toBeDefined();
32+
expect(typeof result.outputs?.confidence).toBe("number");
33+
expect(result.outputs?.words).toBeDefined();
34+
expect(Array.isArray(result.outputs?.words)).toBe(true);
3135
});
3236

33-
it("should return expected error with language detection enabled", async () => {
37+
it("should execute successfully with language detection enabled", async () => {
3438
const nodeId = "nova-3";
3539
const node = new Nova3Node({
3640
nodeId,
@@ -48,8 +52,17 @@ describe("Nova3Node", () => {
4852
} as unknown as NodeContext;
4953

5054
const result = await node.execute(context);
51-
expect(result.status).toBe("error");
52-
expect(result.error).toContain("required properties at '/audio' are 'body,contentType'");
55+
expect(result.status).toBe("completed");
56+
expect(result.outputs).toBeDefined();
57+
expect(result.outputs?.text).toBeDefined();
58+
expect(typeof result.outputs?.text).toBe("string");
59+
expect(result.outputs?.confidence).toBeDefined();
60+
expect(typeof result.outputs?.confidence).toBe("number");
61+
expect(result.outputs?.words).toBeDefined();
62+
expect(Array.isArray(result.outputs?.words)).toBe(true);
63+
if (result.outputs?.language) {
64+
expect(typeof result.outputs.language).toBe("string");
65+
}
5366
});
5467

5568
it("should return error when audio is not provided", async () => {

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export class Nova3Node extends ExecutableNode {
1717
icon: "mic",
1818
documentation: `This node transcribes speech from audio files using Deepgram's Nova-3 model, providing high-quality speech-to-text conversion with advanced features like speaker diarization, sentiment analysis, and topic detection.
1919
20-
⚠️ **CURRENTLY NOT SUPPORTED**: Nova-3 is not currently compatible with Cloudflare's AI Gateway due to incompatible audio format requirements. The API requires a specific \`{audio: {body, contentType}}\` format that the AI Gateway cannot handle.
21-
2220
## Usage Example
2321
2422
- **Input**: audio file (MP3, WAV, etc.)
@@ -31,16 +29,7 @@ export class Nova3Node extends ExecutableNode {
3129
- **Topic Detection**: Automatically detect topics in the audio
3230
- **Language Detection**: Automatically detect the spoken language
3331
- **Smart Formatting**: Apply intelligent formatting to improve readability
34-
- **Entity Detection**: Identify and extract key entities from content
35-
36-
## Pricing
37-
38-
- Regular HTTP: $0.0052 per audio minute
39-
- WebSocket: $0.0092 per audio minute
40-
41-
## Status
42-
43-
This implementation is complete and ready to work once Cloudflare resolves the AI Gateway compatibility issue.`,
32+
- **Entity Detection**: Identify and extract key entities from content`,
4433
computeCost: 5,
4534
inputs: [
4635
{
@@ -251,10 +240,18 @@ This implementation is complete and ready to work once Cloudflare resolves the A
251240
}
252241

253242
// Build parameters object with only provided values
254-
// Try using the exact format from the documentation but with Uint8Array directly
243+
// Nova-3 requires {body, contentType} format where body is a ReadableStream
244+
// Convert Uint8Array to ReadableStream
245+
const audioStream = new ReadableStream({
246+
start(controller) {
247+
controller.enqueue(audio.data);
248+
controller.close();
249+
}
250+
});
251+
255252
const params: any = {
256253
audio: {
257-
body: audio.data,
254+
body: audioStream,
258255
contentType: audio.mimeType || "audio/mpeg",
259256
},
260257
};

apps/api/src/nodes/cloudflare-node-registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { GeoTiffQueryNode } from "./3d/geotiff-query-node";
66
import { AudioRecorderNode } from "./audio/audio-recorder-node";
77
import { Aura1Node } from "./audio/aura-1-node";
88
import { MelottsNode } from "./audio/melotts-node";
9+
import { Nova3Node } from "./audio/nova-3-node";
910
import { WhisperLargeV3TurboNode } from "./audio/whisper-large-v3-turbo-node";
1011
import { WhisperNode } from "./audio/whisper-node";
1112
import { WhisperTinyEnNode } from "./audio/whisper-tiny-en-node";
@@ -387,6 +388,7 @@ export class CloudflareNodeRegistry extends BaseNodeRegistry {
387388
this.registerImplementation(ExifReaderNode);
388389
this.registerImplementation(Aura1Node);
389390
this.registerImplementation(MelottsNode);
391+
this.registerImplementation(Nova3Node);
390392
this.registerImplementation(WebcamNode);
391393

392394
// String operations

0 commit comments

Comments
 (0)