@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.
Files changed (83) hide show
  1. package/README.md +68 -68
  2. package/dist/main/lib/enums/AgentEvents.d.ts +51 -1
  3. package/dist/main/lib/enums/AgentEvents.d.ts.map +1 -1
  4. package/dist/main/lib/enums/AgentEvents.js +51 -1
  5. package/dist/main/lib/enums/AgentEvents.js.map +1 -1
  6. package/dist/main/lib/fetch.js +1 -1
  7. package/dist/main/lib/fetch.js.map +1 -1
  8. package/dist/main/lib/types/AgentLiveSchema.d.ts +10 -20
  9. package/dist/main/lib/types/AgentLiveSchema.d.ts.map +1 -1
  10. package/dist/main/lib/types/FunctionCallResponse.d.ts +14 -0
  11. package/dist/main/lib/types/FunctionCallResponse.d.ts.map +1 -0
  12. package/dist/main/lib/types/FunctionCallResponse.js +3 -0
  13. package/dist/main/lib/types/FunctionCallResponse.js.map +1 -0
  14. package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +2 -0
  15. package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
  16. package/dist/main/lib/types/index.d.ts +1 -0
  17. package/dist/main/lib/types/index.d.ts.map +1 -1
  18. package/dist/main/lib/types/index.js +1 -0
  19. package/dist/main/lib/types/index.js.map +1 -1
  20. package/dist/main/lib/version.d.ts +1 -1
  21. package/dist/main/lib/version.js +1 -1
  22. package/dist/main/packages/AbstractLiveClient.d.ts +1 -1
  23. package/dist/main/packages/AbstractLiveClient.js +11 -0
  24. package/dist/main/packages/AbstractLiveClient.js.map +1 -1
  25. package/dist/main/packages/AgentLiveClient.d.ts +8 -1
  26. package/dist/main/packages/AgentLiveClient.d.ts.map +1 -1
  27. package/dist/main/packages/AgentLiveClient.js +17 -1
  28. package/dist/main/packages/AgentLiveClient.js.map +1 -1
  29. package/dist/main/packages/ListenRestClient.d.ts.map +1 -1
  30. package/dist/main/packages/ListenRestClient.js.map +1 -1
  31. package/dist/main/packages/ReadRestClient.d.ts.map +1 -1
  32. package/dist/main/packages/ReadRestClient.js.map +1 -1
  33. package/dist/main/packages/SpeakRestClient.d.ts.map +1 -1
  34. package/dist/main/packages/SpeakRestClient.js +10 -15
  35. package/dist/main/packages/SpeakRestClient.js.map +1 -1
  36. package/dist/module/lib/enums/AgentEvents.d.ts +51 -1
  37. package/dist/module/lib/enums/AgentEvents.d.ts.map +1 -1
  38. package/dist/module/lib/enums/AgentEvents.js +51 -1
  39. package/dist/module/lib/enums/AgentEvents.js.map +1 -1
  40. package/dist/module/lib/fetch.js +1 -1
  41. package/dist/module/lib/fetch.js.map +1 -1
  42. package/dist/module/lib/types/AgentLiveSchema.d.ts +10 -20
  43. package/dist/module/lib/types/AgentLiveSchema.d.ts.map +1 -1
  44. package/dist/module/lib/types/FunctionCallResponse.d.ts +14 -0
  45. package/dist/module/lib/types/FunctionCallResponse.d.ts.map +1 -0
  46. package/dist/module/lib/types/FunctionCallResponse.js +2 -0
  47. package/dist/module/lib/types/FunctionCallResponse.js.map +1 -0
  48. package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +2 -0
  49. package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
  50. package/dist/module/lib/types/index.d.ts +1 -0
  51. package/dist/module/lib/types/index.d.ts.map +1 -1
  52. package/dist/module/lib/types/index.js +1 -0
  53. package/dist/module/lib/types/index.js.map +1 -1
  54. package/dist/module/lib/version.d.ts +1 -1
  55. package/dist/module/lib/version.js +1 -1
  56. package/dist/module/packages/AbstractLiveClient.d.ts +1 -1
  57. package/dist/module/packages/AbstractLiveClient.js +11 -0
  58. package/dist/module/packages/AbstractLiveClient.js.map +1 -1
  59. package/dist/module/packages/AgentLiveClient.d.ts +8 -1
  60. package/dist/module/packages/AgentLiveClient.d.ts.map +1 -1
  61. package/dist/module/packages/AgentLiveClient.js +17 -1
  62. package/dist/module/packages/AgentLiveClient.js.map +1 -1
  63. package/dist/module/packages/ListenRestClient.d.ts.map +1 -1
  64. package/dist/module/packages/ListenRestClient.js.map +1 -1
  65. package/dist/module/packages/ReadRestClient.d.ts.map +1 -1
  66. package/dist/module/packages/ReadRestClient.js.map +1 -1
  67. package/dist/module/packages/SpeakRestClient.d.ts.map +1 -1
  68. package/dist/module/packages/SpeakRestClient.js +10 -15
  69. package/dist/module/packages/SpeakRestClient.js.map +1 -1
  70. package/dist/umd/deepgram.js +1 -1
  71. package/package.json +14 -3
  72. package/src/lib/enums/AgentEvents.ts +51 -1
  73. package/src/lib/fetch.ts +1 -1
  74. package/src/lib/types/AgentLiveSchema.ts +19 -25
  75. package/src/lib/types/FunctionCallResponse.ts +13 -0
  76. package/src/lib/types/LiveTranscriptionEvent.ts +2 -0
  77. package/src/lib/types/index.ts +1 -0
  78. package/src/lib/version.ts +1 -1
  79. package/src/packages/AbstractLiveClient.ts +6 -6
  80. package/src/packages/AgentLiveClient.ts +23 -2
  81. package/src/packages/ListenRestClient.ts +0 -1
  82. package/src/packages/ReadRestClient.ts +1 -1
  83. package/src/packages/SpeakRestClient.ts +15 -19
