retell-sdk 2.2.4 → 2.2.7
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/example.js +19 -4
- package/example.js.map +1 -1
- package/models/components/agent.d.ts +3 -205
- package/models/components/agent.d.ts.map +1 -1
- package/models/components/agent.js +5 -221
- package/models/components/agent.js.map +1 -1
- package/models/components/calldetail.d.ts +33 -22
- package/models/components/calldetail.d.ts.map +1 -1
- package/models/components/calldetail.js +32 -31
- package/models/components/calldetail.js.map +1 -1
- package/models/components/index.d.ts +0 -3
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +0 -3
- package/models/components/index.js.map +1 -1
- package/models/errors/index.d.ts +1 -6
- package/models/errors/index.d.ts.map +1 -1
- package/models/errors/index.js +1 -6
- package/models/errors/index.js.map +1 -1
- package/models/errors/registercall.d.ts +218 -0
- package/models/errors/registercall.d.ts.map +1 -0
- package/models/errors/registercall.js +386 -0
- package/models/errors/registercall.js.map +1 -0
- package/models/operations/createagent.d.ts +3 -16
- package/models/operations/createagent.d.ts.map +1 -1
- package/models/operations/createagent.js +4 -22
- package/models/operations/createagent.js.map +1 -1
- package/models/operations/getcall.d.ts +1 -1
- package/models/operations/index.d.ts +1 -7
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +1 -7
- package/models/operations/index.js.map +1 -1
- package/models/operations/listcalls.d.ts +1 -7
- package/models/operations/listcalls.d.ts.map +1 -1
- package/models/operations/listcalls.js +0 -4
- package/models/operations/listcalls.js.map +1 -1
- package/models/operations/registercall.d.ts +74 -0
- package/models/operations/registercall.d.ts.map +1 -0
- package/models/operations/registercall.js +104 -0
- package/models/operations/registercall.js.map +1 -0
- package/models/operations/updateagent.d.ts +3 -16
- package/models/operations/updateagent.d.ts.map +1 -1
- package/models/operations/updateagent.js +7 -25
- package/models/operations/updateagent.js.map +1 -1
- package/package.json +4 -2
- package/sdk/audioWsClient.d.ts +10 -0
- package/sdk/audioWsClient.d.ts.map +1 -0
- package/sdk/audioWsClient.js +66 -0
- package/sdk/audioWsClient.js.map +1 -0
- package/sdk/index.d.ts +1 -1
- package/sdk/index.d.ts.map +1 -1
- package/sdk/index.js +1 -1
- package/sdk/index.js.map +1 -1
- package/sdk/sdk.d.ts +1 -23
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +11 -437
- package/sdk/sdk.js.map +1 -1
- package/src/example.ts +26 -4
- package/src/models/components/agent.ts +8 -460
- package/src/models/components/calldetail.ts +47 -42
- package/src/models/components/index.ts +0 -3
- package/src/models/errors/index.ts +1 -6
- package/src/models/errors/{createphonecall.ts → registercall.ts} +60 -60
- package/src/models/operations/createagent.ts +8 -50
- package/src/models/operations/getcall.ts +1 -1
- package/src/models/operations/index.ts +1 -7
- package/src/models/operations/listcalls.ts +1 -11
- package/src/models/operations/registercall.ts +167 -0
- package/src/models/operations/updateagent.ts +11 -58
- package/src/sdk/audioWsClient.ts +68 -0
- package/src/sdk/index.ts +1 -1
- package/src/sdk/sdk.ts +13 -526
- package/src/models/components/agentpromptparams.ts +0 -61
- package/src/models/components/callphonenumber.ts +0 -64
- package/src/models/components/phonenumber.ts +0 -84
- package/src/models/errors/createphonenumber.ts +0 -552
- package/src/models/errors/deletephonenumber.ts +0 -442
- package/src/models/errors/getphonenumber.ts +0 -442
- package/src/models/errors/listphonenumbers.ts +0 -332
- package/src/models/errors/updatephoneagent.ts +0 -442
- package/src/models/operations/createphonecall.ts +0 -353
- package/src/models/operations/createphonenumber.ts +0 -144
- package/src/models/operations/createwebcall.ts +0 -16
- package/src/models/operations/deletephonenumber.ts +0 -119
- package/src/models/operations/getphonenumber.ts +0 -134
- package/src/models/operations/listphonenumbers.ts +0 -88
- package/src/models/operations/updatephoneagent.ts +0 -187
- package/src/sdk/liveClient.ts +0 -113
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as components from "../../models/components";
|
|
6
|
-
import { Function } from "../../models/components";
|
|
7
6
|
import { z } from "zod";
|
|
8
7
|
|
|
9
8
|
export type CreateAgentRequestBody = {
|
|
@@ -12,22 +11,13 @@ export type CreateAgentRequestBody = {
|
|
|
12
11
|
*/
|
|
13
12
|
agentName?: string | undefined;
|
|
14
13
|
/*
|
|
15
|
-
*
|
|
16
|
-
* response generation system.
|
|
14
|
+
* The URL we will establish LLM websocket for getting response, usually your server.
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Setting combination that controls interaction flow, like begin and end logic.
|
|
21
|
-
*/
|
|
22
|
-
interactionSetting?: components.InteractionSettingRequest | undefined;
|
|
16
|
+
llmWebsocketUrl: string;
|
|
23
17
|
/**
|
|
24
18
|
* Unique voice id used for the agent. Find list of available voices in documentation.
|
|
25
19
|
*/
|
|
26
20
|
voiceId: string;
|
|
27
|
-
/**
|
|
28
|
-
* Functions are the actions that the agent can perform, like booking appointments, retriving information, etc. By setting this field, either OpenAI's function calling feature or your own custom LLM's logic would determine when the function shall get called, and our server would make the call.
|
|
29
|
-
*/
|
|
30
|
-
functions?: Function[] | undefined;
|
|
31
21
|
};
|
|
32
22
|
|
|
33
23
|
export type CreateAgentResponse = {
|
|
@@ -53,14 +43,8 @@ export type CreateAgentResponse = {
|
|
|
53
43
|
export namespace CreateAgentRequestBody$ {
|
|
54
44
|
export type Inbound = {
|
|
55
45
|
agent_name?: string | undefined;
|
|
56
|
-
|
|
57
|
-
| components.RetellLlmSetting$.Inbound
|
|
58
|
-
| components.CustomLlmSetting$.Inbound;
|
|
59
|
-
interaction_setting?:
|
|
60
|
-
| components.InteractionSettingRequest$.Inbound
|
|
61
|
-
| undefined;
|
|
46
|
+
llm_websocket_url: string;
|
|
62
47
|
voice_id: string;
|
|
63
|
-
functions?: Function[] | undefined;
|
|
64
48
|
};
|
|
65
49
|
|
|
66
50
|
export const inboundSchema: z.ZodType<
|
|
@@ -70,37 +54,21 @@ export namespace CreateAgentRequestBody$ {
|
|
|
70
54
|
> = z
|
|
71
55
|
.object({
|
|
72
56
|
agent_name: z.string().optional(),
|
|
73
|
-
|
|
74
|
-
components.RetellLlmSetting$.inboundSchema,
|
|
75
|
-
components.CustomLlmSetting$.inboundSchema,
|
|
76
|
-
]),
|
|
77
|
-
interaction_setting:
|
|
78
|
-
components.InteractionSettingRequest$.inboundSchema.optional(),
|
|
57
|
+
llm_websocket_url: z.string(),
|
|
79
58
|
voice_id: z.string(),
|
|
80
|
-
functions: z.array(components.Function$.inboundSchema).optional(),
|
|
81
59
|
})
|
|
82
60
|
.transform((v) => {
|
|
83
61
|
return {
|
|
84
62
|
...(v.agent_name === undefined ? null : { agentName: v.agent_name }),
|
|
85
|
-
|
|
86
|
-
...(v.interaction_setting === undefined
|
|
87
|
-
? null
|
|
88
|
-
: { interactionSetting: v.interaction_setting }),
|
|
63
|
+
llmWebsocketUrl: v.llm_websocket_url,
|
|
89
64
|
voiceId: v.voice_id,
|
|
90
|
-
...(v.functions === undefined ? null : { functions: v.functions }),
|
|
91
65
|
};
|
|
92
66
|
});
|
|
93
67
|
|
|
94
68
|
export type Outbound = {
|
|
95
69
|
agent_name?: string | undefined;
|
|
96
|
-
|
|
97
|
-
| components.RetellLlmSetting$.Inbound
|
|
98
|
-
| components.CustomLlmSetting$.Inbound;
|
|
99
|
-
interaction_setting?:
|
|
100
|
-
| components.InteractionSettingRequest$.Inbound
|
|
101
|
-
| undefined;
|
|
70
|
+
llm_websocket_url: string;
|
|
102
71
|
voice_id: string;
|
|
103
|
-
functions?: Function[] | undefined;
|
|
104
72
|
};
|
|
105
73
|
|
|
106
74
|
export const outboundSchema: z.ZodType<
|
|
@@ -110,24 +78,14 @@ export namespace CreateAgentRequestBody$ {
|
|
|
110
78
|
> = z
|
|
111
79
|
.object({
|
|
112
80
|
agentName: z.string().optional(),
|
|
113
|
-
|
|
114
|
-
components.RetellLlmSetting$.outboundSchema,
|
|
115
|
-
components.CustomLlmSetting$.outboundSchema,
|
|
116
|
-
]),
|
|
117
|
-
interactionSetting:
|
|
118
|
-
components.InteractionSettingRequest$.outboundSchema.optional(),
|
|
81
|
+
llmWebsocketUrl: z.string(),
|
|
119
82
|
voiceId: z.string(),
|
|
120
|
-
functions: z.array(components.Function$.inboundSchema).optional(),
|
|
121
83
|
})
|
|
122
84
|
.transform((v) => {
|
|
123
85
|
return {
|
|
124
86
|
...(v.agentName === undefined ? null : { agent_name: v.agentName }),
|
|
125
|
-
|
|
126
|
-
...(v.interactionSetting === undefined
|
|
127
|
-
? null
|
|
128
|
-
: { interaction_setting: v.interactionSetting }),
|
|
87
|
+
llm_websocket_url: v.llmWebsocketUrl,
|
|
129
88
|
voice_id: v.voiceId,
|
|
130
|
-
...(v.functions === undefined ? null : { functions: v.functions }),
|
|
131
89
|
};
|
|
132
90
|
});
|
|
133
91
|
}
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export * from "./createagent";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./createwebcall";
|
|
8
|
-
export * from "./createphonenumber";
|
|
6
|
+
export * from "./registercall";
|
|
9
7
|
export * from "./deleteagent";
|
|
10
|
-
export * from "./deletephonenumber";
|
|
11
8
|
export * from "./getagent";
|
|
12
9
|
export * from "./getcall";
|
|
13
|
-
export * from "./getphonenumber";
|
|
14
10
|
export * from "./listagents";
|
|
15
11
|
export * from "./listcalls";
|
|
16
|
-
export * from "./listphonenumbers";
|
|
17
12
|
export * from "./updateagent";
|
|
18
|
-
export * from "./updatephoneagent";
|
|
@@ -32,10 +32,6 @@ export type FilterCriteria = {
|
|
|
32
32
|
* Exclusive. Filter calls that start before this timestamp.
|
|
33
33
|
*/
|
|
34
34
|
beforeStartTimestamp?: number | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Only retrieve calls of specific type(s).
|
|
37
|
-
*/
|
|
38
|
-
callType?: Array<CallType> | undefined;
|
|
39
35
|
};
|
|
40
36
|
|
|
41
37
|
/**
|
|
@@ -72,7 +68,7 @@ export type ListCallsResponse = {
|
|
|
72
68
|
*/
|
|
73
69
|
rawResponse: Response;
|
|
74
70
|
/**
|
|
75
|
-
* Successfully retrieved all
|
|
71
|
+
* Successfully retrieved all calls.
|
|
76
72
|
*/
|
|
77
73
|
calls?: Array<components.CallDetail> | undefined;
|
|
78
74
|
};
|
|
@@ -88,7 +84,6 @@ export namespace FilterCriteria$ {
|
|
|
88
84
|
agent_id?: Array<string> | undefined;
|
|
89
85
|
before_end_timestamp?: number | undefined;
|
|
90
86
|
before_start_timestamp?: number | undefined;
|
|
91
|
-
call_type?: Array<CallType> | undefined;
|
|
92
87
|
};
|
|
93
88
|
|
|
94
89
|
export const inboundSchema: z.ZodType<FilterCriteria, z.ZodTypeDef, Inbound> =
|
|
@@ -99,7 +94,6 @@ export namespace FilterCriteria$ {
|
|
|
99
94
|
agent_id: z.array(z.string()).optional(),
|
|
100
95
|
before_end_timestamp: z.number().int().optional(),
|
|
101
96
|
before_start_timestamp: z.number().int().optional(),
|
|
102
|
-
call_type: z.array(CallType$).optional(),
|
|
103
97
|
})
|
|
104
98
|
.transform((v) => {
|
|
105
99
|
return {
|
|
@@ -116,7 +110,6 @@ export namespace FilterCriteria$ {
|
|
|
116
110
|
...(v.before_start_timestamp === undefined
|
|
117
111
|
? null
|
|
118
112
|
: { beforeStartTimestamp: v.before_start_timestamp }),
|
|
119
|
-
...(v.call_type === undefined ? null : { callType: v.call_type }),
|
|
120
113
|
};
|
|
121
114
|
});
|
|
122
115
|
|
|
@@ -126,7 +119,6 @@ export namespace FilterCriteria$ {
|
|
|
126
119
|
agent_id?: Array<string> | undefined;
|
|
127
120
|
before_end_timestamp?: number | undefined;
|
|
128
121
|
before_start_timestamp?: number | undefined;
|
|
129
|
-
call_type?: Array<CallType> | undefined;
|
|
130
122
|
};
|
|
131
123
|
|
|
132
124
|
export const outboundSchema: z.ZodType<
|
|
@@ -140,7 +132,6 @@ export namespace FilterCriteria$ {
|
|
|
140
132
|
agentId: z.array(z.string()).optional(),
|
|
141
133
|
beforeEndTimestamp: z.number().int().optional(),
|
|
142
134
|
beforeStartTimestamp: z.number().int().optional(),
|
|
143
|
-
callType: z.array(CallType$).optional(),
|
|
144
135
|
})
|
|
145
136
|
.transform((v) => {
|
|
146
137
|
return {
|
|
@@ -157,7 +148,6 @@ export namespace FilterCriteria$ {
|
|
|
157
148
|
...(v.beforeStartTimestamp === undefined
|
|
158
149
|
? null
|
|
159
150
|
: { before_start_timestamp: v.beforeStartTimestamp }),
|
|
160
|
-
...(v.callType === undefined ? null : { call_type: v.callType }),
|
|
161
151
|
};
|
|
162
152
|
});
|
|
163
153
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AudioEncoding,
|
|
7
|
+
AudioWebsocketProtocol,
|
|
8
|
+
AudioEncoding$,
|
|
9
|
+
AudioWebsocketProtocol$,
|
|
10
|
+
} from "../../models/components";
|
|
11
|
+
import * as components from "../../models/components";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
export type RegisterCallRequestBody = {
|
|
15
|
+
/**
|
|
16
|
+
* Corresponding agent id of this call.
|
|
17
|
+
*/
|
|
18
|
+
agentId: string;
|
|
19
|
+
/**
|
|
20
|
+
* The audio encoding of the call.
|
|
21
|
+
*/
|
|
22
|
+
audioEncoding: AudioEncoding;
|
|
23
|
+
/**
|
|
24
|
+
* Sample rate of the conversation, the input and output audio bytes will all conform to this rate. Check the audio source, audio format, and voice used for the agent to select one that works.
|
|
25
|
+
*/
|
|
26
|
+
sampleRate: number;
|
|
27
|
+
/**
|
|
28
|
+
* The protocol how audio websocket read and send audio bytes.
|
|
29
|
+
*/
|
|
30
|
+
audioWebsocketProtocol: AudioWebsocketProtocol;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RegisterCallResponse = {
|
|
34
|
+
/**
|
|
35
|
+
* Successfully retrieved a call.
|
|
36
|
+
*/
|
|
37
|
+
callDetail?: components.CallDetail | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* HTTP response content type for this operation
|
|
40
|
+
*/
|
|
41
|
+
contentType: string;
|
|
42
|
+
/**
|
|
43
|
+
* HTTP response status code for this operation
|
|
44
|
+
*/
|
|
45
|
+
statusCode: number;
|
|
46
|
+
/**
|
|
47
|
+
* Raw HTTP response; suitable for custom response parsing
|
|
48
|
+
*/
|
|
49
|
+
rawResponse: Response;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** @internal */
|
|
53
|
+
export namespace RegisterCallRequestBody$ {
|
|
54
|
+
export type Inbound = {
|
|
55
|
+
agent_id: string;
|
|
56
|
+
audio_encoding: AudioEncoding;
|
|
57
|
+
sample_rate: number;
|
|
58
|
+
audio_websocket_protocol: AudioWebsocketProtocol;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const inboundSchema: z.ZodType<
|
|
62
|
+
RegisterCallRequestBody,
|
|
63
|
+
z.ZodTypeDef,
|
|
64
|
+
Inbound
|
|
65
|
+
> = z
|
|
66
|
+
.object({
|
|
67
|
+
agent_id: z.string(),
|
|
68
|
+
call_id: z.string(),
|
|
69
|
+
audio_encoding: AudioEncoding$,
|
|
70
|
+
sample_rate: z.number().int(),
|
|
71
|
+
audio_websocket_protocol: AudioWebsocketProtocol$,
|
|
72
|
+
})
|
|
73
|
+
.transform((v) => {
|
|
74
|
+
return {
|
|
75
|
+
agentId: v.agent_id,
|
|
76
|
+
audioEncoding: v.audio_encoding,
|
|
77
|
+
sampleRate: v.sample_rate,
|
|
78
|
+
audioWebsocketProtocol: v.audio_websocket_protocol,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export type Outbound = {
|
|
83
|
+
agent_id: string;
|
|
84
|
+
audio_encoding: components.AudioEncoding;
|
|
85
|
+
sample_rate: number;
|
|
86
|
+
audio_websocket_protocol: components.AudioWebsocketProtocol;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const outboundSchema: z.ZodType<
|
|
90
|
+
Outbound,
|
|
91
|
+
z.ZodTypeDef,
|
|
92
|
+
RegisterCallRequestBody
|
|
93
|
+
> = z
|
|
94
|
+
.object({
|
|
95
|
+
agentId: z.string(),
|
|
96
|
+
audioEncoding: AudioEncoding$,
|
|
97
|
+
sampleRate: z.number().int(),
|
|
98
|
+
audioWebsocketProtocol: AudioWebsocketProtocol$,
|
|
99
|
+
})
|
|
100
|
+
.transform((v) => {
|
|
101
|
+
return {
|
|
102
|
+
agent_id: v.agentId,
|
|
103
|
+
audio_encoding: v.audioEncoding,
|
|
104
|
+
sample_rate: v.sampleRate,
|
|
105
|
+
audio_websocket_protocol: v.audioWebsocketProtocol,
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** @internal */
|
|
111
|
+
export namespace RegisterCallResponse$ {
|
|
112
|
+
export type Inbound = {
|
|
113
|
+
CallDetail?: components.CallDetail$.Inbound | undefined;
|
|
114
|
+
ContentType: string;
|
|
115
|
+
StatusCode: number;
|
|
116
|
+
RawResponse: Response;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const inboundSchema: z.ZodType<
|
|
120
|
+
RegisterCallResponse,
|
|
121
|
+
z.ZodTypeDef,
|
|
122
|
+
Inbound
|
|
123
|
+
> = z
|
|
124
|
+
.object({
|
|
125
|
+
CallDetail: components.CallDetail$.inboundSchema.optional(),
|
|
126
|
+
ContentType: z.string(),
|
|
127
|
+
StatusCode: z.number().int(),
|
|
128
|
+
RawResponse: z.instanceof(Response),
|
|
129
|
+
})
|
|
130
|
+
.transform((v) => {
|
|
131
|
+
return {
|
|
132
|
+
...(v.CallDetail === undefined ? null : { callDetail: v.CallDetail }),
|
|
133
|
+
contentType: v.ContentType,
|
|
134
|
+
statusCode: v.StatusCode,
|
|
135
|
+
rawResponse: v.RawResponse,
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export type Outbound = {
|
|
140
|
+
CallDetail?: components.CallDetail$.Outbound | undefined;
|
|
141
|
+
ContentType: string;
|
|
142
|
+
StatusCode: number;
|
|
143
|
+
RawResponse: never;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const outboundSchema: z.ZodType<
|
|
147
|
+
Outbound,
|
|
148
|
+
z.ZodTypeDef,
|
|
149
|
+
RegisterCallResponse
|
|
150
|
+
> = z
|
|
151
|
+
.object({
|
|
152
|
+
callDetail: components.CallDetail$.outboundSchema.optional(),
|
|
153
|
+
contentType: z.string(),
|
|
154
|
+
statusCode: z.number().int(),
|
|
155
|
+
rawResponse: z.instanceof(Response).transform(() => {
|
|
156
|
+
throw new Error("Response cannot be serialized");
|
|
157
|
+
}),
|
|
158
|
+
})
|
|
159
|
+
.transform((v) => {
|
|
160
|
+
return {
|
|
161
|
+
...(v.callDetail === undefined ? null : { CallDetail: v.callDetail }),
|
|
162
|
+
ContentType: v.contentType,
|
|
163
|
+
StatusCode: v.statusCode,
|
|
164
|
+
RawResponse: v.rawResponse,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as components from "../../models/components";
|
|
6
|
-
import { Function } from "../../models/components";
|
|
7
6
|
import { z } from "zod";
|
|
8
7
|
|
|
9
8
|
export type UpdateAgentRequestBody = {
|
|
@@ -12,40 +11,21 @@ export type UpdateAgentRequestBody = {
|
|
|
12
11
|
*/
|
|
13
12
|
agentName?: string | undefined;
|
|
14
13
|
/*
|
|
15
|
-
*
|
|
16
|
-
* response generation system.
|
|
14
|
+
* The URL we will establish LLM websocket for getting response, usually your server.
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
| components.RetellLlmSetting
|
|
20
|
-
| components.CustomLlmSetting
|
|
21
|
-
| undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Setting combination that controls interaction flow, like begin and end logic.
|
|
24
|
-
*/
|
|
25
|
-
interactionSetting?: components.InteractionSettingRequest | undefined;
|
|
16
|
+
llmWebsocketUrl?: string | undefined;
|
|
26
17
|
/**
|
|
27
18
|
* Unique voice id used for the agent. Find list of available voices in documentation.
|
|
28
19
|
*/
|
|
29
20
|
voiceId?: string | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Functions are the actions that the agent can perform, like booking appointments, retriving information, etc. By setting this field, either OpenAI's function calling feature or your own custom LLM's logic would determine when the function shall get called, and our server would make the call.
|
|
32
|
-
*/
|
|
33
|
-
functions?: Function[] | undefined;
|
|
34
21
|
};
|
|
35
22
|
|
|
36
23
|
/** @internal */
|
|
37
24
|
export namespace UpdateAgentRequestBody$ {
|
|
38
25
|
export type Inbound = {
|
|
39
26
|
agent_name?: string | undefined;
|
|
40
|
-
|
|
41
|
-
| components.RetellLlmSetting$.Inbound
|
|
42
|
-
| components.CustomLlmSetting$.Inbound
|
|
43
|
-
| undefined;
|
|
44
|
-
interaction_setting?:
|
|
45
|
-
| components.InteractionSettingRequest$.Inbound
|
|
46
|
-
| undefined;
|
|
27
|
+
llm_websocket_url?: string | undefined;
|
|
47
28
|
voice_id?: string | undefined;
|
|
48
|
-
functions?: Function[] | undefined;
|
|
49
29
|
};
|
|
50
30
|
|
|
51
31
|
export const inboundSchema: z.ZodType<
|
|
@@ -55,40 +35,23 @@ export namespace UpdateAgentRequestBody$ {
|
|
|
55
35
|
> = z
|
|
56
36
|
.object({
|
|
57
37
|
agent_name: z.string().optional(),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
components.RetellLlmSetting$.inboundSchema,
|
|
61
|
-
components.CustomLlmSetting$.inboundSchema,
|
|
62
|
-
])
|
|
63
|
-
.optional(),
|
|
64
|
-
interaction_setting:
|
|
65
|
-
components.InteractionSettingRequest$.inboundSchema.optional(),
|
|
66
|
-
voice_id: z.string().optional(),
|
|
67
|
-
functions: z.array(components.Function$.inboundSchema).optional(),
|
|
38
|
+
llm_websocket_url: z.string(),
|
|
39
|
+
voice_id: z.string(),
|
|
68
40
|
})
|
|
69
41
|
.transform((v) => {
|
|
70
42
|
return {
|
|
71
43
|
...(v.agent_name === undefined ? null : { agentName: v.agent_name }),
|
|
72
|
-
...(v.
|
|
73
|
-
...(v.interaction_setting === undefined
|
|
44
|
+
...(v.llm_websocket_url === undefined
|
|
74
45
|
? null
|
|
75
|
-
: {
|
|
46
|
+
: { llmWebsocketUrl: v.llm_websocket_url }),
|
|
76
47
|
...(v.voice_id === undefined ? null : { voiceId: v.voice_id }),
|
|
77
|
-
...(v.functions === undefined ? null : { functions: v.functions }),
|
|
78
48
|
};
|
|
79
49
|
});
|
|
80
50
|
|
|
81
51
|
export type Outbound = {
|
|
82
52
|
agent_name?: string | undefined;
|
|
83
|
-
|
|
84
|
-
| components.RetellLlmSetting$.Outbound
|
|
85
|
-
| components.CustomLlmSetting$.Outbound
|
|
86
|
-
| undefined;
|
|
87
|
-
interaction_setting?:
|
|
88
|
-
| components.InteractionSettingRequest$.Outbound
|
|
89
|
-
| undefined;
|
|
53
|
+
llm_websocket_url?: string | undefined;
|
|
90
54
|
voice_id?: string | undefined;
|
|
91
|
-
functions?: Function[] | undefined;
|
|
92
55
|
};
|
|
93
56
|
|
|
94
57
|
export const outboundSchema: z.ZodType<
|
|
@@ -98,26 +61,16 @@ export namespace UpdateAgentRequestBody$ {
|
|
|
98
61
|
> = z
|
|
99
62
|
.object({
|
|
100
63
|
agentName: z.string().optional(),
|
|
101
|
-
|
|
102
|
-
.union([
|
|
103
|
-
components.RetellLlmSetting$.outboundSchema,
|
|
104
|
-
components.CustomLlmSetting$.outboundSchema,
|
|
105
|
-
])
|
|
106
|
-
.optional(),
|
|
107
|
-
interactionSetting:
|
|
108
|
-
components.InteractionSettingRequest$.outboundSchema.optional(),
|
|
64
|
+
llmWebsocketUrl: z.string().optional(),
|
|
109
65
|
voiceId: z.string().optional(),
|
|
110
|
-
functions: z.array(components.Function$.inboundSchema).optional(),
|
|
111
66
|
})
|
|
112
67
|
.transform((v) => {
|
|
113
68
|
return {
|
|
114
69
|
...(v.agentName === undefined ? null : { agent_name: v.agentName }),
|
|
115
|
-
...(v.
|
|
116
|
-
...(v.interactionSetting === undefined
|
|
70
|
+
...(v.llmWebsocketUrl === undefined
|
|
117
71
|
? null
|
|
118
|
-
: {
|
|
72
|
+
: { llm_websocket_url: v.llmWebsocketUrl }),
|
|
119
73
|
...(v.voiceId === undefined ? null : { voice_id: v.voiceId }),
|
|
120
|
-
...(v.functions === undefined ? null : { functions: v.functions }),
|
|
121
74
|
};
|
|
122
75
|
});
|
|
123
76
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { EventEmitter } from "eventemitter3";
|
|
2
|
+
import WebSocket from "isomorphic-ws";
|
|
3
|
+
|
|
4
|
+
let baseEndpoint = "wss://api.re-tell.ai/audio-websocket/";
|
|
5
|
+
|
|
6
|
+
export class AudioWsClient extends EventEmitter {
|
|
7
|
+
private ws: WebSocket;
|
|
8
|
+
|
|
9
|
+
constructor(callId: string, customEndpoint?: string) {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
if (customEndpoint) baseEndpoint = customEndpoint;
|
|
13
|
+
const endpoint = baseEndpoint + callId;
|
|
14
|
+
this.ws = new WebSocket(endpoint);
|
|
15
|
+
this.ws.binaryType = "arraybuffer";
|
|
16
|
+
|
|
17
|
+
this.ws.onmessage = (event) => {
|
|
18
|
+
const eventStr = event.data.toString();
|
|
19
|
+
if (eventStr === "clear") {
|
|
20
|
+
this.emit("clear");
|
|
21
|
+
} else {
|
|
22
|
+
const audio: ArrayBuffer = event.data as ArrayBuffer;
|
|
23
|
+
this.emit("audio", new Uint8Array(audio));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.ws.onclose = (event) => {
|
|
27
|
+
this.emit("close", event.code, event.reason);
|
|
28
|
+
};
|
|
29
|
+
this.ws.onerror = (event) => {
|
|
30
|
+
this.emit("error", event.error);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
send(audio: Uint8Array) {
|
|
35
|
+
if (this.ws.readyState === 1) {
|
|
36
|
+
this.ws.send(audio);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
close() {
|
|
41
|
+
this.ws.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function convertUint8ToFloat32(array: Uint8Array): Float32Array {
|
|
46
|
+
const targetArray = new Float32Array(array.byteLength / 2);
|
|
47
|
+
|
|
48
|
+
// A DataView is used to read our 16-bit little-endian samples out of the Uint8Array buffer
|
|
49
|
+
const sourceDataView = new DataView(array.buffer);
|
|
50
|
+
|
|
51
|
+
// Loop through, get values, and divide by 32,768
|
|
52
|
+
for (let i = 0; i < targetArray.length; i++) {
|
|
53
|
+
targetArray[i] = sourceDataView.getInt16(i * 2, true) / Math.pow(2, 16 - 1);
|
|
54
|
+
}
|
|
55
|
+
return targetArray;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function convertFloat32ToUint8(array: Float32Array): Uint8Array {
|
|
59
|
+
const buffer = new ArrayBuffer(array.length * 2);
|
|
60
|
+
const view = new DataView(buffer);
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < array.length; i++) {
|
|
63
|
+
const value = (array[i] as number) * 32768;
|
|
64
|
+
view.setInt16(i * 2, value, true); // true for little-endian
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new Uint8Array(buffer);
|
|
68
|
+
}
|
package/src/sdk/index.ts
CHANGED