@fonoster/apiserver 0.8.51 → 0.8.56
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/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +260 -0
- package/dist/applications/validation/createValidationSchema.d.ts +440 -0
- package/dist/voice/VoiceClientImpl.d.ts +2 -2
- package/dist/voice/handlers/createStreamGatherHandler.js +5 -3
- package/dist/voice/handlers/gather/createGatherHandler.js +6 -5
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +1 -1
- package/dist/voice/stt/Deepgram.js +11 -2
- package/dist/voice/stt/Google.js +6 -2
- package/dist/voice/stt/types.d.ts +1 -0
- package/dist/voice/tts/ElevenLabs.js +3 -1
- package/dist/voice/types/voice.d.ts +2 -1
- package/package.json +9 -9
|
@@ -294,6 +294,206 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
294
294
|
};
|
|
295
295
|
}[];
|
|
296
296
|
}>;
|
|
297
|
+
testCases: z.ZodOptional<z.ZodObject<{
|
|
298
|
+
evalsLanguageModel: z.ZodObject<{
|
|
299
|
+
provider: z.ZodEnum<["openai"]>;
|
|
300
|
+
model: z.ZodString;
|
|
301
|
+
apiKey: z.ZodString;
|
|
302
|
+
}, "strip", z.ZodTypeAny, {
|
|
303
|
+
provider?: "openai";
|
|
304
|
+
apiKey?: string;
|
|
305
|
+
model?: string;
|
|
306
|
+
}, {
|
|
307
|
+
provider?: "openai";
|
|
308
|
+
apiKey?: string;
|
|
309
|
+
model?: string;
|
|
310
|
+
}>;
|
|
311
|
+
evalsSystemPrompt: z.ZodOptional<z.ZodString>;
|
|
312
|
+
scenarios: z.ZodArray<z.ZodObject<{
|
|
313
|
+
ref: z.ZodString;
|
|
314
|
+
description: z.ZodString;
|
|
315
|
+
telephonyContext: z.ZodObject<{
|
|
316
|
+
callDirection: z.ZodNativeEnum<typeof import("@fonoster/types").CallDirection>;
|
|
317
|
+
ingressNumber: z.ZodString;
|
|
318
|
+
callerNumber: z.ZodString;
|
|
319
|
+
}, "strip", z.ZodTypeAny, {
|
|
320
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
321
|
+
ingressNumber?: string;
|
|
322
|
+
callerNumber?: string;
|
|
323
|
+
}, {
|
|
324
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
325
|
+
ingressNumber?: string;
|
|
326
|
+
callerNumber?: string;
|
|
327
|
+
}>;
|
|
328
|
+
conversation: z.ZodArray<z.ZodObject<{
|
|
329
|
+
userInput: z.ZodString;
|
|
330
|
+
expected: z.ZodObject<{
|
|
331
|
+
text: z.ZodObject<{
|
|
332
|
+
type: z.ZodEnum<["exact", "similar"]>;
|
|
333
|
+
response: z.ZodString;
|
|
334
|
+
}, "strip", z.ZodTypeAny, {
|
|
335
|
+
type?: "exact" | "similar";
|
|
336
|
+
response?: string;
|
|
337
|
+
}, {
|
|
338
|
+
type?: "exact" | "similar";
|
|
339
|
+
response?: string;
|
|
340
|
+
}>;
|
|
341
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
342
|
+
tool: z.ZodString;
|
|
343
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
344
|
+
}, "strip", z.ZodTypeAny, {
|
|
345
|
+
parameters?: Record<string, any>;
|
|
346
|
+
tool?: string;
|
|
347
|
+
}, {
|
|
348
|
+
parameters?: Record<string, any>;
|
|
349
|
+
tool?: string;
|
|
350
|
+
}>, "many">>;
|
|
351
|
+
}, "strip", z.ZodTypeAny, {
|
|
352
|
+
tools?: {
|
|
353
|
+
parameters?: Record<string, any>;
|
|
354
|
+
tool?: string;
|
|
355
|
+
}[];
|
|
356
|
+
text?: {
|
|
357
|
+
type?: "exact" | "similar";
|
|
358
|
+
response?: string;
|
|
359
|
+
};
|
|
360
|
+
}, {
|
|
361
|
+
tools?: {
|
|
362
|
+
parameters?: Record<string, any>;
|
|
363
|
+
tool?: string;
|
|
364
|
+
}[];
|
|
365
|
+
text?: {
|
|
366
|
+
type?: "exact" | "similar";
|
|
367
|
+
response?: string;
|
|
368
|
+
};
|
|
369
|
+
}>;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
expected?: {
|
|
372
|
+
tools?: {
|
|
373
|
+
parameters?: Record<string, any>;
|
|
374
|
+
tool?: string;
|
|
375
|
+
}[];
|
|
376
|
+
text?: {
|
|
377
|
+
type?: "exact" | "similar";
|
|
378
|
+
response?: string;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
userInput?: string;
|
|
382
|
+
}, {
|
|
383
|
+
expected?: {
|
|
384
|
+
tools?: {
|
|
385
|
+
parameters?: Record<string, any>;
|
|
386
|
+
tool?: string;
|
|
387
|
+
}[];
|
|
388
|
+
text?: {
|
|
389
|
+
type?: "exact" | "similar";
|
|
390
|
+
response?: string;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
userInput?: string;
|
|
394
|
+
}>, "many">;
|
|
395
|
+
}, "strip", z.ZodTypeAny, {
|
|
396
|
+
description?: string;
|
|
397
|
+
ref?: string;
|
|
398
|
+
telephonyContext?: {
|
|
399
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
400
|
+
ingressNumber?: string;
|
|
401
|
+
callerNumber?: string;
|
|
402
|
+
};
|
|
403
|
+
conversation?: {
|
|
404
|
+
expected?: {
|
|
405
|
+
tools?: {
|
|
406
|
+
parameters?: Record<string, any>;
|
|
407
|
+
tool?: string;
|
|
408
|
+
}[];
|
|
409
|
+
text?: {
|
|
410
|
+
type?: "exact" | "similar";
|
|
411
|
+
response?: string;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
userInput?: string;
|
|
415
|
+
}[];
|
|
416
|
+
}, {
|
|
417
|
+
description?: string;
|
|
418
|
+
ref?: string;
|
|
419
|
+
telephonyContext?: {
|
|
420
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
421
|
+
ingressNumber?: string;
|
|
422
|
+
callerNumber?: string;
|
|
423
|
+
};
|
|
424
|
+
conversation?: {
|
|
425
|
+
expected?: {
|
|
426
|
+
tools?: {
|
|
427
|
+
parameters?: Record<string, any>;
|
|
428
|
+
tool?: string;
|
|
429
|
+
}[];
|
|
430
|
+
text?: {
|
|
431
|
+
type?: "exact" | "similar";
|
|
432
|
+
response?: string;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
userInput?: string;
|
|
436
|
+
}[];
|
|
437
|
+
}>, "many">;
|
|
438
|
+
}, "strip", z.ZodTypeAny, {
|
|
439
|
+
evalsLanguageModel?: {
|
|
440
|
+
provider?: "openai";
|
|
441
|
+
apiKey?: string;
|
|
442
|
+
model?: string;
|
|
443
|
+
};
|
|
444
|
+
evalsSystemPrompt?: string;
|
|
445
|
+
scenarios?: {
|
|
446
|
+
description?: string;
|
|
447
|
+
ref?: string;
|
|
448
|
+
telephonyContext?: {
|
|
449
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
450
|
+
ingressNumber?: string;
|
|
451
|
+
callerNumber?: string;
|
|
452
|
+
};
|
|
453
|
+
conversation?: {
|
|
454
|
+
expected?: {
|
|
455
|
+
tools?: {
|
|
456
|
+
parameters?: Record<string, any>;
|
|
457
|
+
tool?: string;
|
|
458
|
+
}[];
|
|
459
|
+
text?: {
|
|
460
|
+
type?: "exact" | "similar";
|
|
461
|
+
response?: string;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
userInput?: string;
|
|
465
|
+
}[];
|
|
466
|
+
}[];
|
|
467
|
+
}, {
|
|
468
|
+
evalsLanguageModel?: {
|
|
469
|
+
provider?: "openai";
|
|
470
|
+
apiKey?: string;
|
|
471
|
+
model?: string;
|
|
472
|
+
};
|
|
473
|
+
evalsSystemPrompt?: string;
|
|
474
|
+
scenarios?: {
|
|
475
|
+
description?: string;
|
|
476
|
+
ref?: string;
|
|
477
|
+
telephonyContext?: {
|
|
478
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
479
|
+
ingressNumber?: string;
|
|
480
|
+
callerNumber?: string;
|
|
481
|
+
};
|
|
482
|
+
conversation?: {
|
|
483
|
+
expected?: {
|
|
484
|
+
tools?: {
|
|
485
|
+
parameters?: Record<string, any>;
|
|
486
|
+
tool?: string;
|
|
487
|
+
}[];
|
|
488
|
+
text?: {
|
|
489
|
+
type?: "exact" | "similar";
|
|
490
|
+
response?: string;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
userInput?: string;
|
|
494
|
+
}[];
|
|
495
|
+
}[];
|
|
496
|
+
}>>;
|
|
297
497
|
}, {
|
|
298
498
|
languageModel: z.ZodEffects<z.ZodObject<{
|
|
299
499
|
provider: z.ZodNativeEnum<typeof import("@fonoster/common").LanguageModelProvider>;
|
|
@@ -613,6 +813,36 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
613
813
|
debounceFrames?: number;
|
|
614
814
|
};
|
|
615
815
|
};
|
|
816
|
+
testCases?: {
|
|
817
|
+
evalsLanguageModel?: {
|
|
818
|
+
provider?: "openai";
|
|
819
|
+
apiKey?: string;
|
|
820
|
+
model?: string;
|
|
821
|
+
};
|
|
822
|
+
evalsSystemPrompt?: string;
|
|
823
|
+
scenarios?: {
|
|
824
|
+
description?: string;
|
|
825
|
+
ref?: string;
|
|
826
|
+
telephonyContext?: {
|
|
827
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
828
|
+
ingressNumber?: string;
|
|
829
|
+
callerNumber?: string;
|
|
830
|
+
};
|
|
831
|
+
conversation?: {
|
|
832
|
+
expected?: {
|
|
833
|
+
tools?: {
|
|
834
|
+
parameters?: Record<string, any>;
|
|
835
|
+
tool?: string;
|
|
836
|
+
}[];
|
|
837
|
+
text?: {
|
|
838
|
+
type?: "exact" | "similar";
|
|
839
|
+
response?: string;
|
|
840
|
+
};
|
|
841
|
+
};
|
|
842
|
+
userInput?: string;
|
|
843
|
+
}[];
|
|
844
|
+
}[];
|
|
845
|
+
};
|
|
616
846
|
}, {
|
|
617
847
|
languageModel?: {
|
|
618
848
|
provider?: import("@fonoster/common").LanguageModelProvider;
|
|
@@ -672,5 +902,35 @@ declare const assistantWithoutApiKeySchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
672
902
|
debounceFrames?: number;
|
|
673
903
|
};
|
|
674
904
|
};
|
|
905
|
+
testCases?: {
|
|
906
|
+
evalsLanguageModel?: {
|
|
907
|
+
provider?: "openai";
|
|
908
|
+
apiKey?: string;
|
|
909
|
+
model?: string;
|
|
910
|
+
};
|
|
911
|
+
evalsSystemPrompt?: string;
|
|
912
|
+
scenarios?: {
|
|
913
|
+
description?: string;
|
|
914
|
+
ref?: string;
|
|
915
|
+
telephonyContext?: {
|
|
916
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
917
|
+
ingressNumber?: string;
|
|
918
|
+
callerNumber?: string;
|
|
919
|
+
};
|
|
920
|
+
conversation?: {
|
|
921
|
+
expected?: {
|
|
922
|
+
tools?: {
|
|
923
|
+
parameters?: Record<string, any>;
|
|
924
|
+
tool?: string;
|
|
925
|
+
}[];
|
|
926
|
+
text?: {
|
|
927
|
+
type?: "exact" | "similar";
|
|
928
|
+
response?: string;
|
|
929
|
+
};
|
|
930
|
+
};
|
|
931
|
+
userInput?: string;
|
|
932
|
+
}[];
|
|
933
|
+
}[];
|
|
934
|
+
};
|
|
675
935
|
}>;
|
|
676
936
|
export { assistantWithoutApiKeySchema };
|
|
@@ -332,6 +332,206 @@ declare function createValidationSchema(request: {
|
|
|
332
332
|
};
|
|
333
333
|
}[];
|
|
334
334
|
}>;
|
|
335
|
+
testCases: z.ZodOptional<z.ZodObject<{
|
|
336
|
+
evalsLanguageModel: z.ZodObject<{
|
|
337
|
+
provider: z.ZodEnum<["openai"]>;
|
|
338
|
+
model: z.ZodString;
|
|
339
|
+
apiKey: z.ZodString;
|
|
340
|
+
}, "strip", z.ZodTypeAny, {
|
|
341
|
+
provider?: "openai";
|
|
342
|
+
apiKey?: string;
|
|
343
|
+
model?: string;
|
|
344
|
+
}, {
|
|
345
|
+
provider?: "openai";
|
|
346
|
+
apiKey?: string;
|
|
347
|
+
model?: string;
|
|
348
|
+
}>;
|
|
349
|
+
evalsSystemPrompt: z.ZodOptional<z.ZodString>;
|
|
350
|
+
scenarios: z.ZodArray<z.ZodObject<{
|
|
351
|
+
ref: z.ZodString;
|
|
352
|
+
description: z.ZodString;
|
|
353
|
+
telephonyContext: z.ZodObject<{
|
|
354
|
+
callDirection: z.ZodNativeEnum<typeof import("@fonoster/types").CallDirection>;
|
|
355
|
+
ingressNumber: z.ZodString;
|
|
356
|
+
callerNumber: z.ZodString;
|
|
357
|
+
}, "strip", z.ZodTypeAny, {
|
|
358
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
359
|
+
ingressNumber?: string;
|
|
360
|
+
callerNumber?: string;
|
|
361
|
+
}, {
|
|
362
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
363
|
+
ingressNumber?: string;
|
|
364
|
+
callerNumber?: string;
|
|
365
|
+
}>;
|
|
366
|
+
conversation: z.ZodArray<z.ZodObject<{
|
|
367
|
+
userInput: z.ZodString;
|
|
368
|
+
expected: z.ZodObject<{
|
|
369
|
+
text: z.ZodObject<{
|
|
370
|
+
type: z.ZodEnum<["exact", "similar"]>;
|
|
371
|
+
response: z.ZodString;
|
|
372
|
+
}, "strip", z.ZodTypeAny, {
|
|
373
|
+
type?: "exact" | "similar";
|
|
374
|
+
response?: string;
|
|
375
|
+
}, {
|
|
376
|
+
type?: "exact" | "similar";
|
|
377
|
+
response?: string;
|
|
378
|
+
}>;
|
|
379
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
380
|
+
tool: z.ZodString;
|
|
381
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
382
|
+
}, "strip", z.ZodTypeAny, {
|
|
383
|
+
parameters?: Record<string, any>;
|
|
384
|
+
tool?: string;
|
|
385
|
+
}, {
|
|
386
|
+
parameters?: Record<string, any>;
|
|
387
|
+
tool?: string;
|
|
388
|
+
}>, "many">>;
|
|
389
|
+
}, "strip", z.ZodTypeAny, {
|
|
390
|
+
tools?: {
|
|
391
|
+
parameters?: Record<string, any>;
|
|
392
|
+
tool?: string;
|
|
393
|
+
}[];
|
|
394
|
+
text?: {
|
|
395
|
+
type?: "exact" | "similar";
|
|
396
|
+
response?: string;
|
|
397
|
+
};
|
|
398
|
+
}, {
|
|
399
|
+
tools?: {
|
|
400
|
+
parameters?: Record<string, any>;
|
|
401
|
+
tool?: string;
|
|
402
|
+
}[];
|
|
403
|
+
text?: {
|
|
404
|
+
type?: "exact" | "similar";
|
|
405
|
+
response?: string;
|
|
406
|
+
};
|
|
407
|
+
}>;
|
|
408
|
+
}, "strip", z.ZodTypeAny, {
|
|
409
|
+
expected?: {
|
|
410
|
+
tools?: {
|
|
411
|
+
parameters?: Record<string, any>;
|
|
412
|
+
tool?: string;
|
|
413
|
+
}[];
|
|
414
|
+
text?: {
|
|
415
|
+
type?: "exact" | "similar";
|
|
416
|
+
response?: string;
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
userInput?: string;
|
|
420
|
+
}, {
|
|
421
|
+
expected?: {
|
|
422
|
+
tools?: {
|
|
423
|
+
parameters?: Record<string, any>;
|
|
424
|
+
tool?: string;
|
|
425
|
+
}[];
|
|
426
|
+
text?: {
|
|
427
|
+
type?: "exact" | "similar";
|
|
428
|
+
response?: string;
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
userInput?: string;
|
|
432
|
+
}>, "many">;
|
|
433
|
+
}, "strip", z.ZodTypeAny, {
|
|
434
|
+
description?: string;
|
|
435
|
+
ref?: string;
|
|
436
|
+
telephonyContext?: {
|
|
437
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
438
|
+
ingressNumber?: string;
|
|
439
|
+
callerNumber?: string;
|
|
440
|
+
};
|
|
441
|
+
conversation?: {
|
|
442
|
+
expected?: {
|
|
443
|
+
tools?: {
|
|
444
|
+
parameters?: Record<string, any>;
|
|
445
|
+
tool?: string;
|
|
446
|
+
}[];
|
|
447
|
+
text?: {
|
|
448
|
+
type?: "exact" | "similar";
|
|
449
|
+
response?: string;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
userInput?: string;
|
|
453
|
+
}[];
|
|
454
|
+
}, {
|
|
455
|
+
description?: string;
|
|
456
|
+
ref?: string;
|
|
457
|
+
telephonyContext?: {
|
|
458
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
459
|
+
ingressNumber?: string;
|
|
460
|
+
callerNumber?: string;
|
|
461
|
+
};
|
|
462
|
+
conversation?: {
|
|
463
|
+
expected?: {
|
|
464
|
+
tools?: {
|
|
465
|
+
parameters?: Record<string, any>;
|
|
466
|
+
tool?: string;
|
|
467
|
+
}[];
|
|
468
|
+
text?: {
|
|
469
|
+
type?: "exact" | "similar";
|
|
470
|
+
response?: string;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
userInput?: string;
|
|
474
|
+
}[];
|
|
475
|
+
}>, "many">;
|
|
476
|
+
}, "strip", z.ZodTypeAny, {
|
|
477
|
+
evalsLanguageModel?: {
|
|
478
|
+
provider?: "openai";
|
|
479
|
+
apiKey?: string;
|
|
480
|
+
model?: string;
|
|
481
|
+
};
|
|
482
|
+
evalsSystemPrompt?: string;
|
|
483
|
+
scenarios?: {
|
|
484
|
+
description?: string;
|
|
485
|
+
ref?: string;
|
|
486
|
+
telephonyContext?: {
|
|
487
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
488
|
+
ingressNumber?: string;
|
|
489
|
+
callerNumber?: string;
|
|
490
|
+
};
|
|
491
|
+
conversation?: {
|
|
492
|
+
expected?: {
|
|
493
|
+
tools?: {
|
|
494
|
+
parameters?: Record<string, any>;
|
|
495
|
+
tool?: string;
|
|
496
|
+
}[];
|
|
497
|
+
text?: {
|
|
498
|
+
type?: "exact" | "similar";
|
|
499
|
+
response?: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
userInput?: string;
|
|
503
|
+
}[];
|
|
504
|
+
}[];
|
|
505
|
+
}, {
|
|
506
|
+
evalsLanguageModel?: {
|
|
507
|
+
provider?: "openai";
|
|
508
|
+
apiKey?: string;
|
|
509
|
+
model?: string;
|
|
510
|
+
};
|
|
511
|
+
evalsSystemPrompt?: string;
|
|
512
|
+
scenarios?: {
|
|
513
|
+
description?: string;
|
|
514
|
+
ref?: string;
|
|
515
|
+
telephonyContext?: {
|
|
516
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
517
|
+
ingressNumber?: string;
|
|
518
|
+
callerNumber?: string;
|
|
519
|
+
};
|
|
520
|
+
conversation?: {
|
|
521
|
+
expected?: {
|
|
522
|
+
tools?: {
|
|
523
|
+
parameters?: Record<string, any>;
|
|
524
|
+
tool?: string;
|
|
525
|
+
}[];
|
|
526
|
+
text?: {
|
|
527
|
+
type?: "exact" | "similar";
|
|
528
|
+
response?: string;
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
userInput?: string;
|
|
532
|
+
}[];
|
|
533
|
+
}[];
|
|
534
|
+
}>>;
|
|
335
535
|
}, {
|
|
336
536
|
languageModel: z.ZodEffects<z.ZodObject<{
|
|
337
537
|
provider: z.ZodNativeEnum<typeof import("@fonoster/common").LanguageModelProvider>;
|
|
@@ -651,6 +851,36 @@ declare function createValidationSchema(request: {
|
|
|
651
851
|
debounceFrames?: number;
|
|
652
852
|
};
|
|
653
853
|
};
|
|
854
|
+
testCases?: {
|
|
855
|
+
evalsLanguageModel?: {
|
|
856
|
+
provider?: "openai";
|
|
857
|
+
apiKey?: string;
|
|
858
|
+
model?: string;
|
|
859
|
+
};
|
|
860
|
+
evalsSystemPrompt?: string;
|
|
861
|
+
scenarios?: {
|
|
862
|
+
description?: string;
|
|
863
|
+
ref?: string;
|
|
864
|
+
telephonyContext?: {
|
|
865
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
866
|
+
ingressNumber?: string;
|
|
867
|
+
callerNumber?: string;
|
|
868
|
+
};
|
|
869
|
+
conversation?: {
|
|
870
|
+
expected?: {
|
|
871
|
+
tools?: {
|
|
872
|
+
parameters?: Record<string, any>;
|
|
873
|
+
tool?: string;
|
|
874
|
+
}[];
|
|
875
|
+
text?: {
|
|
876
|
+
type?: "exact" | "similar";
|
|
877
|
+
response?: string;
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
userInput?: string;
|
|
881
|
+
}[];
|
|
882
|
+
}[];
|
|
883
|
+
};
|
|
654
884
|
}, {
|
|
655
885
|
languageModel?: {
|
|
656
886
|
provider?: import("@fonoster/common").LanguageModelProvider;
|
|
@@ -710,6 +940,36 @@ declare function createValidationSchema(request: {
|
|
|
710
940
|
debounceFrames?: number;
|
|
711
941
|
};
|
|
712
942
|
};
|
|
943
|
+
testCases?: {
|
|
944
|
+
evalsLanguageModel?: {
|
|
945
|
+
provider?: "openai";
|
|
946
|
+
apiKey?: string;
|
|
947
|
+
model?: string;
|
|
948
|
+
};
|
|
949
|
+
evalsSystemPrompt?: string;
|
|
950
|
+
scenarios?: {
|
|
951
|
+
description?: string;
|
|
952
|
+
ref?: string;
|
|
953
|
+
telephonyContext?: {
|
|
954
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
955
|
+
ingressNumber?: string;
|
|
956
|
+
callerNumber?: string;
|
|
957
|
+
};
|
|
958
|
+
conversation?: {
|
|
959
|
+
expected?: {
|
|
960
|
+
tools?: {
|
|
961
|
+
parameters?: Record<string, any>;
|
|
962
|
+
tool?: string;
|
|
963
|
+
}[];
|
|
964
|
+
text?: {
|
|
965
|
+
type?: "exact" | "similar";
|
|
966
|
+
response?: string;
|
|
967
|
+
};
|
|
968
|
+
};
|
|
969
|
+
userInput?: string;
|
|
970
|
+
}[];
|
|
971
|
+
}[];
|
|
972
|
+
};
|
|
713
973
|
}>;
|
|
714
974
|
}, "strip", z.ZodTypeAny, {
|
|
715
975
|
config?: {
|
|
@@ -771,6 +1031,36 @@ declare function createValidationSchema(request: {
|
|
|
771
1031
|
debounceFrames?: number;
|
|
772
1032
|
};
|
|
773
1033
|
};
|
|
1034
|
+
testCases?: {
|
|
1035
|
+
evalsLanguageModel?: {
|
|
1036
|
+
provider?: "openai";
|
|
1037
|
+
apiKey?: string;
|
|
1038
|
+
model?: string;
|
|
1039
|
+
};
|
|
1040
|
+
evalsSystemPrompt?: string;
|
|
1041
|
+
scenarios?: {
|
|
1042
|
+
description?: string;
|
|
1043
|
+
ref?: string;
|
|
1044
|
+
telephonyContext?: {
|
|
1045
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1046
|
+
ingressNumber?: string;
|
|
1047
|
+
callerNumber?: string;
|
|
1048
|
+
};
|
|
1049
|
+
conversation?: {
|
|
1050
|
+
expected?: {
|
|
1051
|
+
tools?: {
|
|
1052
|
+
parameters?: Record<string, any>;
|
|
1053
|
+
tool?: string;
|
|
1054
|
+
}[];
|
|
1055
|
+
text?: {
|
|
1056
|
+
type?: "exact" | "similar";
|
|
1057
|
+
response?: string;
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
userInput?: string;
|
|
1061
|
+
}[];
|
|
1062
|
+
}[];
|
|
1063
|
+
};
|
|
774
1064
|
};
|
|
775
1065
|
productRef?: string;
|
|
776
1066
|
}, {
|
|
@@ -833,6 +1123,36 @@ declare function createValidationSchema(request: {
|
|
|
833
1123
|
debounceFrames?: number;
|
|
834
1124
|
};
|
|
835
1125
|
};
|
|
1126
|
+
testCases?: {
|
|
1127
|
+
evalsLanguageModel?: {
|
|
1128
|
+
provider?: "openai";
|
|
1129
|
+
apiKey?: string;
|
|
1130
|
+
model?: string;
|
|
1131
|
+
};
|
|
1132
|
+
evalsSystemPrompt?: string;
|
|
1133
|
+
scenarios?: {
|
|
1134
|
+
description?: string;
|
|
1135
|
+
ref?: string;
|
|
1136
|
+
telephonyContext?: {
|
|
1137
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1138
|
+
ingressNumber?: string;
|
|
1139
|
+
callerNumber?: string;
|
|
1140
|
+
};
|
|
1141
|
+
conversation?: {
|
|
1142
|
+
expected?: {
|
|
1143
|
+
tools?: {
|
|
1144
|
+
parameters?: Record<string, any>;
|
|
1145
|
+
tool?: string;
|
|
1146
|
+
}[];
|
|
1147
|
+
text?: {
|
|
1148
|
+
type?: "exact" | "similar";
|
|
1149
|
+
response?: string;
|
|
1150
|
+
};
|
|
1151
|
+
};
|
|
1152
|
+
userInput?: string;
|
|
1153
|
+
}[];
|
|
1154
|
+
}[];
|
|
1155
|
+
};
|
|
836
1156
|
};
|
|
837
1157
|
productRef?: string;
|
|
838
1158
|
}>, {
|
|
@@ -895,6 +1215,36 @@ declare function createValidationSchema(request: {
|
|
|
895
1215
|
debounceFrames?: number;
|
|
896
1216
|
};
|
|
897
1217
|
};
|
|
1218
|
+
testCases?: {
|
|
1219
|
+
evalsLanguageModel?: {
|
|
1220
|
+
provider?: "openai";
|
|
1221
|
+
apiKey?: string;
|
|
1222
|
+
model?: string;
|
|
1223
|
+
};
|
|
1224
|
+
evalsSystemPrompt?: string;
|
|
1225
|
+
scenarios?: {
|
|
1226
|
+
description?: string;
|
|
1227
|
+
ref?: string;
|
|
1228
|
+
telephonyContext?: {
|
|
1229
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1230
|
+
ingressNumber?: string;
|
|
1231
|
+
callerNumber?: string;
|
|
1232
|
+
};
|
|
1233
|
+
conversation?: {
|
|
1234
|
+
expected?: {
|
|
1235
|
+
tools?: {
|
|
1236
|
+
parameters?: Record<string, any>;
|
|
1237
|
+
tool?: string;
|
|
1238
|
+
}[];
|
|
1239
|
+
text?: {
|
|
1240
|
+
type?: "exact" | "similar";
|
|
1241
|
+
response?: string;
|
|
1242
|
+
};
|
|
1243
|
+
};
|
|
1244
|
+
userInput?: string;
|
|
1245
|
+
}[];
|
|
1246
|
+
}[];
|
|
1247
|
+
};
|
|
898
1248
|
};
|
|
899
1249
|
productRef?: string;
|
|
900
1250
|
}, {
|
|
@@ -957,6 +1307,36 @@ declare function createValidationSchema(request: {
|
|
|
957
1307
|
debounceFrames?: number;
|
|
958
1308
|
};
|
|
959
1309
|
};
|
|
1310
|
+
testCases?: {
|
|
1311
|
+
evalsLanguageModel?: {
|
|
1312
|
+
provider?: "openai";
|
|
1313
|
+
apiKey?: string;
|
|
1314
|
+
model?: string;
|
|
1315
|
+
};
|
|
1316
|
+
evalsSystemPrompt?: string;
|
|
1317
|
+
scenarios?: {
|
|
1318
|
+
description?: string;
|
|
1319
|
+
ref?: string;
|
|
1320
|
+
telephonyContext?: {
|
|
1321
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1322
|
+
ingressNumber?: string;
|
|
1323
|
+
callerNumber?: string;
|
|
1324
|
+
};
|
|
1325
|
+
conversation?: {
|
|
1326
|
+
expected?: {
|
|
1327
|
+
tools?: {
|
|
1328
|
+
parameters?: Record<string, any>;
|
|
1329
|
+
tool?: string;
|
|
1330
|
+
}[];
|
|
1331
|
+
text?: {
|
|
1332
|
+
type?: "exact" | "similar";
|
|
1333
|
+
response?: string;
|
|
1334
|
+
};
|
|
1335
|
+
};
|
|
1336
|
+
userInput?: string;
|
|
1337
|
+
}[];
|
|
1338
|
+
}[];
|
|
1339
|
+
};
|
|
960
1340
|
};
|
|
961
1341
|
productRef?: string;
|
|
962
1342
|
}>;
|
|
@@ -1031,6 +1411,36 @@ declare function createValidationSchema(request: {
|
|
|
1031
1411
|
debounceFrames?: number;
|
|
1032
1412
|
};
|
|
1033
1413
|
};
|
|
1414
|
+
testCases?: {
|
|
1415
|
+
evalsLanguageModel?: {
|
|
1416
|
+
provider?: "openai";
|
|
1417
|
+
apiKey?: string;
|
|
1418
|
+
model?: string;
|
|
1419
|
+
};
|
|
1420
|
+
evalsSystemPrompt?: string;
|
|
1421
|
+
scenarios?: {
|
|
1422
|
+
description?: string;
|
|
1423
|
+
ref?: string;
|
|
1424
|
+
telephonyContext?: {
|
|
1425
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1426
|
+
ingressNumber?: string;
|
|
1427
|
+
callerNumber?: string;
|
|
1428
|
+
};
|
|
1429
|
+
conversation?: {
|
|
1430
|
+
expected?: {
|
|
1431
|
+
tools?: {
|
|
1432
|
+
parameters?: Record<string, any>;
|
|
1433
|
+
tool?: string;
|
|
1434
|
+
}[];
|
|
1435
|
+
text?: {
|
|
1436
|
+
type?: "exact" | "similar";
|
|
1437
|
+
response?: string;
|
|
1438
|
+
};
|
|
1439
|
+
};
|
|
1440
|
+
userInput?: string;
|
|
1441
|
+
}[];
|
|
1442
|
+
}[];
|
|
1443
|
+
};
|
|
1034
1444
|
};
|
|
1035
1445
|
productRef?: string;
|
|
1036
1446
|
};
|
|
@@ -1108,6 +1518,36 @@ declare function createValidationSchema(request: {
|
|
|
1108
1518
|
debounceFrames?: number;
|
|
1109
1519
|
};
|
|
1110
1520
|
};
|
|
1521
|
+
testCases?: {
|
|
1522
|
+
evalsLanguageModel?: {
|
|
1523
|
+
provider?: "openai";
|
|
1524
|
+
apiKey?: string;
|
|
1525
|
+
model?: string;
|
|
1526
|
+
};
|
|
1527
|
+
evalsSystemPrompt?: string;
|
|
1528
|
+
scenarios?: {
|
|
1529
|
+
description?: string;
|
|
1530
|
+
ref?: string;
|
|
1531
|
+
telephonyContext?: {
|
|
1532
|
+
callDirection?: import("@fonoster/types").CallDirection;
|
|
1533
|
+
ingressNumber?: string;
|
|
1534
|
+
callerNumber?: string;
|
|
1535
|
+
};
|
|
1536
|
+
conversation?: {
|
|
1537
|
+
expected?: {
|
|
1538
|
+
tools?: {
|
|
1539
|
+
parameters?: Record<string, any>;
|
|
1540
|
+
tool?: string;
|
|
1541
|
+
}[];
|
|
1542
|
+
text?: {
|
|
1543
|
+
type?: "exact" | "similar";
|
|
1544
|
+
response?: string;
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
1547
|
+
userInput?: string;
|
|
1548
|
+
}[];
|
|
1549
|
+
}[];
|
|
1550
|
+
};
|
|
1111
1551
|
};
|
|
1112
1552
|
productRef?: string;
|
|
1113
1553
|
};
|
|
@@ -32,8 +32,8 @@ declare class VoiceClientImpl implements VoiceClient {
|
|
|
32
32
|
synthesize(text: string, options: SayOptions): Promise<string>;
|
|
33
33
|
transcribe(): Promise<SpeechResult>;
|
|
34
34
|
startSpeechGather(callback: (stream: {
|
|
35
|
-
speech
|
|
36
|
-
|
|
35
|
+
speech: string;
|
|
36
|
+
responseTime: number;
|
|
37
37
|
}) => void): Promise<void>;
|
|
38
38
|
startDtmfGather(sessionRef: string, callback: (event: {
|
|
39
39
|
digit: string;
|
|
@@ -47,18 +47,20 @@ function createStreamGatherHandler(voiceClient) {
|
|
|
47
47
|
voiceClient.sendResponse({
|
|
48
48
|
streamGatherPayload: {
|
|
49
49
|
sessionRef,
|
|
50
|
-
digit
|
|
50
|
+
digit,
|
|
51
|
+
responseTime: 0
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
if (effectiveSource.includes(common_1.StreamGatherSource.SPEECH)) {
|
|
56
57
|
voiceClient.startSpeechGather((event) => {
|
|
57
|
-
const { speech } = event;
|
|
58
|
+
const { speech, responseTime } = event;
|
|
58
59
|
voiceClient.sendResponse({
|
|
59
60
|
streamGatherPayload: {
|
|
60
61
|
sessionRef,
|
|
61
|
-
speech
|
|
62
|
+
speech,
|
|
63
|
+
responseTime
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
66
|
});
|
|
@@ -60,7 +60,7 @@ function createGatherHandler(voiceClient) {
|
|
|
60
60
|
const effectiveSource = source || common_1.GatherSource.SPEECH_AND_DTMF;
|
|
61
61
|
const promises = [timeoutPromise];
|
|
62
62
|
if (effectiveSource.includes(common_1.GatherSource.SPEECH)) {
|
|
63
|
-
promises.push(voiceClient.transcribe().then((result) => result
|
|
63
|
+
promises.push(voiceClient.transcribe().then((result) => result));
|
|
64
64
|
}
|
|
65
65
|
if (effectiveSource.includes(common_1.GatherSource.DTMF)) {
|
|
66
66
|
promises.push(voiceClient
|
|
@@ -71,14 +71,15 @@ function createGatherHandler(voiceClient) {
|
|
|
71
71
|
timeout: effectiveTimeout,
|
|
72
72
|
onDigitReceived: timeoutPromise.cancelGlobalTimer
|
|
73
73
|
})
|
|
74
|
-
.then((
|
|
74
|
+
.then((result) => result));
|
|
75
75
|
}
|
|
76
|
-
const result = yield Promise.race(promises);
|
|
76
|
+
const result = (yield Promise.race(promises));
|
|
77
77
|
voiceClient.sendResponse({
|
|
78
78
|
gatherResponse: {
|
|
79
79
|
sessionRef,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
responseTime: result.responseTime,
|
|
81
|
+
speech: (0, utils_1.isDtmf)(result.digits) ? undefined : result.speech,
|
|
82
|
+
digits: (0, utils_1.isDtmf)(result.digits) ? result.digits : undefined
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
85
|
}));
|
|
@@ -2,7 +2,7 @@ interface PromiseWithResetTimer<T> extends Promise<T> {
|
|
|
2
2
|
cancelGlobalTimer?: () => void;
|
|
3
3
|
}
|
|
4
4
|
declare function getTimeoutPromise(timeout: number): {
|
|
5
|
-
timeoutPromise: PromiseWithResetTimer<
|
|
5
|
+
timeoutPromise: PromiseWithResetTimer<unknown>;
|
|
6
6
|
effectiveTimeout: number;
|
|
7
7
|
};
|
|
8
8
|
export { getTimeoutPromise };
|
|
@@ -90,8 +90,15 @@ class Deepgram extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
|
90
90
|
if (!data.channel.alternatives[0].transcript || !data.speech_final) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
+
const words = data.channel.alternatives[0].words;
|
|
94
|
+
const responseTime = words.length > 0
|
|
95
|
+
? (words.reduce((acc, word) => acc + (word.end - word.start), 0) *
|
|
96
|
+
1000) /
|
|
97
|
+
words.length
|
|
98
|
+
: 0;
|
|
93
99
|
out.emit("data", {
|
|
94
|
-
speech: data.channel.alternatives[0].transcript
|
|
100
|
+
speech: data.channel.alternatives[0].transcript,
|
|
101
|
+
responseTime
|
|
95
102
|
});
|
|
96
103
|
});
|
|
97
104
|
connection.on(LiveTranscriptionEvents.Error, (err) => {
|
|
@@ -104,6 +111,7 @@ class Deepgram extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
|
104
111
|
transcribe(stream) {
|
|
105
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
113
|
return new Promise((resolve, reject) => {
|
|
114
|
+
const startTime = performance.now();
|
|
107
115
|
const connection = this.client.listen.live(buildTranscribeConfig(this.engineConfig.config));
|
|
108
116
|
stream.on("data", (chunk) => {
|
|
109
117
|
connection.send(chunk);
|
|
@@ -113,7 +121,8 @@ class Deepgram extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
|
113
121
|
if (data.channel.alternatives[0].transcript && data.speech_final) {
|
|
114
122
|
const result = {
|
|
115
123
|
speech: data.channel.alternatives[0].transcript,
|
|
116
|
-
isFinal: true
|
|
124
|
+
isFinal: true,
|
|
125
|
+
responseTime: performance.now() - startTime
|
|
117
126
|
};
|
|
118
127
|
resolve(result);
|
|
119
128
|
connection.destroy();
|
package/dist/voice/stt/Google.js
CHANGED
|
@@ -47,6 +47,7 @@ const common_1 = require("@fonoster/common");
|
|
|
47
47
|
const speech_1 = require("@google-cloud/speech");
|
|
48
48
|
const z = __importStar(require("zod"));
|
|
49
49
|
const AbstractSpeechToText_1 = require("./AbstractSpeechToText");
|
|
50
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
50
51
|
const ENGINE_NAME = "stt.google";
|
|
51
52
|
exports.ENGINE_NAME = ENGINE_NAME;
|
|
52
53
|
class Google extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
@@ -63,6 +64,7 @@ class Google extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
|
63
64
|
}
|
|
64
65
|
transcribe(stream) {
|
|
65
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const startTime = perf_hooks_1.performance.now();
|
|
66
68
|
const languageCode = this.engineConfig.config.languageCode || common_1.VoiceLanguage.EN_US;
|
|
67
69
|
const audioConfig = {
|
|
68
70
|
interimResults: false,
|
|
@@ -78,15 +80,17 @@ class Google extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
|
78
80
|
.on("error", (e) => reject(e))
|
|
79
81
|
.on("data", (data) => {
|
|
80
82
|
var _a;
|
|
83
|
+
const responseTime = perf_hooks_1.performance.now() - startTime;
|
|
81
84
|
if ((_a = data.results[0]) === null || _a === void 0 ? void 0 : _a.alternatives[0]) {
|
|
82
85
|
const result = {
|
|
83
86
|
speech: data.results[0].alternatives[0].transcript,
|
|
84
|
-
isFinal: true
|
|
87
|
+
isFinal: true,
|
|
88
|
+
responseTime
|
|
85
89
|
};
|
|
86
90
|
resolve(result);
|
|
87
91
|
}
|
|
88
92
|
else {
|
|
89
|
-
resolve({ speech: "", isFinal: true });
|
|
93
|
+
resolve({ speech: "", isFinal: true, responseTime });
|
|
90
94
|
}
|
|
91
95
|
recognizeStream.destroy();
|
|
92
96
|
});
|
|
@@ -125,7 +125,9 @@ class ElevenLabs extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
|
125
125
|
voice,
|
|
126
126
|
text,
|
|
127
127
|
model_id: model !== null && model !== void 0 ? model : "eleven_flash_v2_5",
|
|
128
|
-
output_format: "pcm_16000"
|
|
128
|
+
output_format: "pcm_16000",
|
|
129
|
+
// TODO: Make this configurable
|
|
130
|
+
optimize_streaming_latency: 2
|
|
129
131
|
});
|
|
130
132
|
return (yield (0, streamToBuffer_1.streamToBuffer)(response));
|
|
131
133
|
});
|
|
@@ -11,7 +11,8 @@ type VoiceClient = {
|
|
|
11
11
|
synthesize: (text: string, options: SayOptions) => Promise<string>;
|
|
12
12
|
transcribe: () => Promise<SpeechResult>;
|
|
13
13
|
startSpeechGather: (callback: (stream: {
|
|
14
|
-
speech
|
|
14
|
+
speech: string;
|
|
15
|
+
responseTime: number;
|
|
15
16
|
}) => void) => void;
|
|
16
17
|
startDtmfGather: (sessionRef: string, callback: (event: {
|
|
17
18
|
digit: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.56",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@deepgram/sdk": "^3.5.1",
|
|
24
|
-
"@fonoster/authz": "^0.8.
|
|
25
|
-
"@fonoster/common": "^0.8.
|
|
26
|
-
"@fonoster/identity": "^0.8.
|
|
27
|
-
"@fonoster/logger": "^0.8.
|
|
28
|
-
"@fonoster/sipnet": "^0.8.
|
|
29
|
-
"@fonoster/streams": "^0.8.
|
|
30
|
-
"@fonoster/types": "^0.8.
|
|
24
|
+
"@fonoster/authz": "^0.8.56",
|
|
25
|
+
"@fonoster/common": "^0.8.56",
|
|
26
|
+
"@fonoster/identity": "^0.8.56",
|
|
27
|
+
"@fonoster/logger": "^0.8.56",
|
|
28
|
+
"@fonoster/sipnet": "^0.8.56",
|
|
29
|
+
"@fonoster/streams": "^0.8.56",
|
|
30
|
+
"@fonoster/types": "^0.8.56",
|
|
31
31
|
"@google-cloud/speech": "^6.6.0",
|
|
32
32
|
"@google-cloud/text-to-speech": "^5.3.0",
|
|
33
33
|
"@grpc/grpc-js": "~1.10.6",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"@types/uuid": "^10.0.0",
|
|
74
74
|
"@types/validator": "^13.12.0"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "eb95cb72d964068fe3d525b696f17c4d4b0522a2"
|
|
77
77
|
}
|