@@ -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";
@@ -1 +1 @@
1
- export const version = "3.9.0-beta.1";
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: Object | undefined }
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
- error: any;
44
- message: string;
45
- type: string;
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 { AgentLiveSchema, SpeakModel, DeepgramClientOptions } from "../lib/types";
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
- this.send(JSON.stringify({ type: "SettingsConfiguration", options }));
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
@@ -3,7 +3,6 @@ import { DeepgramError, isDeepgramError } from "../lib/errors";
3
3
  import type {
4
4
  AsyncPrerecordedResponse,
5
5
  DeepgramResponse,
6
- Fetch,
7
6
  FileSource,
8
7
  PrerecordedSchema,
9
8
  SyncPrerecordedResponse,
@@ -1,4 +1,4 @@
1
- import { CallbackUrl, appendSearchParams, isTextSource, isUrlSource } from "../lib/helpers";
1
+ import { CallbackUrl, isTextSource, isUrlSource } from "../lib/helpers";
2
2
  import { DeepgramError, isDeepgramError } from "../lib/errors";
3
3
  import type {
4
4
  AnalyzeSchema,
@@ -26,28 +26,24 @@ export class SpeakRestClient extends AbstractRestClient {
26
26
  options?: SpeakSchema,
27
27
  endpoint = ":version/speak"
28
28
  ): Promise<SpeakRestClient> {
29
- try {
30
- let body;
29
+ let body;
31
30
 
32
- if (isTextSource(source)) {
33
- body = JSON.stringify(source);
34
- } else {
35
- throw new DeepgramError("Unknown transcription source type");
36
- }
31
+ if (isTextSource(source)) {
32
+ body = JSON.stringify(source);
33
+ } else {
34
+ throw new DeepgramError("Unknown transcription source type");
35
+ }
37
36
 
38
- const requestUrl = this.getRequestUrl(
39
- endpoint,
40
- {},
41
- { ...{ model: "aura-asteria-en" }, ...options }
42
- );
43
- this.result = await this.post(requestUrl, body, {
44
- headers: { Accept: "audio/*", "Content-Type": "application/json" },
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
- return this;
48
- } catch (error) {
49
- throw error;
50
- }
46
+ return this;
51
47
  }
52
48
 
53
49
  /**