Skip to content

Commit f84761b

Browse files
committed
feat: support nova-3 in agent
1 parent 23bf960 commit f84761b

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

examples/node-agent-live/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const agent = async () => {
2727
},
2828
agent: {
2929
listen: {
30-
model: "nova-2",
30+
model: "nova-3",
31+
keyterms: ["spacewalk"],
3132
},
3233
speak: {
3334
model: "aura-asteria-en",

src/lib/types/AgentLiveSchema.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type AudioEncoding =
2626
| "g729";
2727

2828
type ListenModel =
29+
| "nova-3"
30+
| "nova-3-general"
2931
| "nova-2"
3032
| "nova-2-meeting"
3133
| "nova-2-phonecall"
@@ -152,12 +154,23 @@ interface AgentLiveSchema extends Record<string, unknown> {
152154
output?: AudioFormat;
153155
};
154156
agent: {
155-
listen: {
156-
/**
157-
* @see https://developers.deepgram.com/docs/model
158-
*/
159-
model: ListenModel;
160-
};
157+
listen:
158+
| {
159+
/**
160+
* @see https://developers.deepgram.com/docs/model
161+
*/
162+
model: Exclude<ListenModel, "nova-3" | "nova-3-general">;
163+
}
164+
| {
165+
/**
166+
* @see https://developers.deepgram.com/docs/model
167+
*/
168+
model: Extract<ListenModel, "nova-3" | "nova-3-general">;
169+
/**
170+
* @see https://developers.deepgram.com/docs/keyterm
171+
*/
172+
keyterms: string[];
173+
};
161174
speak: {
162175
/**
163176
* @see https://developers.deepgram.com/docs/tts-models

src/packages/AgentLiveClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DEFAULT_AGENT_URL } from "../lib/constants";
22
import { AgentEvents } from "../lib/enums/AgentEvents";
3+
import { DeepgramError } from "../lib/errors.js";
34
import type {
45
AgentLiveSchema,
56
SpeakModel,
@@ -119,6 +120,10 @@ export class AgentLiveClient extends AbstractLiveClient {
119120
* @param options.context.replay - Whether to replay the last message if it was an assistant message.
120121
*/
121122
public configure(options: AgentLiveSchema): void {
123+
// @ts-expect-error Not every consumer of the SDK is using TypeScript, this conditional exists to catch runtime errors for JS code where there is no compile-time checking.
124+
if (!options.agent.listen.model.startsWith("nova-3") && options.agent.listen.keyterms?.length) {
125+
throw new DeepgramError("Keyterms are only supported with the Nova 3 models.");
126+
}
122127
// Converting the property names...
123128
const opts: Record<string, any> = { ...options };
124129
opts.audio.input["sample_rate"] = options.audio.input?.sampleRate;

0 commit comments

Comments
 (0)