@deepgram/sdk 3.9.0-beta.1 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -68
- package/dist/main/lib/enums/AgentEvents.d.ts +51 -1
- package/dist/main/lib/enums/AgentEvents.d.ts.map +1 -1
- package/dist/main/lib/enums/AgentEvents.js +51 -1
- package/dist/main/lib/enums/AgentEvents.js.map +1 -1
- package/dist/main/lib/fetch.js +1 -1
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/types/AgentLiveSchema.d.ts +10 -20
- package/dist/main/lib/types/AgentLiveSchema.d.ts.map +1 -1
- package/dist/main/lib/types/FunctionCallResponse.d.ts +14 -0
- package/dist/main/lib/types/FunctionCallResponse.d.ts.map +1 -0
- package/dist/main/lib/types/FunctionCallResponse.js +3 -0
- package/dist/main/lib/types/FunctionCallResponse.js.map +1 -0
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +2 -0
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/main/lib/types/index.d.ts +1 -0
- package/dist/main/lib/types/index.d.ts.map +1 -1
- package/dist/main/lib/types/index.js +1 -0
- package/dist/main/lib/types/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/AbstractLiveClient.d.ts +1 -1
- package/dist/main/packages/AbstractLiveClient.js +11 -0
- package/dist/main/packages/AbstractLiveClient.js.map +1 -1
- package/dist/main/packages/AgentLiveClient.d.ts +8 -1
- package/dist/main/packages/AgentLiveClient.d.ts.map +1 -1
- package/dist/main/packages/AgentLiveClient.js +17 -1
- package/dist/main/packages/AgentLiveClient.js.map +1 -1
- package/dist/main/packages/ListenRestClient.d.ts.map +1 -1
- package/dist/main/packages/ListenRestClient.js.map +1 -1
- package/dist/main/packages/ReadRestClient.d.ts.map +1 -1
- package/dist/main/packages/ReadRestClient.js.map +1 -1
- package/dist/main/packages/SpeakRestClient.d.ts.map +1 -1
- package/dist/main/packages/SpeakRestClient.js +10 -15
- package/dist/main/packages/SpeakRestClient.js.map +1 -1
- package/dist/module/lib/enums/AgentEvents.d.ts +51 -1
- package/dist/module/lib/enums/AgentEvents.d.ts.map +1 -1
- package/dist/module/lib/enums/AgentEvents.js +51 -1
- package/dist/module/lib/enums/AgentEvents.js.map +1 -1
- package/dist/module/lib/fetch.js +1 -1
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/types/AgentLiveSchema.d.ts +10 -20
- package/dist/module/lib/types/AgentLiveSchema.d.ts.map +1 -1
- package/dist/module/lib/types/FunctionCallResponse.d.ts +14 -0
- package/dist/module/lib/types/FunctionCallResponse.d.ts.map +1 -0
- package/dist/module/lib/types/FunctionCallResponse.js +2 -0
- package/dist/module/lib/types/FunctionCallResponse.js.map +1 -0
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +2 -0
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/module/lib/types/index.d.ts +1 -0
- package/dist/module/lib/types/index.d.ts.map +1 -1
- package/dist/module/lib/types/index.js +1 -0
- package/dist/module/lib/types/index.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/AbstractLiveClient.d.ts +1 -1
- package/dist/module/packages/AbstractLiveClient.js +11 -0
- package/dist/module/packages/AbstractLiveClient.js.map +1 -1
- package/dist/module/packages/AgentLiveClient.d.ts +8 -1
- package/dist/module/packages/AgentLiveClient.d.ts.map +1 -1
- package/dist/module/packages/AgentLiveClient.js +17 -1
- package/dist/module/packages/AgentLiveClient.js.map +1 -1
- package/dist/module/packages/ListenRestClient.d.ts.map +1 -1
- package/dist/module/packages/ListenRestClient.js.map +1 -1
- package/dist/module/packages/ReadRestClient.d.ts.map +1 -1
- package/dist/module/packages/ReadRestClient.js.map +1 -1
- package/dist/module/packages/SpeakRestClient.d.ts.map +1 -1
- package/dist/module/packages/SpeakRestClient.js +10 -15
- package/dist/module/packages/SpeakRestClient.js.map +1 -1
- package/dist/umd/deepgram.js +1 -1
- package/package.json +14 -3
- package/src/lib/enums/AgentEvents.ts +51 -1
- package/src/lib/fetch.ts +1 -1
- package/src/lib/types/AgentLiveSchema.ts +19 -25
- package/src/lib/types/FunctionCallResponse.ts +13 -0
- package/src/lib/types/LiveTranscriptionEvent.ts +2 -0
- package/src/lib/types/index.ts +1 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractLiveClient.ts +6 -6
- package/src/packages/AgentLiveClient.ts +23 -2
- package/src/packages/ListenRestClient.ts +0 -1
- package/src/packages/ReadRestClient.ts +1 -1
- package/src/packages/SpeakRestClient.ts +15 -19
package/src/lib/types/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./DeepgramClientOptions";
|
|
|
9
9
|
export * from "./DeepgramResponse";
|
|
10
10
|
export * from "./DeepgramSource";
|
|
11
11
|
export * from "./Fetch";
|
|
12
|
+
export * from "./FunctionCallResponse";
|
|
12
13
|
export * from "./GetModelsResponse";
|
|
13
14
|
export * from "./GetModelsSchema";
|
|
14
15
|
export * from "./GetProjectBalancesResponse";
|
package/src/lib/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "3.
|
|
1
|
+
export const version = "3.10.0";
|
|
@@ -16,7 +16,7 @@ interface WebSocketLikeConstructor {
|
|
|
16
16
|
new (
|
|
17
17
|
address: string | URL,
|
|
18
18
|
_ignored?: any,
|
|
19
|
-
options?: { headers:
|
|
19
|
+
options?: { headers: object | undefined }
|
|
20
20
|
): WebSocketLike;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -39,11 +39,11 @@ type SocketDataLike = string | ArrayBufferLike | Blob;
|
|
|
39
39
|
* @property {string} message - A human-readable error message.
|
|
40
40
|
* @property {string} type - The type of the error.
|
|
41
41
|
*/
|
|
42
|
-
interface WebSocketLikeError {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
42
|
+
// interface WebSocketLikeError {
|
|
43
|
+
// error: any;
|
|
44
|
+
// message: string;
|
|
45
|
+
// type: string;
|
|
46
|
+
// }
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Indicates whether a native WebSocket implementation is available in the current environment.
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_AGENT_URL } from "../lib/constants";
|
|
2
2
|
import { AgentEvents } from "../lib/enums/AgentEvents";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
AgentLiveSchema,
|
|
5
|
+
SpeakModel,
|
|
6
|
+
DeepgramClientOptions,
|
|
7
|
+
FunctionCallResponse,
|
|
8
|
+
} from "../lib/types";
|
|
4
9
|
import { AbstractLiveClient } from "./AbstractLiveClient";
|
|
5
10
|
|
|
6
11
|
export class AgentLiveClient extends AbstractLiveClient {
|
|
@@ -114,7 +119,13 @@ export class AgentLiveClient extends AbstractLiveClient {
|
|
|
114
119
|
* @param options.context.replay - Whether to replay the last message if it was an assistant message.
|
|
115
120
|
*/
|
|
116
121
|
public configure(options: AgentLiveSchema): void {
|
|
117
|
-
|
|
122
|
+
// Converting the property names...
|
|
123
|
+
const opts: Record<string, any> = { ...options };
|
|
124
|
+
opts.audio.input["sample_rate"] = options.audio.input?.sampleRate;
|
|
125
|
+
delete opts.audio.input.sampleRate;
|
|
126
|
+
opts.audio.output["sample_rate"] = options.audio.output?.sampleRate;
|
|
127
|
+
delete opts.audio.output.sampleRate;
|
|
128
|
+
this.send(JSON.stringify({ type: "SettingsConfiguration", ...opts }));
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
/**
|
|
@@ -146,6 +157,16 @@ export class AgentLiveClient extends AbstractLiveClient {
|
|
|
146
157
|
this.send(JSON.stringify({ type: "InjectAgentMessage", message }));
|
|
147
158
|
}
|
|
148
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Respond to a function call request.
|
|
162
|
+
* @param response - The response to the function call request.
|
|
163
|
+
* @param response.function_call_id - The ID that was received in the request (these MUST match).
|
|
164
|
+
* @param response.output - The result of the function call.
|
|
165
|
+
*/
|
|
166
|
+
public functionCallResponse(response: FunctionCallResponse): void {
|
|
167
|
+
this.send(JSON.stringify({ type: "FunctionCallResponse", ...response }));
|
|
168
|
+
}
|
|
169
|
+
|
|
149
170
|
/**
|
|
150
171
|
* Send a keepalive to avoid closing the websocket while you
|
|
151
172
|
* are not transmitting audio. This should be sent at least
|
|
@@ -26,28 +26,24 @@ export class SpeakRestClient extends AbstractRestClient {
|
|
|
26
26
|
options?: SpeakSchema,
|
|
27
27
|
endpoint = ":version/speak"
|
|
28
28
|
): Promise<SpeakRestClient> {
|
|
29
|
-
|
|
30
|
-
let body;
|
|
29
|
+
let body;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if (isTextSource(source)) {
|
|
32
|
+
body = JSON.stringify(source);
|
|
33
|
+
} else {
|
|
34
|
+
throw new DeepgramError("Unknown transcription source type");
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
const requestUrl = this.getRequestUrl(
|
|
38
|
+
endpoint,
|
|
39
|
+
{},
|
|
40
|
+
{ ...{ model: "aura-asteria-en" }, ...options }
|
|
41
|
+
);
|
|
42
|
+
this.result = await this.post(requestUrl, body, {
|
|
43
|
+
headers: { Accept: "audio/*", "Content-Type": "application/json" },
|
|
44
|
+
});
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
} catch (error) {
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
46
|
+
return this;
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
/**
|