@fonoster/autopilot 0.8.25 → 0.8.26

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.
@@ -23,6 +23,8 @@ const common_1 = require("@fonoster/common");
23
23
  const zod_1 = require("zod");
24
24
  const ToolSchema_1 = require("../tools/ToolSchema");
25
25
  const types_1 = require("../types");
26
+ const NUMBER_BETWEEN_0_AND_1 = "must be a number between 0 and 1";
27
+ const NUMBER_BETWEEN_0_AND_2 = "must be a number between 0 and 2";
26
28
  const conversationSettingsSchema = zod_1.z.object({
27
29
  firstMessage: zod_1.z.string().optional(),
28
30
  systemTemplate: zod_1.z.string(),
@@ -62,8 +64,11 @@ const conversationSettingsSchema = zod_1.z.object({
62
64
  .optional(),
63
65
  vad: zod_1.z.object({
64
66
  pathToModel: zod_1.z.string().optional(),
65
- activationThreshold: zod_1.z.number(),
66
- deactivationThreshold: zod_1.z.number(),
67
+ activationThreshold: zod_1.z.number()
68
+ .max(1)
69
+ .min(0)
70
+ .positive({ message: NUMBER_BETWEEN_0_AND_1 }),
71
+ deactivationThreshold: zod_1.z.number().max(1).min(0).positive({ message: NUMBER_BETWEEN_0_AND_1 }),
67
72
  debounceFrames: zod_1.z
68
73
  .number()
69
74
  .int({ message: common_1.Messages.POSITIVE_INTEGER_MESSAGE })
@@ -77,7 +82,9 @@ const languageModelConfigSchema = zod_1.z.object({
77
82
  }),
78
83
  apiKey: zod_1.z.string().optional(),
79
84
  model: zod_1.z.string(),
80
- temperature: zod_1.z.number(),
85
+ temperature: zod_1.z.number()
86
+ .max(2, { message: NUMBER_BETWEEN_0_AND_2 })
87
+ .min(0, { message: NUMBER_BETWEEN_0_AND_2 }),
81
88
  maxTokens: zod_1.z
82
89
  .number()
83
90
  .int({ message: common_1.Messages.POSITIVE_INTEGER_MESSAGE })
@@ -23,6 +23,10 @@ const _1 = require(".");
23
23
  function createLanguageModel(params) {
24
24
  const { voice, assistantConfig, knowledgeBase, telephonyContext } = params;
25
25
  const { languageModel: languageModelSettings, conversationSettings } = assistantConfig;
26
+ // Ensure that the transfer tool is only added if the transfer options exist
27
+ const tools = languageModelSettings.tools.concat(assistantConfig.conversationSettings.transferOptions
28
+ ? [_1.hangupToolDefinition, _1.transferToolDefinition]
29
+ : [_1.hangupToolDefinition]);
26
30
  return _1.LanguageModelFactory.getLanguageModel(languageModelSettings.provider, {
27
31
  // @ts-expect-error don't know the model type here
28
32
  model: languageModelSettings.model,
@@ -33,10 +37,6 @@ function createLanguageModel(params) {
33
37
  systemTemplate: conversationSettings.systemTemplate,
34
38
  baseUrl: languageModelSettings.baseUrl,
35
39
  knowledgeBase,
36
- tools: [
37
- ...languageModelSettings.tools,
38
- _1.hangupToolDefinition,
39
- _1.transferToolDefinition
40
- ]
40
+ tools
41
41
  }, voice, telephonyContext);
42
42
  }
@@ -112,12 +112,12 @@ declare const machine: import("xstate").StateMachine<AutopilotContext, {
112
112
  }, import("xstate").EventObject>;
113
113
  id: string | undefined;
114
114
  }, "src", TSrc>["logic"]>;
115
- <TLogic extends import("xstate").AnyActorLogic>(src: TLogic, options?: {
115
+ <TLogic extends import("xstate").AnyActorLogic>(src: TLogic, ...[options]: import("xstate").ConditionalRequired<[options?: ({
116
116
  id?: never;
117
117
  systemId?: string;
118
118
  input?: import("xstate").InputFrom<TLogic> | undefined;
119
119
  syncSnapshot?: boolean;
120
- } | undefined): import("xstate").ActorRefFromLogic<TLogic>;
120
+ } & { [K in import("xstate").RequiredLogicInput<TLogic>]: unknown; }) | undefined], import("xstate").IsNotNever<import("xstate").RequiredLogicInput<TLogic>>>): import("xstate").ActorRefFromLogic<TLogic>;
121
121
  };
122
122
  input: {
123
123
  conversationSettings: ConversationSettings;
@@ -21,7 +21,7 @@ exports.SileroVad = void 0;
21
21
  * limitations under the License.
22
22
  */
23
23
  const logger_1 = require("@fonoster/logger");
24
- const makeVad_1 = require("./makeVad");
24
+ const createVad_1 = require("./createVad");
25
25
  const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
26
26
  class SileroVad {
27
27
  constructor(params) {
@@ -29,7 +29,7 @@ class SileroVad {
29
29
  this.params = params;
30
30
  }
31
31
  async init() {
32
- this.vad = await (0, makeVad_1.makeVad)(this.params);
32
+ this.vad = await (0, createVad_1.createVad)(this.params);
33
33
  }
34
34
  processChunk(data, callback) {
35
35
  if (!this.vad) {
@@ -1,7 +1,7 @@
1
- declare function makeVad(params: {
1
+ declare function createVad(params: {
2
2
  pathToModel: string;
3
3
  activationThreshold: number;
4
4
  deactivationThreshold: number;
5
5
  debounceFrames: number;
6
6
  }): Promise<(chunk: Uint8Array, callback: (event: "SPEECH_START" | "SPEECH_END") => void) => Promise<void>>;
7
- export { makeVad };
7
+ export { createVad };
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.makeVad = makeVad;
36
+ exports.createVad = createVad;
37
37
  /* eslint-disable no-loops/no-loops */
38
38
  /*
39
39
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
@@ -57,7 +57,7 @@ const ort = __importStar(require("onnxruntime-node"));
57
57
  const chunkToFloat32Array_1 = require("./chunkToFloat32Array");
58
58
  const SileroVadModel_1 = require("./SileroVadModel");
59
59
  const BUFFER_SIZE = 512;
60
- async function makeVad(params) {
60
+ async function createVad(params) {
61
61
  const { pathToModel, activationThreshold, deactivationThreshold, debounceFrames } = params;
62
62
  const silero = await SileroVadModel_1.SileroVadModel.new(ort, pathToModel);
63
63
  let audioBuffer = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/autopilot",
3
- "version": "0.8.25",
3
+ "version": "0.8.26",
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",
@@ -33,10 +33,10 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-s3": "^3.712.0",
36
- "@fonoster/common": "^0.8.25",
37
- "@fonoster/logger": "^0.8.24",
38
- "@fonoster/types": "^0.8.24",
39
- "@fonoster/voice": "^0.8.25",
36
+ "@fonoster/common": "^0.8.26",
37
+ "@fonoster/logger": "^0.8.26",
38
+ "@fonoster/types": "^0.8.26",
39
+ "@fonoster/voice": "^0.8.26",
40
40
  "@langchain/community": "^0.3.19",
41
41
  "@langchain/core": "^0.3.23",
42
42
  "@langchain/groq": "^0.1.2",
@@ -54,5 +54,5 @@
54
54
  "devDependencies": {
55
55
  "typescript": "^5.5.4"
56
56
  },
57
- "gitHead": "159876a77dc3f30e2d155a2d4f39d1a73919f2af"
57
+ "gitHead": "f01e634eca9a94b3a276369e998c6e75f8b75284"
58
58
  }