-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathapi.ts
17184 lines (16729 loc) · 564 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/
export interface AssemblyAITranscriber {
/** This is the transcription provider that will be used. */
provider: 'assembly-ai';
/** This is the language that will be set for the transcription. */
language?: 'en';
/** The WebSocket URL that the transcriber connects to. */
realtimeUrl?: string;
/** Add up to 2500 characters of custom vocabulary. */
wordBoost?: string[];
/** The duration of the end utterance silence threshold in milliseconds. */
endUtteranceSilenceThreshold?: number;
/**
* Disable partial transcripts.
* Set to `true` to not receive partial transcripts. Defaults to `false`.
*/
disablePartialTranscripts?: boolean;
}
export interface Server {
/**
* This is the timeout in seconds for the request to your server. Defaults to 20 seconds.
*
* @default 20
* @min 1
* @max 120
* @example 20
*/
timeoutSeconds?: number;
/** API endpoint to send requests to. */
url: string;
/**
* This is the secret you can set that Vapi will send with every request to your server. Will be sent as a header called x-vapi-secret.
*
* Same precedence logic as server.
*/
secret?: string;
/**
* These are the custom headers to include in the request sent to your server.
*
* Each key-value pair represents a header name and its value.
*/
headers?: object;
}
export interface CustomTranscriber {
/** This is the transcription provider that will be used. Use `custom-transcriber` for providers that are not natively supported. */
provider: 'custom-transcriber';
/**
* This is where the transcription request will be sent.
*
* Usage:
* 1. Vapi will initiate a websocket connection with `server.url`.
*
* 2. Vapi will send an initial text frame with the sample rate. Format:
* ```
* {
* "type": "start",
* "encoding": "linear16", // 16-bit raw PCM format
* "container": "raw",
* "sampleRate": {{sampleRate}},
* "channels": 2 // customer is channel 0, assistant is channel 1
* }
* ```
*
* 3. Vapi will send the audio data in 16-bit raw PCM format as binary frames.
*
* 4. You can read the messages something like this:
* ```
* ws.on('message', (data, isBinary) => {
* if (isBinary) {
* pcmBuffer = Buffer.concat([pcmBuffer, data]);
* console.log(`Received PCM data, buffer size: ${pcmBuffer.length}`);
* } else {
* console.log('Received message:', JSON.parse(data.toString()));
* }
* });
* ```
*
* 5. You will respond with transcriptions as you have them. Format:
* ```
* {
* "type": "transcriber-response",
* "transcription": "Hello, world!",
* "channel": "customer" | "assistant"
* }
* ```
*/
server: Server;
}
export interface DeepgramTranscriber {
/** This is the transcription provider that will be used. */
provider: 'deepgram';
/** This is the Deepgram model that will be used. A list of models can be found here: https://developers.deepgram.com/docs/models-languages-overview */
model?:
| 'nova-2'
| 'nova-2-general'
| 'nova-2-meeting'
| 'nova-2-phonecall'
| 'nova-2-finance'
| 'nova-2-conversationalai'
| 'nova-2-voicemail'
| 'nova-2-video'
| 'nova-2-medical'
| 'nova-2-drivethru'
| 'nova-2-automotive'
| 'nova'
| 'nova-general'
| 'nova-phonecall'
| 'nova-medical'
| 'enhanced'
| 'enhanced-general'
| 'enhanced-meeting'
| 'enhanced-phonecall'
| 'enhanced-finance'
| 'base'
| 'base-general'
| 'base-meeting'
| 'base-phonecall'
| 'base-finance'
| 'base-conversationalai'
| 'base-voicemail'
| 'base-video'
| string;
/** This is the language that will be set for the transcription. The list of languages Deepgram supports can be found here: https://developers.deepgram.com/docs/models-languages-overview */
language?:
| 'bg'
| 'ca'
| 'cs'
| 'da'
| 'da-DK'
| 'de'
| 'de-CH'
| 'el'
| 'en'
| 'en-AU'
| 'en-GB'
| 'en-IN'
| 'en-NZ'
| 'en-US'
| 'es'
| 'es-419'
| 'es-LATAM'
| 'et'
| 'fi'
| 'fr'
| 'fr-CA'
| 'hi'
| 'hi-Latn'
| 'hu'
| 'id'
| 'it'
| 'ja'
| 'ko'
| 'ko-KR'
| 'lt'
| 'lv'
| 'ms'
| 'multi'
| 'nl'
| 'nl-BE'
| 'no'
| 'pl'
| 'pt'
| 'pt-BR'
| 'ro'
| 'ru'
| 'sk'
| 'sv'
| 'sv-SE'
| 'ta'
| 'taq'
| 'th'
| 'th-TH'
| 'tr'
| 'uk'
| 'vi'
| 'zh'
| 'zh-CN'
| 'zh-HK'
| 'zh-Hans'
| 'zh-Hant'
| 'zh-TW';
/**
* This will be use smart format option provided by Deepgram. It's default disabled because it can sometimes format numbers as times but it's getting better.
* @example false
*/
smartFormat?: boolean;
/**
* This automatically switches the transcriber's language when the customer's language changes. Defaults to false.
*
* Usage:
* - If your customers switch languages mid-call, you can set this to true.
*
* Note:
* - To detect language changes, Vapi uses a custom trained model. Languages supported (X = limited support):
* 1. Arabic
* 2. Bengali
* 3. Cantonese
* 4. Chinese
* 5. Chinese Simplified (X)
* 6. Chinese Traditional (X)
* 7. English
* 8. Farsi (X)
* 9. French
* 10. German
* 11. Haitian Creole (X)
* 12. Hindi
* 13. Italian
* 14. Japanese
* 15. Korean
* 16. Portuguese
* 17. Russian
* 18. Spanish
* 19. Thai
* 20. Urdu
* 21. Vietnamese
* - To receive `language-change-detected` webhook events, add it to `assistant.serverMessages`.
*
* @default false
* @example false
*/
codeSwitchingEnabled?: boolean;
/** These keywords are passed to the transcription model to help it pick up use-case specific words. Anything that may not be a common word, like your company name, should be added here. */
keywords?: string[];
/**
* This is the timeout after which Deepgram will send transcription on user silence. You can read in-depth documentation here: https://developers.deepgram.com/docs/endpointing.
*
* Here are the most important bits:
* - Defaults to 10. This is recommended for most use cases to optimize for latency.
* - 10 can cause some missing transcriptions since because of the shorter context. This mostly happens for one-word utterances. For those uses cases, it's recommended to try 300. It will add a bit of latency but the quality and reliability of the experience will be better.
* - If neither 10 nor 300 work, contact [email protected] and we'll find another solution.
*
* @default 10
* @min 10
* @max 500
*/
endpointing?: number;
}
export interface TalkscriberTranscriber {
/** This is the transcription provider that will be used. */
provider: 'talkscriber';
/** This is the model that will be used for the transcription. */
model?: 'whisper';
/** This is the language that will be set for the transcription. The list of languages Whisper supports can be found here: https://github.com/openai/whisper/blob/main/whisper/tokenizer.py */
language?:
| 'en'
| 'zh'
| 'de'
| 'es'
| 'ru'
| 'ko'
| 'fr'
| 'ja'
| 'pt'
| 'tr'
| 'pl'
| 'ca'
| 'nl'
| 'ar'
| 'sv'
| 'it'
| 'id'
| 'hi'
| 'fi'
| 'vi'
| 'he'
| 'uk'
| 'el'
| 'ms'
| 'cs'
| 'ro'
| 'da'
| 'hu'
| 'ta'
| 'no'
| 'th'
| 'ur'
| 'hr'
| 'bg'
| 'lt'
| 'la'
| 'mi'
| 'ml'
| 'cy'
| 'sk'
| 'te'
| 'fa'
| 'lv'
| 'bn'
| 'sr'
| 'az'
| 'sl'
| 'kn'
| 'et'
| 'mk'
| 'br'
| 'eu'
| 'is'
| 'hy'
| 'ne'
| 'mn'
| 'bs'
| 'kk'
| 'sq'
| 'sw'
| 'gl'
| 'mr'
| 'pa'
| 'si'
| 'km'
| 'sn'
| 'yo'
| 'so'
| 'af'
| 'oc'
| 'ka'
| 'be'
| 'tg'
| 'sd'
| 'gu'
| 'am'
| 'yi'
| 'lo'
| 'uz'
| 'fo'
| 'ht'
| 'ps'
| 'tk'
| 'nn'
| 'mt'
| 'sa'
| 'lb'
| 'my'
| 'bo'
| 'tl'
| 'mg'
| 'as'
| 'tt'
| 'haw'
| 'ln'
| 'ha'
| 'ba'
| 'jw'
| 'su'
| 'yue';
}
export interface GladiaTranscriber {
/** This is the transcription provider that will be used. */
provider: 'gladia';
/** This is the Gladia model that will be used. Default is 'fast' */
model?: 'fast' | 'accurate';
/** Defines how the transcription model detects the audio language. Default value is 'automatic single language'. */
languageBehaviour?:
| 'manual'
| 'automatic single language'
| 'automatic multiple languages';
/** Defines the language to use for the transcription. Required when languageBehaviour is 'manual'. */
language?:
| 'af'
| 'sq'
| 'am'
| 'ar'
| 'hy'
| 'as'
| 'az'
| 'ba'
| 'eu'
| 'be'
| 'bn'
| 'bs'
| 'br'
| 'bg'
| 'ca'
| 'zh'
| 'hr'
| 'cs'
| 'da'
| 'nl'
| 'en'
| 'et'
| 'fo'
| 'fi'
| 'fr'
| 'gl'
| 'ka'
| 'de'
| 'el'
| 'gu'
| 'ht'
| 'ha'
| 'haw'
| 'he'
| 'hi'
| 'hu'
| 'is'
| 'id'
| 'it'
| 'ja'
| 'jp'
| 'jv'
| 'kn'
| 'kk'
| 'km'
| 'ko'
| 'lo'
| 'la'
| 'lv'
| 'ln'
| 'lt'
| 'lb'
| 'mk'
| 'mg'
| 'ms'
| 'ml'
| 'mt'
| 'mi'
| 'mr'
| 'mn'
| 'mymr'
| 'ne'
| 'no'
| 'nn'
| 'oc'
| 'ps'
| 'fa'
| 'pl'
| 'pt'
| 'pa'
| 'ro'
| 'ru'
| 'sa'
| 'sr'
| 'sn'
| 'sd'
| 'si'
| 'sk'
| 'sl'
| 'so'
| 'es'
| 'su'
| 'sw'
| 'sv'
| 'tl'
| 'tg'
| 'ta'
| 'tt'
| 'te'
| 'th'
| 'bo'
| 'tr'
| 'tk'
| 'uk'
| 'ur'
| 'uz'
| 'vi'
| 'cy'
| 'yi'
| 'yo';
/**
* Provides a custom vocabulary to the model to improve accuracy of transcribing context specific words, technical terms, names, etc. If empty, this argument is ignored.
* ⚠️ Warning ⚠️: Please be aware that the transcription_hint field has a character limit of 600. If you provide a transcription_hint longer than 600 characters, it will be automatically truncated to meet this limit.
* @maxLength 600
* @example "custom vocabulary"
*/
transcriptionHint?: string;
/**
* If prosody is true, you will get a transcription that can contain prosodies i.e. (laugh) (giggles) (malefic laugh) (toss) (music)… Default value is false.
* @example false
*/
prosody?: boolean;
/**
* If true, audio will be pre-processed to improve accuracy but latency will increase. Default value is false.
* @example false
*/
audioEnhancer?: boolean;
}
export interface TextContent {
type: 'text';
text: string;
language:
| 'aa'
| 'ab'
| 'ae'
| 'af'
| 'ak'
| 'am'
| 'an'
| 'ar'
| 'as'
| 'av'
| 'ay'
| 'az'
| 'ba'
| 'be'
| 'bg'
| 'bh'
| 'bi'
| 'bm'
| 'bn'
| 'bo'
| 'br'
| 'bs'
| 'ca'
| 'ce'
| 'ch'
| 'co'
| 'cr'
| 'cs'
| 'cu'
| 'cv'
| 'cy'
| 'da'
| 'de'
| 'dv'
| 'dz'
| 'ee'
| 'el'
| 'en'
| 'eo'
| 'es'
| 'et'
| 'eu'
| 'fa'
| 'ff'
| 'fi'
| 'fj'
| 'fo'
| 'fr'
| 'fy'
| 'ga'
| 'gd'
| 'gl'
| 'gn'
| 'gu'
| 'gv'
| 'ha'
| 'he'
| 'hi'
| 'ho'
| 'hr'
| 'ht'
| 'hu'
| 'hy'
| 'hz'
| 'ia'
| 'id'
| 'ie'
| 'ig'
| 'ii'
| 'ik'
| 'io'
| 'is'
| 'it'
| 'iu'
| 'ja'
| 'jv'
| 'ka'
| 'kg'
| 'ki'
| 'kj'
| 'kk'
| 'kl'
| 'km'
| 'kn'
| 'ko'
| 'kr'
| 'ks'
| 'ku'
| 'kv'
| 'kw'
| 'ky'
| 'la'
| 'lb'
| 'lg'
| 'li'
| 'ln'
| 'lo'
| 'lt'
| 'lu'
| 'lv'
| 'mg'
| 'mh'
| 'mi'
| 'mk'
| 'ml'
| 'mn'
| 'mr'
| 'ms'
| 'mt'
| 'my'
| 'na'
| 'nb'
| 'nd'
| 'ne'
| 'ng'
| 'nl'
| 'nn'
| 'no'
| 'nr'
| 'nv'
| 'ny'
| 'oc'
| 'oj'
| 'om'
| 'or'
| 'os'
| 'pa'
| 'pi'
| 'pl'
| 'ps'
| 'pt'
| 'qu'
| 'rm'
| 'rn'
| 'ro'
| 'ru'
| 'rw'
| 'sa'
| 'sc'
| 'sd'
| 'se'
| 'sg'
| 'si'
| 'sk'
| 'sl'
| 'sm'
| 'sn'
| 'so'
| 'sq'
| 'sr'
| 'ss'
| 'st'
| 'su'
| 'sv'
| 'sw'
| 'ta'
| 'te'
| 'tg'
| 'th'
| 'ti'
| 'tk'
| 'tl'
| 'tn'
| 'to'
| 'tr'
| 'ts'
| 'tt'
| 'tw'
| 'ty'
| 'ug'
| 'uk'
| 'ur'
| 'uz'
| 've'
| 'vi'
| 'vo'
| 'wa'
| 'wo'
| 'xh'
| 'yi'
| 'yue'
| 'yo'
| 'za'
| 'zh'
| 'zu';
}
export interface Condition {
/** This is the operator you want to use to compare the parameter and value. */
operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
/**
* This is the name of the parameter that you want to check.
* @maxLength 1000
*/
param: string;
/**
* This is the value you want to compare against the parameter.
* @maxLength 1000
*/
value: object;
}
export interface ToolMessageStart {
/**
* This is an alternative to the `content` property. It allows to specify variants of the same content, one per language.
*
* Usage:
* - If your assistants are multilingual, you can provide content for each language.
* - If you don't provide content for a language, the first item in the array will be automatically translated to the active language at that moment.
*
* This will override the `content` property.
*/
contents?: TextContent[];
/**
* This message is triggered when the tool call starts.
*
* This message is never triggered for async tools.
*
* If this message is not provided, one of the default filler messages "Hold on a sec", "One moment", "Just a sec", "Give me a moment" or "This'll just take a sec" will be used.
*/
type: 'request-start';
/**
* This is the content that the assistant says when this message is triggered.
* @maxLength 1000
*/
content?: string;
/** This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered. */
conditions?: Condition[];
}
export interface ToolMessageComplete {
/**
* This is an alternative to the `content` property. It allows to specify variants of the same content, one per language.
*
* Usage:
* - If your assistants are multilingual, you can provide content for each language.
* - If you don't provide content for a language, the first item in the array will be automatically translated to the active language at that moment.
*
* This will override the `content` property.
*/
contents?: TextContent[];
/**
* This message is triggered when the tool call is complete.
*
* This message is triggered immediately without waiting for your server to respond for async tool calls.
*
* If this message is not provided, the model will be requested to respond.
*
* If this message is provided, only this message will be spoken and the model will not be requested to come up with a response. It's an exclusive OR.
*/
type: 'request-complete';
/**
* This is optional and defaults to "assistant".
*
* When role=assistant, `content` is said out loud.
*
* When role=system, `content` is passed to the model in a system message. Example:
* system: default one
* assistant:
* user:
* assistant:
* user:
* assistant:
* user:
* assistant: tool called
* tool: your server response
* <--- system prompt as hint
* ---> model generates response which is spoken
* This is useful when you want to provide a hint to the model about what to say next.
*/
role?: 'assistant' | 'system';
/**
* This is an optional boolean that if true, the call will end after the message is spoken. Default is false.
*
* This is ignored if `role` is set to `system`.
*
* @default false
* @example false
*/
endCallAfterSpokenEnabled?: boolean;
/**
* This is the content that the assistant says when this message is triggered.
* @maxLength 1000
*/
content?: string;
/** This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered. */
conditions?: Condition[];
}
export interface ToolMessageFailed {
/**
* This is an alternative to the `content` property. It allows to specify variants of the same content, one per language.
*
* Usage:
* - If your assistants are multilingual, you can provide content for each language.
* - If you don't provide content for a language, the first item in the array will be automatically translated to the active language at that moment.
*
* This will override the `content` property.
*/
contents?: TextContent[];
/**
* This message is triggered when the tool call fails.
*
* This message is never triggered for async tool calls.
*
* If this message is not provided, the model will be requested to respond.
*
* If this message is provided, only this message will be spoken and the model will not be requested to come up with a response. It's an exclusive OR.
*/
type: 'request-failed';
/**
* This is an optional boolean that if true, the call will end after the message is spoken. Default is false.
*
* @default false
* @example false
*/
endCallAfterSpokenEnabled?: boolean;
/**
* This is the content that the assistant says when this message is triggered.
* @maxLength 1000
*/
content?: string;
/** This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered. */
conditions?: Condition[];
}
export interface ToolMessageDelayed {
/**
* This is an alternative to the `content` property. It allows to specify variants of the same content, one per language.
*
* Usage:
* - If your assistants are multilingual, you can provide content for each language.
* - If you don't provide content for a language, the first item in the array will be automatically translated to the active language at that moment.
*
* This will override the `content` property.
*/
contents?: TextContent[];
/**
* This message is triggered when the tool call is delayed.
*
* There are the two things that can trigger this message:
* 1. The user talks with the assistant while your server is processing the request. Default is "Sorry, a few more seconds."
* 2. The server doesn't respond within `timingMilliseconds`.
*
* This message is never triggered for async tool calls.
*/
type: 'request-response-delayed';
/**
* The number of milliseconds to wait for the server response before saying this message.
* @min 100
* @max 120000
* @example 1000
*/
timingMilliseconds?: number;
/**
* This is the content that the assistant says when this message is triggered.
* @maxLength 1000
*/
content?: string;
/** This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered. */
conditions?: Condition[];
}
export interface JsonSchema {
/**
* This is the type of output you'd like.
*
* `string`, `number`, `integer`, `boolean` are the primitive types and should be obvious.
*
* `array` and `object` are more interesting and quite powerful. They allow you to define nested structures.
*
* For `array`, you can define the schema of the items in the array using the `items` property.
*
* For `object`, you can define the properties of the object using the `properties` property.
*/
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
/**
* This is required if the type is "array". This is the schema of the items in the array.
*
* This is of type JsonSchema. However, Swagger doesn't support circular references.
*/
items?: object;
/**
* This is required if the type is "object". This specifies the properties of the object.
*
* This is a map of string to JsonSchema. However, Swagger doesn't support circular references.
*/
properties?: object;
/** This is the description to help the model understand what it needs to output. */
description?: string;
/**
* This is a list of properties that are required.
*
* This only makes sense if the type is "object".
*/
required?: string[];
}
export interface OpenAIFunctionParameters {
/** This must be set to 'object'. It instructs the model to return a JSON object containing the function call properties. */
type: 'object';
/**
* This provides a description of the properties required by the function.
* JSON Schema can be used to specify expectations for each property.
* Refer to [this doc](https://ajv.js.org/json-schema.html#json-data-type) for a comprehensive guide on JSON Schema.
*/
properties: Record<string, JsonSchema>;
/** This specifies the properties that are required by the function. */
required?: string[];
}
export interface OpenAIFunction {
/**
* This is a boolean that controls whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true. Learn more about Structured Outputs in the [OpenAI guide](https://openai.com/index/introducing-structured-outputs-in-the-api/).
*
* @default false
* @default false
*/
strict?: boolean;
/**
* This is the the name of the function to be called.
*
* Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
* @maxLength 64
* @pattern /^[a-zA-Z0-9_-]{1,64}$/
*/
name: string;
/**
* This is the description of what the function does, used by the AI to choose when and how to call the function.
* @maxLength 1000
*/
description?: string;
/**
* These are the parameters the functions accepts, described as a JSON Schema object.
*
* See the [OpenAI guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema) for documentation about the format.
*
* Omitting parameters defines a function with an empty parameter list.
*/
parameters?: OpenAIFunctionParameters;
}
export interface CreateDtmfToolDTO {
/**
* This determines if the tool is async.
*
* If async, the assistant will move forward without waiting for your server to respond. This is useful if you just want to trigger something on your server.
*
* If sync, the assistant will wait for your server to respond. This is useful if want assistant to respond with the result from your server.
*
* Defaults to synchronous (`false`).
* @example false
*/
async?: boolean;
/**
* These are the messages that will be spoken to the user as the tool is running.
*
* For some tools, this is auto-filled based on special fields like `tool.destinations`. For others like the function tool, these can be custom configured.
*/
messages?: (
| ToolMessageStart
| ToolMessageComplete
| ToolMessageFailed
| ToolMessageDelayed
)[];
/** The type of tool. "dtmf" for DTMF tool. */
type: 'dtmf';
/**
* This is the function definition of the tool.
*
* For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on tool-specific fields like `tool.destinations`. But, even in those cases, you can provide a custom function definition for advanced use cases.
*
* An example of an advanced use case is if you want to customize the message that's spoken for `endCall` tool. You can specify a function where it returns an argument "reason". Then, in `messages` array, you can have many "request-complete" messages. One of these messages will be triggered if the `messages[].conditions` matches the "reason" argument.
*/
function?: OpenAIFunction;
/**
* This is the server that will be hit when this tool is requested by the model.
*
* All requests will be sent with the call object among other things. You can find more details in the Server URL documentation.
*
* This overrides the serverUrl set on the org and the phoneNumber. Order of precedence: highest tool.server.url, then assistant.serverUrl, then phoneNumber.serverUrl, then org.serverUrl.
*/
server?: Server;
}
export interface CreateEndCallToolDTO {
/**
* This determines if the tool is async.
*
* If async, the assistant will move forward without waiting for your server to respond. This is useful if you just want to trigger something on your server.
*
* If sync, the assistant will wait for your server to respond. This is useful if want assistant to respond with the result from your server.
*
* Defaults to synchronous (`false`).
* @example false
*/
async?: boolean;
/**
* These are the messages that will be spoken to the user as the tool is running.
*
* For some tools, this is auto-filled based on special fields like `tool.destinations`. For others like the function tool, these can be custom configured.
*/
messages?: (
| ToolMessageStart
| ToolMessageComplete