@fonoster/autopilot 0.8.41 → 0.8.43

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.
@@ -34,7 +34,7 @@ function createLanguageModel(params) {
34
34
  maxTokens: languageModelSettings.maxTokens,
35
35
  temperature: languageModelSettings.temperature,
36
36
  firstMessage: conversationSettings.firstMessage,
37
- systemTemplate: conversationSettings.systemTemplate,
37
+ systemPrompt: conversationSettings.systemPrompt,
38
38
  baseUrl: languageModelSettings.baseUrl,
39
39
  knowledgeBase,
40
40
  tools
@@ -241,6 +241,11 @@ const machine = (0, xstate_1.setup)({
241
241
  SPEECH_START: {
242
242
  target: "waitingForUserRequest",
243
243
  description: "Event from VAD system."
244
+ },
245
+ SPEECH_RESULT: {
246
+ target: "waitingForUserRequest",
247
+ description: "User started speaking before SPEECH_START event",
248
+ actions: [{ type: "appendSpeech" }]
244
249
  }
245
250
  },
246
251
  after: {
@@ -299,29 +304,12 @@ const machine = (0, xstate_1.setup)({
299
304
  {
300
305
  actions: { type: "appendSpeech" },
301
306
  guard: "isSpeaking",
302
- description: "Just append the speech result."
303
- },
304
- {
305
- target: "processingUserRequest",
306
- actions: { type: "appendSpeech" },
307
- guard: (0, xstate_1.not)("isSpeaking"),
308
- description: "Append the speech result and process it."
307
+ description: "Just append the speech result when actively speaking"
309
308
  }
310
309
  ]
311
310
  }
312
311
  },
313
312
  waitingForSpeechTimeout: {
314
- after: {
315
- MAX_SPEECH_WAIT_TIMEOUT: [
316
- {
317
- target: "processingUserRequest",
318
- guard: "hasSpeechResult"
319
- },
320
- {
321
- target: "idle"
322
- }
323
- ]
324
- },
325
313
  on: {
326
314
  SPEECH_START: {
327
315
  target: "waitingForUserRequest",
@@ -334,6 +322,17 @@ const machine = (0, xstate_1.setup)({
334
322
  },
335
323
  description: "Append final speech and process the request"
336
324
  }
325
+ },
326
+ after: {
327
+ MAX_SPEECH_WAIT_TIMEOUT: [
328
+ {
329
+ target: "processingUserRequest",
330
+ guard: "hasSpeechResult"
331
+ },
332
+ {
333
+ target: "idle"
334
+ }
335
+ ]
337
336
  }
338
337
  },
339
338
  processingUserRequest: {
@@ -28,13 +28,13 @@ const tools_1 = require("../tools");
28
28
  const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
29
29
  class AbstractLanguageModel {
30
30
  constructor(params, voice, telephonyContext) {
31
- const { model, firstMessage, systemTemplate, knowledgeBase, tools } = params;
31
+ const { model, firstMessage, systemPrompt, knowledgeBase, tools } = params;
32
32
  this.chatHistory = (0, chatHistory_1.createChatHistory)();
33
33
  this.toolsCatalog = new tools_1.ToolsCatalog(tools);
34
34
  this.voice = voice;
35
35
  const promptTemplate = (0, createPromptTemplate_1.createPromptTemplate)({
36
36
  firstMessage,
37
- systemTemplate,
37
+ systemPrompt,
38
38
  telephonyContext
39
39
  });
40
40
  this.chain = (0, createChain_1.createChain)(model, knowledgeBase, promptTemplate, this.chatHistory);
@@ -2,6 +2,6 @@ import { ChatPromptTemplate } from "@langchain/core/prompts";
2
2
  import { TelephonyContext } from "./types";
3
3
  export declare function createPromptTemplate(params: {
4
4
  firstMessage?: string;
5
- systemTemplate: string;
5
+ systemPrompt: string;
6
6
  telephonyContext: TelephonyContext;
7
7
  }): ChatPromptTemplate<any, any>;
@@ -21,11 +21,11 @@ exports.createPromptTemplate = createPromptTemplate;
21
21
  */
22
22
  const prompts_1 = require("@langchain/core/prompts");
23
23
  function createPromptTemplate(params) {
24
- const { firstMessage, systemTemplate, telephonyContext } = params;
24
+ const { firstMessage, systemPrompt, telephonyContext } = params;
25
25
  return prompts_1.ChatPromptTemplate.fromMessages([
26
26
  new prompts_1.MessagesPlaceholder("history"),
27
27
  prompts_1.SystemMessagePromptTemplate.fromTemplate(`firstMessage: ${firstMessage}`),
28
- prompts_1.SystemMessagePromptTemplate.fromTemplate(systemTemplate),
28
+ prompts_1.SystemMessagePromptTemplate.fromTemplate(systemPrompt),
29
29
  prompts_1.SystemMessagePromptTemplate.fromTemplate("{context}"),
30
30
  prompts_1.SystemMessagePromptTemplate.fromTemplate(`callReceivedAt:${new Date().toISOString()}
31
31
  ingressNumber:${telephonyContext.ingressNumber}
@@ -7,7 +7,7 @@ type LanguageModel = {
7
7
  };
8
8
  type BaseModelParams = {
9
9
  firstMessage?: string;
10
- systemTemplate: string;
10
+ systemPrompt: string;
11
11
  knowledgeBase: KnowledgeBase;
12
12
  tools: Tool[];
13
13
  telephonyContext: TelephonyContext;
package/dist/vadWorker.js CHANGED
@@ -23,13 +23,15 @@ const SileroVad_1 = require("./vad/SileroVad");
23
23
  const SileroVad_2 = require("./vadv5/SileroVad");
24
24
  const envs_1 = require("./envs");
25
25
  const path_1 = require("path");
26
- const vad = envs_1.SILERO_VAD_VERSION === "v4" ? new SileroVad_1.SileroVad({
27
- ...worker_threads_1.workerData,
28
- pathToModel: (0, path_1.join)(__dirname, "..", "silero_vad.onnx")
29
- }) : new SileroVad_2.SileroVad({
30
- ...worker_threads_1.workerData,
31
- pathToModel: (0, path_1.join)(__dirname, "..", "silero_vad_v5.onnx")
32
- });
26
+ const vad = envs_1.SILERO_VAD_VERSION === "v4"
27
+ ? new SileroVad_1.SileroVad({
28
+ ...worker_threads_1.workerData,
29
+ pathToModel: (0, path_1.join)(__dirname, "..", "silero_vad.onnx")
30
+ })
31
+ : new SileroVad_2.SileroVad({
32
+ ...worker_threads_1.workerData,
33
+ pathToModel: (0, path_1.join)(__dirname, "..", "silero_vad_v5.onnx")
34
+ });
33
35
  vad.init().then(() => {
34
36
  worker_threads_1.parentPort?.on("message", (chunk) => {
35
37
  vad.processChunk(chunk, (voiceActivity) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/autopilot",
3
- "version": "0.8.41",
3
+ "version": "0.8.43",
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,11 +33,11 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-s3": "^3.712.0",
36
- "@fonoster/common": "^0.8.41",
37
- "@fonoster/logger": "^0.8.41",
38
- "@fonoster/sdk": "^0.8.41",
39
- "@fonoster/types": "^0.8.41",
40
- "@fonoster/voice": "^0.8.41",
36
+ "@fonoster/common": "^0.8.43",
37
+ "@fonoster/logger": "^0.8.43",
38
+ "@fonoster/sdk": "^0.8.43",
39
+ "@fonoster/types": "^0.8.43",
40
+ "@fonoster/voice": "^0.8.43",
41
41
  "@langchain/community": "^0.3.19",
42
42
  "@langchain/core": "^0.3.23",
43
43
  "@langchain/groq": "^0.1.2",
@@ -55,5 +55,5 @@
55
55
  "devDependencies": {
56
56
  "typescript": "^5.5.4"
57
57
  },
58
- "gitHead": "9aeac381dc6e2864d81b3fcc8dfe6f067910516f"
58
+ "gitHead": "b6971e5e184c3deb7d2f133bf99abaa70cc6ccaa"
59
59
  }