From 93c1feb72ee4eac2fa0091b226a5c98a1cd8d8a5 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Thu, 31 Oct 2024 09:40:22 -0700 Subject: [PATCH] feat: use agent directly, no live prop --- examples/node-agent-live/index.js | 2 +- src/DeepgramClient.ts | 10 +++++----- src/packages/AgentClient.ts | 21 --------------------- src/packages/index.ts | 2 +- 4 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 src/packages/AgentClient.ts diff --git a/examples/node-agent-live/index.js b/examples/node-agent-live/index.js index 3fbcb32..f036c1b 100644 --- a/examples/node-agent-live/index.js +++ b/examples/node-agent-live/index.js @@ -9,7 +9,7 @@ const agent = async () => { let audioBuffer = Buffer.alloc(0); let i = 0; const url = "https://dpgr.am/spacewalk.wav"; - const connection = deepgram.agent.live(); + const connection = deepgram.agent(); connection.on(AgentEvents.Open, async () => { console.log("Connection opened"); diff --git a/src/DeepgramClient.ts b/src/DeepgramClient.ts index 3026f26..67da0fd 100644 --- a/src/DeepgramClient.ts +++ b/src/DeepgramClient.ts @@ -1,6 +1,7 @@ import { DeepgramVersionError } from "./lib/errors"; import { AbstractClient, + AgentLiveClient, ListenClient, ManageClient, ReadClient, @@ -8,7 +9,6 @@ import { SelfHostedRestClient, SpeakClient, ModelsRestClient, - AgentClient, } from "./packages"; /** @@ -82,13 +82,13 @@ export default class DeepgramClient extends AbstractClient { } /** - * Returns a new instance of the AgentClient, which provides access to Deepgram's Voice Agent API. + * Returns a new instance of the AgentLiveClient, which provides access to Deepgram's Voice Agent API. * - * @returns {AgentClient} A new instance of the AgentClient. + * @returns {AgentLiveClient} A new instance of the AgentLiveClient. * @beta */ - get agent(): any { - return new AgentClient(this.options); + public agent(endpoint: string = "/agent"): AgentLiveClient { + return new AgentLiveClient(this.options, endpoint); } /** diff --git a/src/packages/AgentClient.ts b/src/packages/AgentClient.ts deleted file mode 100644 index f555a59..0000000 --- a/src/packages/AgentClient.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { AbstractClient } from "./AbstractClient"; -import { AgentLiveClient } from "./AgentLiveClient"; - -/** - * The `AgentClient` class extends the `AbstractClient` class and provides access to the "agent" namespace. - * It exposes one method: - * - * `live(ttsOptions: SpeakSchema = {}, endpoint = ":version/speak")`: Returns an `AgentLiveClient` instance for interacting with the voice agent API. - */ -export class AgentClient extends AbstractClient { - public namespace: string = "agent"; - - /** - * Returns an `AgentLiveClient` instance for interacting with the voice agent API. - * @param {string} [endpoint="/agent"] - The endpoint to use for the live speak API. - * @returns {SpeakLiveClient} - A `SpeakLiveClient` instance for interacting with the live speak API. - */ - public live(endpoint: string = "/agent"): AgentLiveClient { - return new AgentLiveClient(this.options, endpoint); - } -} diff --git a/src/packages/index.ts b/src/packages/index.ts index 7a78830..7872e2a 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -1,7 +1,7 @@ export * from "./AbstractClient"; export * from "./AbstractLiveClient"; export * from "./AbstractRestClient"; -export * from "./AgentClient"; +export * from "./AgentLiveClient"; export * from "./ListenClient"; export * from "./ListenLiveClient"; export * from "./ListenRestClient";