@fonoster/autopilot 0.7.14 → 0.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -137,6 +137,8 @@ You can configure a new tool by adding a new entry in the `tools` array in the c
137
137
 
138
138
  In addition to the `get` operation type, you can use the `post` operation type. The `post` operation type is used when sending data to the tool. When sending a post, you can optionally set `waitForResponse` to false, which will "fire and forget" the request. The default behavior is to wait for the response.
139
139
 
140
+ If your tool needs the number of the caller or the number that received the call, you can use the reserved variables `ingressNumber` and `callerNumber`. Similarly, you can use the reserved variable `callReceivedAt` to get the date and time when the call was received in `ISO 8601` format.
141
+
140
142
  The expected format for the response is a JSON object with the following structure:
141
143
 
142
144
  ```json
@@ -131,22 +131,27 @@ declare const languageModelConfigSchema: z.ZodObject<{
131
131
  type: z.ZodNativeEnum<typeof import("../tools/ToolSchema").AllowedOperations>;
132
132
  url: z.ZodOptional<z.ZodString>;
133
133
  waitForResponse: z.ZodOptional<z.ZodBoolean>;
134
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
134
135
  }, "strip", z.ZodTypeAny, {
135
136
  type: import("../tools/ToolSchema").AllowedOperations;
136
137
  url?: string | undefined;
137
138
  waitForResponse?: boolean | undefined;
139
+ headers?: Record<string, string> | undefined;
138
140
  }, {
139
141
  type: import("../tools/ToolSchema").AllowedOperations;
140
142
  url?: string | undefined;
141
143
  waitForResponse?: boolean | undefined;
144
+ headers?: Record<string, string> | undefined;
142
145
  }>, {
143
146
  type: import("../tools/ToolSchema").AllowedOperations;
144
147
  url?: string | undefined;
145
148
  waitForResponse?: boolean | undefined;
149
+ headers?: Record<string, string> | undefined;
146
150
  }, {
147
151
  type: import("../tools/ToolSchema").AllowedOperations;
148
152
  url?: string | undefined;
149
153
  waitForResponse?: boolean | undefined;
154
+ headers?: Record<string, string> | undefined;
150
155
  }>;
151
156
  }, "strip", z.ZodTypeAny, {
152
157
  name: string;
@@ -164,6 +169,7 @@ declare const languageModelConfigSchema: z.ZodObject<{
164
169
  type: import("../tools/ToolSchema").AllowedOperations;
165
170
  url?: string | undefined;
166
171
  waitForResponse?: boolean | undefined;
172
+ headers?: Record<string, string> | undefined;
167
173
  };
168
174
  }, {
169
175
  name: string;
@@ -181,6 +187,7 @@ declare const languageModelConfigSchema: z.ZodObject<{
181
187
  type: import("../tools/ToolSchema").AllowedOperations;
182
188
  url?: string | undefined;
183
189
  waitForResponse?: boolean | undefined;
190
+ headers?: Record<string, string> | undefined;
184
191
  };
185
192
  }>, "many">;
186
193
  }, "strip", z.ZodTypeAny, {
@@ -206,6 +213,7 @@ declare const languageModelConfigSchema: z.ZodObject<{
206
213
  type: import("../tools/ToolSchema").AllowedOperations;
207
214
  url?: string | undefined;
208
215
  waitForResponse?: boolean | undefined;
216
+ headers?: Record<string, string> | undefined;
209
217
  };
210
218
  }[];
211
219
  temperature: number;
@@ -234,6 +242,7 @@ declare const languageModelConfigSchema: z.ZodObject<{
234
242
  type: import("../tools/ToolSchema").AllowedOperations;
235
243
  url?: string | undefined;
236
244
  waitForResponse?: boolean | undefined;
245
+ headers?: Record<string, string> | undefined;
237
246
  };
238
247
  }[];
239
248
  temperature: number;
@@ -372,22 +381,27 @@ declare const assistantSchema: z.ZodObject<{
372
381
  type: z.ZodNativeEnum<typeof import("../tools/ToolSchema").AllowedOperations>;
373
382
  url: z.ZodOptional<z.ZodString>;
374
383
  waitForResponse: z.ZodOptional<z.ZodBoolean>;
384
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
375
385
  }, "strip", z.ZodTypeAny, {
376
386
  type: import("../tools/ToolSchema").AllowedOperations;
377
387
  url?: string | undefined;
378
388
  waitForResponse?: boolean | undefined;
389
+ headers?: Record<string, string> | undefined;
379
390
  }, {
380
391
  type: import("../tools/ToolSchema").AllowedOperations;
381
392
  url?: string | undefined;
382
393
  waitForResponse?: boolean | undefined;
394
+ headers?: Record<string, string> | undefined;
383
395
  }>, {
384
396
  type: import("../tools/ToolSchema").AllowedOperations;
385
397
  url?: string | undefined;
386
398
  waitForResponse?: boolean | undefined;
399
+ headers?: Record<string, string> | undefined;
387
400
  }, {
388
401
  type: import("../tools/ToolSchema").AllowedOperations;
389
402
  url?: string | undefined;
390
403
  waitForResponse?: boolean | undefined;
404
+ headers?: Record<string, string> | undefined;
391
405
  }>;
392
406
  }, "strip", z.ZodTypeAny, {
393
407
  name: string;
@@ -405,6 +419,7 @@ declare const assistantSchema: z.ZodObject<{
405
419
  type: import("../tools/ToolSchema").AllowedOperations;
406
420
  url?: string | undefined;
407
421
  waitForResponse?: boolean | undefined;
422
+ headers?: Record<string, string> | undefined;
408
423
  };
409
424
  }, {
410
425
  name: string;
@@ -422,6 +437,7 @@ declare const assistantSchema: z.ZodObject<{
422
437
  type: import("../tools/ToolSchema").AllowedOperations;
423
438
  url?: string | undefined;
424
439
  waitForResponse?: boolean | undefined;
440
+ headers?: Record<string, string> | undefined;
425
441
  };
426
442
  }>, "many">;
427
443
  }, "strip", z.ZodTypeAny, {
@@ -447,6 +463,7 @@ declare const assistantSchema: z.ZodObject<{
447
463
  type: import("../tools/ToolSchema").AllowedOperations;
448
464
  url?: string | undefined;
449
465
  waitForResponse?: boolean | undefined;
466
+ headers?: Record<string, string> | undefined;
450
467
  };
451
468
  }[];
452
469
  temperature: number;
@@ -475,6 +492,7 @@ declare const assistantSchema: z.ZodObject<{
475
492
  type: import("../tools/ToolSchema").AllowedOperations;
476
493
  url?: string | undefined;
477
494
  waitForResponse?: boolean | undefined;
495
+ headers?: Record<string, string> | undefined;
478
496
  };
479
497
  }[];
480
498
  temperature: number;
@@ -522,6 +540,7 @@ declare const assistantSchema: z.ZodObject<{
522
540
  type: import("../tools/ToolSchema").AllowedOperations;
523
541
  url?: string | undefined;
524
542
  waitForResponse?: boolean | undefined;
543
+ headers?: Record<string, string> | undefined;
525
544
  };
526
545
  }[];
527
546
  temperature: number;
@@ -569,6 +588,7 @@ declare const assistantSchema: z.ZodObject<{
569
588
  type: import("../tools/ToolSchema").AllowedOperations;
570
589
  url?: string | undefined;
571
590
  waitForResponse?: boolean | undefined;
591
+ headers?: Record<string, string> | undefined;
572
592
  };
573
593
  }[];
574
594
  temperature: number;
@@ -1,3 +1,3 @@
1
- import { AssistantConfig, FilesKnowledgeBase } from ".";
2
- declare function createLanguageModel(assistantConfig: AssistantConfig, knowledgeBase: FilesKnowledgeBase): import("./models/AbstractLanguageModel").AbstractLanguageModel;
1
+ import { AssistantConfig, FilesKnowledgeBase, TelephonyContext } from ".";
2
+ declare function createLanguageModel(assistantConfig: AssistantConfig, knowledgeBase: FilesKnowledgeBase, telephonyContext: TelephonyContext): import("./models/AbstractLanguageModel").AbstractLanguageModel;
3
3
  export { createLanguageModel };
@@ -21,7 +21,7 @@ exports.createLanguageModel = createLanguageModel;
21
21
  */
22
22
  const envs_1 = require("./envs");
23
23
  const _1 = require(".");
24
- function createLanguageModel(assistantConfig, knowledgeBase) {
24
+ function createLanguageModel(assistantConfig, knowledgeBase, telephonyContext) {
25
25
  const { languageModel: languageModelSettings, conversationSettings } = assistantConfig;
26
26
  return _1.LanguageModelFactory.getLanguageModel(languageModelSettings.provider, {
27
27
  apiKey: envs_1.OPENAI_API_KEY,
@@ -36,5 +36,5 @@ function createLanguageModel(assistantConfig, knowledgeBase) {
36
36
  _1.hangupToolDefinition,
37
37
  _1.transferToolDefinition
38
38
  ]
39
- });
39
+ }, telephonyContext);
40
40
  }
@@ -56,7 +56,10 @@ async function handleVoiceRequest(req, res) {
56
56
  const knowledgeBase = await (0, loadKnowledgeBase_1.loadKnowledgeBase)();
57
57
  const voice = new _1.VoiceImpl(sessionRef, res);
58
58
  const vad = new _1.SileroVad();
59
- const languageModel = (0, createLanguageModel_1.createLanguageModel)(assistantConfig, knowledgeBase);
59
+ const languageModel = (0, createLanguageModel_1.createLanguageModel)(assistantConfig, knowledgeBase, {
60
+ ingressNumber: req.ingressNumber,
61
+ callerNumber: req.callerNumber
62
+ });
60
63
  const autopilot = new _1.default({
61
64
  conversationSettings: assistantConfig.conversationSettings,
62
65
  voice,
@@ -84,6 +84,9 @@ const machine = (0, xstate_1.setup)({
84
84
  return;
85
85
  }
86
86
  else if (response.type === "transfer") {
87
+ logger.verbose("transferring call to a number in the pstn", {
88
+ phoneNumber: context.transferPhoneNumber
89
+ });
87
90
  const message = context.transferMessage;
88
91
  await context.voice.say(message);
89
92
  await context.voice.transfer(context.transferPhoneNumber, {
@@ -1,11 +1,9 @@
1
- import { InvocationResult, LanguageModel, LanguageModelParams } from "./types";
2
- import { ToolsCatalog } from "../tools";
1
+ import { InvocationResult, LanguageModel, LanguageModelParams, TelephonyContext } from "./types";
3
2
  declare abstract class AbstractLanguageModel implements LanguageModel {
4
- private params;
5
3
  private chain;
6
4
  private chatHistory;
7
- toolsCatalog: ToolsCatalog;
8
- constructor(params: LanguageModelParams);
5
+ private toolsCatalog;
6
+ constructor(params: LanguageModelParams, telephonyContext: TelephonyContext);
9
7
  invoke(text: string): Promise<InvocationResult>;
10
8
  }
11
9
  export { AbstractLanguageModel };
@@ -26,10 +26,9 @@ const createPromptTemplate_1 = require("./createPromptTemplate");
26
26
  const tools_1 = require("../tools");
27
27
  const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
28
28
  class AbstractLanguageModel {
29
- constructor(params) {
30
- this.params = params;
31
- const { model, systemTemplate, knowledgeBase, tools } = this.params;
32
- const promptTemplate = (0, createPromptTemplate_1.createPromptTemplate)(systemTemplate);
29
+ constructor(params, telephonyContext) {
30
+ const { model, systemTemplate, knowledgeBase, tools } = params;
31
+ const promptTemplate = (0, createPromptTemplate_1.createPromptTemplate)(systemTemplate, telephonyContext);
33
32
  this.chatHistory = (0, chatHistory_1.createChatHistory)();
34
33
  this.toolsCatalog = new tools_1.ToolsCatalog(tools);
35
34
  this.chain = (0, createChain_1.createChain)(model, knowledgeBase, promptTemplate, this.chatHistory);
@@ -1,9 +1,9 @@
1
1
  import { AbstractLanguageModel } from "./AbstractLanguageModel";
2
2
  import { GroqParams } from "./groq";
3
3
  import { OpenAIParams } from "./openai";
4
- import { BaseModelParams } from "./types";
4
+ import { BaseModelParams, TelephonyContext } from "./types";
5
5
  import { LANGUAGE_MODEL_PROVIDER } from "../types";
6
- type LanguageModelConstructor<T extends BaseModelParams = BaseModelParams> = new (options: T) => AbstractLanguageModel;
6
+ type LanguageModelConstructor<T extends BaseModelParams = BaseModelParams> = new (options: T, telephonyContext: TelephonyContext) => AbstractLanguageModel;
7
7
  type LanguageModelConfigMap = {
8
8
  [LANGUAGE_MODEL_PROVIDER.OPENAI]: OpenAIParams;
9
9
  [LANGUAGE_MODEL_PROVIDER.GROQ]: GroqParams;
@@ -11,6 +11,6 @@ type LanguageModelConfigMap = {
11
11
  declare class LanguageModelFactory {
12
12
  private static languageModels;
13
13
  static registerLanguageModel<T extends BaseModelParams>(name: string, ctor: LanguageModelConstructor<T>): void;
14
- static getLanguageModel<T extends keyof LanguageModelConfigMap>(languageModel: T, config: LanguageModelConfigMap[T]): AbstractLanguageModel;
14
+ static getLanguageModel<T extends keyof LanguageModelConfigMap>(languageModel: T, config: LanguageModelConfigMap[T], telephonyContext: TelephonyContext): AbstractLanguageModel;
15
15
  }
16
16
  export { LanguageModelFactory };
@@ -29,12 +29,12 @@ class LanguageModelFactory {
29
29
  logger.verbose("registering llm provider", { name });
30
30
  this.languageModels.set(name, ctor);
31
31
  }
32
- static getLanguageModel(languageModel, config) {
32
+ static getLanguageModel(languageModel, config, telephonyContext) {
33
33
  const LanguageModelConstructor = this.languageModels.get(`llm.${languageModel}`);
34
34
  if (!LanguageModelConstructor) {
35
35
  throw new Error(`Language model ${languageModel} not found`);
36
36
  }
37
- return new LanguageModelConstructor(config);
37
+ return new LanguageModelConstructor(config, telephonyContext);
38
38
  }
39
39
  }
40
40
  exports.LanguageModelFactory = LanguageModelFactory;
@@ -1,2 +1,3 @@
1
1
  import { ChatPromptTemplate } from "@langchain/core/prompts";
2
- export declare function createPromptTemplate(systemTemplate: string): ChatPromptTemplate<any, any>;
2
+ import { TelephonyContext } from "./types";
3
+ export declare function createPromptTemplate(systemTemplate: string, telephonyContext: TelephonyContext): ChatPromptTemplate<any, any>;
@@ -20,13 +20,14 @@ exports.createPromptTemplate = createPromptTemplate;
20
20
  * limitations under the License.
21
21
  */
22
22
  const prompts_1 = require("@langchain/core/prompts");
23
- function createPromptTemplate(systemTemplate) {
23
+ function createPromptTemplate(systemTemplate, telephonyContext) {
24
24
  return prompts_1.ChatPromptTemplate.fromMessages([
25
25
  new prompts_1.MessagesPlaceholder("history"),
26
26
  prompts_1.SystemMessagePromptTemplate.fromTemplate(systemTemplate),
27
27
  prompts_1.SystemMessagePromptTemplate.fromTemplate("{context}"),
28
- // This is how the model will know the current date
29
- prompts_1.SystemMessagePromptTemplate.fromTemplate(`current date:${new Date().toISOString()}`),
28
+ prompts_1.SystemMessagePromptTemplate.fromTemplate(`callReceivedAt:${new Date().toISOString()}
29
+ ingressNumber:${telephonyContext.ingressNumber}
30
+ callerNumber:${telephonyContext.callerNumber}`),
30
31
  prompts_1.HumanMessagePromptTemplate.fromTemplate("{input}")
31
32
  ]);
32
33
  }
@@ -1,7 +1,8 @@
1
1
  import { GroqParams } from "./types";
2
2
  import { AbstractLanguageModel } from "../AbstractLanguageModel";
3
+ import { TelephonyContext } from "../types";
3
4
  declare const LANGUAGE_MODEL_NAME = "llm.groq";
4
5
  declare class Groq extends AbstractLanguageModel {
5
- constructor(params: GroqParams);
6
+ constructor(params: GroqParams, telephonyContext: TelephonyContext);
6
7
  }
7
8
  export { Groq, LANGUAGE_MODEL_NAME };
@@ -7,7 +7,7 @@ const AbstractLanguageModel_1 = require("../AbstractLanguageModel");
7
7
  const LANGUAGE_MODEL_NAME = "llm.groq";
8
8
  exports.LANGUAGE_MODEL_NAME = LANGUAGE_MODEL_NAME;
9
9
  class Groq extends AbstractLanguageModel_1.AbstractLanguageModel {
10
- constructor(params) {
10
+ constructor(params, telephonyContext) {
11
11
  const model = new groq_1.ChatGroq({
12
12
  ...params
13
13
  }).bind({
@@ -16,7 +16,7 @@ class Groq extends AbstractLanguageModel_1.AbstractLanguageModel {
16
16
  super({
17
17
  ...params,
18
18
  model
19
- });
19
+ }, telephonyContext);
20
20
  }
21
21
  }
22
22
  exports.Groq = Groq;
@@ -1,7 +1,8 @@
1
1
  import { OpenAIParams } from "./types";
2
2
  import { AbstractLanguageModel } from "../AbstractLanguageModel";
3
+ import { TelephonyContext } from "../types";
3
4
  declare const LANGUAGE_MODEL_NAME = "llm.openai";
4
5
  declare class OpenAI extends AbstractLanguageModel {
5
- constructor(params: OpenAIParams);
6
+ constructor(params: OpenAIParams, telephonyContext: TelephonyContext);
6
7
  }
7
8
  export { LANGUAGE_MODEL_NAME, OpenAI };
@@ -7,7 +7,7 @@ const AbstractLanguageModel_1 = require("../AbstractLanguageModel");
7
7
  const LANGUAGE_MODEL_NAME = "llm.openai";
8
8
  exports.LANGUAGE_MODEL_NAME = LANGUAGE_MODEL_NAME;
9
9
  class OpenAI extends AbstractLanguageModel_1.AbstractLanguageModel {
10
- constructor(params) {
10
+ constructor(params, telephonyContext) {
11
11
  const model = new openai_1.ChatOpenAI({
12
12
  ...params
13
13
  }).bind({
@@ -16,7 +16,7 @@ class OpenAI extends AbstractLanguageModel_1.AbstractLanguageModel {
16
16
  super({
17
17
  ...params,
18
18
  model
19
- });
19
+ }, telephonyContext);
20
20
  }
21
21
  }
22
22
  exports.OpenAI = OpenAI;
@@ -8,6 +8,7 @@ type BaseModelParams = {
8
8
  systemTemplate: string;
9
9
  knowledgeBase: KnowledgeBase;
10
10
  tools: Tool[];
11
+ telephonyContext: TelephonyContext;
11
12
  };
12
13
  type LanguageModelParams = BaseModelParams & {
13
14
  model: BaseChatModel;
@@ -16,4 +17,8 @@ type InvocationResult = {
16
17
  type: "say" | "hangup" | "transfer";
17
18
  content?: string;
18
19
  };
19
- export { BaseModelParams, InvocationResult, LanguageModel, LanguageModelParams };
20
+ type TelephonyContext = {
21
+ ingressNumber: string;
22
+ callerNumber: string;
23
+ };
24
+ export { BaseModelParams, InvocationResult, LanguageModel, LanguageModelParams, TelephonyContext };
@@ -52,22 +52,27 @@ declare const toolSchema: z.ZodObject<{
52
52
  type: z.ZodNativeEnum<typeof AllowedOperations>;
53
53
  url: z.ZodOptional<z.ZodString>;
54
54
  waitForResponse: z.ZodOptional<z.ZodBoolean>;
55
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
55
56
  }, "strip", z.ZodTypeAny, {
56
57
  type: AllowedOperations;
57
58
  url?: string | undefined;
58
59
  waitForResponse?: boolean | undefined;
60
+ headers?: Record<string, string> | undefined;
59
61
  }, {
60
62
  type: AllowedOperations;
61
63
  url?: string | undefined;
62
64
  waitForResponse?: boolean | undefined;
65
+ headers?: Record<string, string> | undefined;
63
66
  }>, {
64
67
  type: AllowedOperations;
65
68
  url?: string | undefined;
66
69
  waitForResponse?: boolean | undefined;
70
+ headers?: Record<string, string> | undefined;
67
71
  }, {
68
72
  type: AllowedOperations;
69
73
  url?: string | undefined;
70
74
  waitForResponse?: boolean | undefined;
75
+ headers?: Record<string, string> | undefined;
71
76
  }>;
72
77
  }, "strip", z.ZodTypeAny, {
73
78
  name: string;
@@ -85,6 +90,7 @@ declare const toolSchema: z.ZodObject<{
85
90
  type: AllowedOperations;
86
91
  url?: string | undefined;
87
92
  waitForResponse?: boolean | undefined;
93
+ headers?: Record<string, string> | undefined;
88
94
  };
89
95
  }, {
90
96
  name: string;
@@ -102,6 +108,7 @@ declare const toolSchema: z.ZodObject<{
102
108
  type: AllowedOperations;
103
109
  url?: string | undefined;
104
110
  waitForResponse?: boolean | undefined;
111
+ headers?: Record<string, string> | undefined;
105
112
  };
106
113
  }>;
107
114
  export { AllowedOperations, toolSchema };
@@ -50,7 +50,8 @@ const toolSchema = zod_1.z.object({
50
50
  type: zod_1.z.nativeEnum(AllowedOperations),
51
51
  // Make url required if operation type is not built-in
52
52
  url: zod_1.z.string().optional(),
53
- waitForResponse: zod_1.z.boolean().optional()
53
+ waitForResponse: zod_1.z.boolean().optional(),
54
+ headers: zod_1.z.record(zod_1.z.string()).optional()
54
55
  })
55
56
  .superRefine(({ url, type }, ctx) => {
56
57
  if (type !== AllowedOperations.BUILT_IN && !url) {
@@ -39,6 +39,7 @@ class ToolsCatalog {
39
39
  method: tool.operation.type,
40
40
  url: tool.operation.url,
41
41
  waitForResponse: tool.operation.waitForResponse,
42
+ headers: tool.operation.headers,
42
43
  body: args
43
44
  });
44
45
  }
@@ -38,6 +38,11 @@ async function sendRequest(input) {
38
38
  else {
39
39
  const response = await fetch(url, options);
40
40
  const data = await response.json();
41
- return responseSchema.parse(data);
41
+ try {
42
+ return responseSchema.parse(data);
43
+ }
44
+ catch (error) {
45
+ throw new Error(`Invalid response: expected ${JSON.stringify(responseSchema, null, 2)}, got ${JSON.stringify(data, null, 2)}`);
46
+ }
42
47
  }
43
48
  }
@@ -26,7 +26,7 @@ class SileroVad {
26
26
  this.init();
27
27
  }
28
28
  async init() {
29
- // FIXME: It feels not to do this in the constructor
29
+ // FIXME: It feels strange to do this in the constructor
30
30
  this.vad = await (0, makeVad_1.makeVad)();
31
31
  }
32
32
  processChunk(data, callback) {
@@ -44,9 +44,11 @@ exports.makeVad = makeVad;
44
44
  * limitations under the License.
45
45
  */
46
46
  const path_1 = require("path");
47
+ const logger_1 = require("@fonoster/logger");
47
48
  const ort = __importStar(require("onnxruntime-node"));
48
49
  const chunkToFloat32Array_1 = require("./chunkToFloat32Array");
49
50
  const SileroVadModel_1 = require("./SileroVadModel");
51
+ const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
50
52
  const BUFFER_SIZE = 16000;
51
53
  async function makeVad(pathToModel) {
52
54
  const effectivePath = pathToModel || (0, path_1.join)(__dirname, "..", "..", "silero_vad.onnx");
@@ -62,6 +64,7 @@ async function makeVad(pathToModel) {
62
64
  const audioFrame = buffer.slice(0, BUFFER_SIZE);
63
65
  const remainingBuffer = buffer.slice(BUFFER_SIZE);
64
66
  const result = await silero.process(new Float32Array(audioFrame));
67
+ logger.silly("last vad result", { ...result });
65
68
  if (result.isSpeech > 0.5) {
66
69
  if (!isSpeechActive) {
67
70
  isSpeechActive = true;
@@ -72,6 +75,9 @@ async function makeVad(pathToModel) {
72
75
  else if (isSpeechActive) {
73
76
  isSpeechActive = false;
74
77
  callback("SPEECH_END");
78
+ // WARNING: I'm unsure if this has any effect on the model
79
+ // but it seems to work fine to ensure the model works optimally
80
+ silero.resetState();
75
81
  return processBuffer(remainingBuffer);
76
82
  }
77
83
  return processBuffer(remainingBuffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/autopilot",
3
- "version": "0.7.14",
3
+ "version": "0.7.15",
4
4
  "description": "Voice AI for the Fonoster platform",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -35,10 +35,10 @@
35
35
  "url": "https://github.com/fonoster/fonoster/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@fonoster/common": "^0.7.13",
39
- "@fonoster/logger": "^0.7.13",
40
- "@fonoster/types": "^0.7.13",
41
- "@fonoster/voice": "^0.7.13",
38
+ "@fonoster/common": "^0.7.15",
39
+ "@fonoster/logger": "^0.7.15",
40
+ "@fonoster/types": "^0.7.15",
41
+ "@fonoster/voice": "^0.7.15",
42
42
  "@langchain/community": "^0.2.31",
43
43
  "@langchain/core": "^0.2.32",
44
44
  "@langchain/groq": "^0.0.17",
@@ -55,5 +55,5 @@
55
55
  "devDependencies": {
56
56
  "typescript": "^5.5.4"
57
57
  },
58
- "gitHead": "e53cc1ba6d17ce64a9541bd51364ace3dcd43aaa"
58
+ "gitHead": "13997c49e69d79aa1a58cd0de1120984e3b8b6f1"
59
59
  }