@fonoster/autopilot 0.9.21 → 0.9.22

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.
Files changed (137) hide show
  1. package/dist/Autopilot.js +6 -2
  2. package/dist/assistants/index.d.ts +18 -0
  3. package/dist/assistants/index.js +1 -1
  4. package/dist/assistants/loadAndValidateAssistant.js +2 -2
  5. package/dist/assistants/types.d.ts +19 -1
  6. package/dist/envs.d.ts +5 -5
  7. package/dist/envs.js +5 -5
  8. package/dist/handleVoiceRequest.js +11 -10
  9. package/dist/index.d.ts +18 -0
  10. package/dist/index.js +1 -1
  11. package/dist/knowledge/AbstractKnowledgeBase.js +1 -1
  12. package/dist/knowledge/FilesKnowledgeBase.d.ts +18 -0
  13. package/dist/knowledge/FilesKnowledgeBase.js +1 -1
  14. package/dist/knowledge/S3KnowledgeBase.d.ts +18 -0
  15. package/dist/knowledge/S3KnowledgeBase.js +1 -1
  16. package/dist/knowledge/index.d.ts +18 -0
  17. package/dist/knowledge/index.js +1 -1
  18. package/dist/knowledge/types.d.ts +18 -0
  19. package/dist/loadAssistantConfigFromFile.js +2 -2
  20. package/dist/loadAssistantFromAPI.d.ts +18 -0
  21. package/dist/loadAssistantFromAPI.js +12 -9
  22. package/dist/machine/actions/announceIdleTimeout.js +1 -1
  23. package/dist/machine/actions/announceSystemError.js +1 -1
  24. package/dist/machine/actions/appendSpeech.d.ts +1 -1
  25. package/dist/machine/actions/appendSpeech.js +2 -2
  26. package/dist/machine/actions/cleanSpeech.d.ts +1 -1
  27. package/dist/machine/actions/cleanSpeech.js +1 -1
  28. package/dist/machine/actions/goodbye.js +1 -1
  29. package/dist/machine/actions/greetUser.js +1 -1
  30. package/dist/machine/actions/increaseIdleTimeoutCount.d.ts +1 -1
  31. package/dist/machine/actions/increaseIdleTimeoutCount.js +2 -2
  32. package/dist/machine/actions/index.d.ts +18 -0
  33. package/dist/machine/actions/index.js +1 -1
  34. package/dist/machine/actions/interruptPlayback.js +1 -1
  35. package/dist/machine/actions/resetIdleTimeoutCount.d.ts +1 -1
  36. package/dist/machine/actions/resetIdleTimeoutCount.js +2 -2
  37. package/dist/machine/actions/resetState.d.ts +1 -1
  38. package/dist/machine/actions/resetState.js +2 -2
  39. package/dist/machine/actions/setSpeaking.d.ts +1 -1
  40. package/dist/machine/actions/setSpeaking.js +2 -2
  41. package/dist/machine/actions/setSpeakingDone.d.ts +1 -1
  42. package/dist/machine/actions/setSpeakingDone.js +2 -2
  43. package/dist/machine/actors/doProcessUserRequest.js +2 -2
  44. package/dist/machine/actors/index.d.ts +18 -0
  45. package/dist/machine/actors/index.js +1 -1
  46. package/dist/machine/context.d.ts +18 -0
  47. package/dist/machine/context.js +1 -1
  48. package/dist/machine/delays.d.ts +18 -0
  49. package/dist/machine/delays.js +1 -2
  50. package/dist/machine/guards/hasSpeechResult.js +1 -1
  51. package/dist/machine/guards/idleTimeoutCountExceedsMax.js +1 -1
  52. package/dist/machine/guards/index.d.ts +18 -0
  53. package/dist/machine/guards/index.js +1 -1
  54. package/dist/machine/guards/isSpeaking.js +1 -1
  55. package/dist/machine/index.d.ts +18 -0
  56. package/dist/machine/index.js +1 -1
  57. package/dist/machine/machine.d.ts +38 -81
  58. package/dist/machine/machine.js +1 -2
  59. package/dist/machine/setup.d.ts +67 -83
  60. package/dist/machine/setup.js +57 -12
  61. package/dist/machine/types.d.ts +28 -1
  62. package/dist/models/AbstractLanguageModel.d.ts +1 -1
  63. package/dist/models/AbstractLanguageModel.js +3 -3
  64. package/dist/models/LanguageModelFactory.d.ts +2 -2
  65. package/dist/models/LanguageModelFactory.js +2 -2
  66. package/dist/models/chatHistory.js +1 -1
  67. package/dist/models/createChain.d.ts +19 -1
  68. package/dist/models/createLanguageModel.d.ts +18 -0
  69. package/dist/models/createLanguageModel.js +5 -6
  70. package/dist/models/createPromptTemplate.d.ts +18 -0
  71. package/dist/models/createPromptTemplate.js +1 -1
  72. package/dist/models/evaluations/createTestTextSimilarity.js +1 -1
  73. package/dist/models/evaluations/evalTestCases.d.ts +24 -2
  74. package/dist/models/evaluations/evalTestCases.js +3 -3
  75. package/dist/models/evaluations/evaluateScenario.js +18 -0
  76. package/dist/models/evaluations/evaluateStep.js +21 -3
  77. package/dist/models/evaluations/evaluateTextResponse.d.ts +18 -0
  78. package/dist/models/evaluations/evaluateTextResponse.js +1 -1
  79. package/dist/models/evaluations/evaluateToolCalls.js +18 -0
  80. package/dist/models/evaluations/index.d.ts +18 -0
  81. package/dist/models/evaluations/index.js +1 -1
  82. package/dist/models/evaluations/printEval.js +2 -2
  83. package/dist/models/evaluations/textSimilaryPrompt.d.ts +18 -0
  84. package/dist/models/evaluations/textSimilaryPrompt.js +1 -1
  85. package/dist/models/evaluations/types.d.ts +19 -6
  86. package/dist/models/groq/Groq.d.ts +1 -1
  87. package/dist/models/groq/index.d.ts +18 -0
  88. package/dist/models/groq/index.js +2 -2
  89. package/dist/models/groq/types.d.ts +18 -0
  90. package/dist/models/index.d.ts +18 -0
  91. package/dist/models/index.js +2 -2
  92. package/dist/models/ollama/Ollama.d.ts +1 -1
  93. package/dist/models/ollama/index.d.ts +18 -0
  94. package/dist/models/ollama/index.js +1 -1
  95. package/dist/models/ollama/types.d.ts +18 -0
  96. package/dist/models/openai/OpenAI.d.ts +1 -1
  97. package/dist/models/openai/index.d.ts +18 -0
  98. package/dist/models/openai/index.js +2 -2
  99. package/dist/models/openai/types.d.ts +18 -0
  100. package/dist/models/toolInvocation.d.ts +1 -1
  101. package/dist/models/toolInvocation.js +1 -1
  102. package/dist/models/types.d.ts +19 -1
  103. package/dist/sendConversationEndedEvent.d.ts +19 -2
  104. package/dist/sendConversationEndedEvent.js +1 -1
  105. package/dist/server.js +163 -1
  106. package/dist/tools/ToolsCatalog.d.ts +1 -1
  107. package/dist/tools/ToolsCatalog.js +6 -6
  108. package/dist/tools/builtin/hangupToolDefinition.d.ts +19 -1
  109. package/dist/tools/builtin/transferToolDefinition.d.ts +19 -1
  110. package/dist/tools/convertToolToOpenAITool.d.ts +19 -1
  111. package/dist/tools/index.d.ts +18 -0
  112. package/dist/tools/index.js +1 -1
  113. package/dist/tools/types.d.ts +27 -0
  114. package/dist/types.d.ts +27 -2
  115. package/dist/vad/SileroVad.js +1 -2
  116. package/dist/vad/SileroVadModel.js +1 -1
  117. package/dist/vad/chunkToFloat32Array.d.ts +18 -0
  118. package/dist/vad/chunkToFloat32Array.js +1 -5
  119. package/dist/vad/createVad.js +1 -10
  120. package/dist/vad/index.d.ts +18 -0
  121. package/dist/vad/index.js +1 -2
  122. package/dist/vad/types.d.ts +18 -0
  123. package/dist/vadWorker.js +3 -3
  124. package/dist/vadv5/SileroVad.js +1 -2
  125. package/dist/vadv5/SileroVadModel.js +1 -1
  126. package/dist/vadv5/createVad.js +3 -4
  127. package/dist/vadv5/index.d.ts +18 -0
  128. package/dist/vadv5/index.js +1 -2
  129. package/dist/vadv5/types.d.ts +18 -0
  130. package/dist/voice/Voice.js +1 -1
  131. package/dist/voice/index.d.ts +18 -0
  132. package/dist/voice/index.js +2 -2
  133. package/dist/voice/types.d.ts +18 -0
  134. package/dist/voiceServerSetup.js +1 -1
  135. package/package.json +9 -11
  136. package/dist/tools/type.d.ts +0 -9
  137. /package/dist/tools/{type.js → types.js} +0 -0
@@ -37,8 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.machineSetup = void 0;
40
- // @ts-nocheck - All inputs are validated by the APIServer
41
- /*
40
+ /**
42
41
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
43
42
  * http://github.com/fonoster/fonoster
44
43
  *
@@ -56,26 +55,72 @@ exports.machineSetup = void 0;
56
55
  * See the License for the specific language governing permissions and
57
56
  * limitations under the License.
58
57
  */
58
+ const logger_1 = require("@fonoster/logger");
59
59
  const xstate_1 = require("xstate");
60
- const actors = __importStar(require("./actors"));
61
- const guards = __importStar(require("./guards"));
62
60
  const actions = __importStar(require("./actions"));
61
+ const actors = __importStar(require("./actors"));
63
62
  const delays_1 = __importDefault(require("./delays"));
63
+ const guards = __importStar(require("./guards"));
64
+ const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
64
65
  const machineSetup = (0, xstate_1.setup)({
65
66
  types: {
66
67
  context: {},
67
68
  input: {},
68
69
  events: {}
69
70
  },
70
- actions,
71
+ actions: {
72
+ ...actions,
73
+ // FIX: Move all this to the actions folder
74
+ appendSpeech: (0, xstate_1.assign)(({ context, event }) => {
75
+ const speech = event.speech;
76
+ logger.verbose("called the appendSpeech action", { speech });
77
+ if (!speech) {
78
+ return context;
79
+ }
80
+ context.speechBuffer = ((context.speechBuffer ?? "") +
81
+ " " +
82
+ speech).trimStart();
83
+ return context;
84
+ }),
85
+ cleanSpeech: (0, xstate_1.assign)({ speechBuffer: "" }),
86
+ increaseIdleTimeoutCount: (0, xstate_1.assign)(({ context }) => {
87
+ logger.verbose("called the increaseIdleTimeoutCount action", {
88
+ idleTimeoutCount: context.idleTimeoutCount + 1
89
+ });
90
+ context.idleTimeoutCount++;
91
+ return context;
92
+ }),
93
+ resetIdleTimeoutCount: (0, xstate_1.assign)(({ context }) => {
94
+ logger.verbose("called the resetIdleTimeoutCount action", {
95
+ idleTimeoutCount: 0
96
+ });
97
+ context.idleTimeoutCount = 0;
98
+ return context;
99
+ }),
100
+ resetState: (0, xstate_1.assign)(({ context }) => {
101
+ logger.verbose("called the resetState action");
102
+ return {
103
+ ...context,
104
+ speechBuffer: "",
105
+ idleTimeoutCount: 0,
106
+ isSpeaking: false
107
+ };
108
+ }),
109
+ setSpeaking: (0, xstate_1.assign)(({ context }) => {
110
+ logger.verbose("called the setSpeaking action", { isSpeaking: true });
111
+ context.isSpeaking = true;
112
+ return context;
113
+ }),
114
+ setSpeakingDone: (0, xstate_1.assign)(({ context }) => {
115
+ logger.verbose("called the setSpeakingDone action", {
116
+ isSpeaking: false
117
+ });
118
+ context.isSpeaking = false;
119
+ return context;
120
+ })
121
+ },
71
122
  guards,
72
123
  delays: delays_1.default,
73
- actors,
74
- after: {
75
- SESSION_TIMEOUT: {
76
- target: "hangup",
77
- actions: ["goodbye"]
78
- }
79
- }
124
+ actors
80
125
  });
81
126
  exports.machineSetup = machineSetup;
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { LanguageModel } from "../models";
2
20
  import { Voice } from "../voice";
3
21
  type AutopilotContext = {
@@ -19,4 +37,13 @@ type AutopilotContext = {
19
37
  isSpeaking: boolean;
20
38
  knowledgeBaseSourceUrl?: string;
21
39
  };
22
- export { AutopilotContext };
40
+ type AutopilotEvents = {
41
+ type: "SPEECH_START";
42
+ } | {
43
+ type: "SPEECH_END";
44
+ } | {
45
+ type: "SPEECH_RESULT";
46
+ speech: string;
47
+ responseTime: number;
48
+ };
49
+ export { AutopilotContext, AutopilotEvents };
@@ -1,5 +1,5 @@
1
- import { InvocationResult, LanguageModel, LanguageModelParams, TelephonyContext } from "./types";
2
1
  import { Voice } from "../voice";
2
+ import { InvocationResult, LanguageModel, LanguageModelParams, TelephonyContext } from "./types";
3
3
  declare abstract class AbstractLanguageModel implements LanguageModel {
4
4
  private readonly chain;
5
5
  private readonly chatHistory;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractLanguageModel = void 0;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -20,11 +20,11 @@ exports.AbstractLanguageModel = void 0;
20
20
  * limitations under the License.
21
21
  */
22
22
  const logger_1 = require("@fonoster/logger");
23
+ const tools_1 = require("../tools");
23
24
  const chatHistory_1 = require("./chatHistory");
24
25
  const createChain_1 = require("./createChain");
25
26
  const createPromptTemplate_1 = require("./createPromptTemplate");
26
27
  const toolInvocation_1 = require("./toolInvocation");
27
- 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) {
@@ -48,7 +48,7 @@ class AbstractLanguageModel {
48
48
  logger.verbose("invoke", {
49
49
  text,
50
50
  response: response.content,
51
- hasTools: response.tool_calls?.length > 0,
51
+ hasTools: (response.tool_calls?.length ?? 0) > 0,
52
52
  tools: response.tool_calls?.map((tool) => tool.name)
53
53
  });
54
54
  // Begin the conversation with the first message
@@ -1,10 +1,10 @@
1
+ import { LanguageModelProvider } from "../types";
2
+ import { Voice } from "../voice";
1
3
  import { AbstractLanguageModel } from "./AbstractLanguageModel";
2
4
  import { GroqParams } from "./groq";
3
5
  import { OllamaParams } from "./ollama";
4
6
  import { OpenAIParams } from "./openai";
5
7
  import { BaseModelParams, TelephonyContext } from "./types";
6
- import { LanguageModelProvider } from "../types";
7
- import { Voice } from "../voice";
8
8
  type LanguageModelConstructor<T extends BaseModelParams = BaseModelParams> = new (options: T, voice: Voice, telephonyContext: TelephonyContext) => AbstractLanguageModel;
9
9
  type LanguageModelConfigMap = {
10
10
  [LanguageModelProvider.OPENAI]: OpenAIParams;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LanguageModelFactory = void 0;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -20,10 +20,10 @@ exports.LanguageModelFactory = void 0;
20
20
  * limitations under the License.
21
21
  */
22
22
  const logger_1 = require("@fonoster/logger");
23
+ const types_1 = require("../types");
23
24
  const groq_1 = require("./groq");
24
25
  const ollama_1 = require("./ollama");
25
26
  const openai_1 = require("./openai");
26
- const types_1 = require("../types");
27
27
  const logger = (0, logger_1.getLogger)({ service: "autopilot", filePath: __filename });
28
28
  class LanguageModelFactory {
29
29
  static registerLanguageModel(name, ctor) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createChatHistory = createChatHistory;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -1,7 +1,25 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { BaseChatModel } from "@langchain/core/language_models/chat_models";
2
20
  import { RunnableSequence } from "@langchain/core/runnables";
21
+ import { KnowledgeBase } from "../knowledge";
3
22
  import { createChatHistory } from "./chatHistory";
4
23
  import { createPromptTemplate } from "./createPromptTemplate";
5
- import { KnowledgeBase } from "../knowledge";
6
24
  declare function createChain(model: BaseChatModel, knowledgeBase: KnowledgeBase, promptTemplate: ReturnType<typeof createPromptTemplate>, chatHistory: ReturnType<typeof createChatHistory>): RunnableSequence<any, import("@langchain/core/messages").AIMessageChunk>;
7
25
  export { createChain };
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { AssistantConfig, KnowledgeBase, TelephonyContext, Voice } from "..";
2
20
  declare function createLanguageModel(params: {
3
21
  voice: Voice;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLanguageModel = createLanguageModel;
4
- // @ts-nocheck - All inputs are validated by the APIServer
5
- /*
4
+ /**
6
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
7
6
  * http://github.com/fonoster/fonoster
8
7
  *
@@ -23,13 +22,13 @@ exports.createLanguageModel = createLanguageModel;
23
22
  const __1 = require("..");
24
23
  function createLanguageModel(params) {
25
24
  const { voice, assistantConfig, knowledgeBase, telephonyContext } = params;
26
- const { languageModel: languageModelSettings, conversationSettings } = assistantConfig;
25
+ const { languageModel, conversationSettings } = assistantConfig;
27
26
  // The transfer tool is only added if the transfer options exist
28
- const tools = languageModelSettings.tools.concat(assistantConfig.conversationSettings.transferOptions
27
+ const tools = languageModel.tools.concat(conversationSettings.transferOptions
29
28
  ? [__1.hangupToolDefinition, __1.transferToolDefinition]
30
29
  : [__1.hangupToolDefinition]);
31
- return __1.LanguageModelFactory.getLanguageModel(languageModelSettings.provider, {
32
- ...languageModelSettings,
30
+ return __1.LanguageModelFactory.getLanguageModel(languageModel.provider, {
31
+ ...languageModel,
33
32
  ...conversationSettings,
34
33
  knowledgeBase,
35
34
  tools
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { ChatPromptTemplate } from "@langchain/core/prompts";
2
20
  import { TelephonyContext } from "./types";
3
21
  export declare function createPromptTemplate(params: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPromptTemplate = createPromptTemplate;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTestTextSimilarity = createTestTextSimilarity;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ import { AssistantConfig } from "../../assistants";
1
20
  import { ScenarioEvaluationReport } from "./types";
2
- import { AutopilotApplication } from "./types";
3
- export declare function evalTestCases(autopilotApplication: AutopilotApplication): Promise<ScenarioEvaluationReport[]>;
21
+ export declare function evalTestCases(autopilotApplication: {
22
+ intelligence: {
23
+ config: AssistantConfig;
24
+ };
25
+ }): Promise<ScenarioEvaluationReport[]>;
@@ -12,19 +12,19 @@ async function evalTestCases(autopilotApplication) {
12
12
  say: async (_) => { }
13
13
  };
14
14
  const evaluationReports = [];
15
- for (const scenario of testCases?.scenarios) {
15
+ for (const scenario of testCases?.scenarios ?? []) {
16
16
  const languageModel = (0, createLanguageModel_1.createLanguageModel)({
17
17
  voice,
18
18
  assistantConfig: autopilotApplication.intelligence.config,
19
19
  knowledgeBase: {
20
20
  load: async () => { },
21
- queryKnowledgeBase: async (query, k) => query
21
+ queryKnowledgeBase: async (query) => query
22
22
  },
23
23
  telephonyContext: scenario.telephonyContext
24
24
  });
25
25
  const testTextSimilarity = (0, createTestTextSimilarity_1.createTestTextSimilarity)({
26
26
  provider: assistantConfig.testCases?.evalsLanguageModel?.provider,
27
- model: assistantConfig.testCases?.evalsLanguageModel?.model,
27
+ model: assistantConfig.testCases?.evalsLanguageModel?.model ?? "",
28
28
  apiKey: assistantConfig.testCases?.evalsLanguageModel?.apiKey
29
29
  }, assistantConfig.testCases?.evalsSystemPrompt || textSimilaryPrompt_1.textSimilaryPrompt);
30
30
  const evaluationReport = await (0, evaluateScenario_1.evaluateScenario)({
@@ -1,6 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateScenario = evaluateScenario;
4
+ /**
5
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/fonoster
7
+ *
8
+ * This file is part of Fonoster
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
4
22
  const evaluateStep_1 = require("./evaluateStep");
5
23
  async function evaluateScenario(config) {
6
24
  const { scenario, languageModel, testTextSimilarity, assistantConfig } = config;
@@ -1,6 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateStep = evaluateStep;
4
+ /**
5
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/fonoster
7
+ *
8
+ * This file is part of Fonoster
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
4
22
  const evaluateTextResponse_1 = require("./evaluateTextResponse");
5
23
  const evaluateToolCalls_1 = require("./evaluateToolCalls");
6
24
  async function evaluateStep({ step, languageModel, testTextSimilarity, assistantConfig }) {
@@ -18,18 +36,18 @@ async function evaluateStep({ step, languageModel, testTextSimilarity, assistant
18
36
  const topTool = response.toolCalls[0];
19
37
  if (topTool.name === "hangup") {
20
38
  stepResult.aiResponse =
21
- assistantConfig.conversationSettings?.goodbyeMessage;
39
+ assistantConfig.conversationSettings?.goodbyeMessage || "";
22
40
  }
23
41
  else if (topTool.name === "transfer") {
24
42
  stepResult.aiResponse =
25
43
  assistantConfig.conversationSettings?.transferOptions?.message ?? "";
26
44
  }
27
45
  else {
28
- stepResult.aiResponse = response.content;
46
+ stepResult.aiResponse = response.content ?? "";
29
47
  }
30
48
  }
31
49
  else {
32
- stepResult.aiResponse = response.content;
50
+ stepResult.aiResponse = response.content ?? "";
33
51
  }
34
52
  const textEvaluation = await (0, evaluateTextResponse_1.evaluateTextResponse)(step.expected.text, stepResult.aiResponse, testTextSimilarity);
35
53
  if (!textEvaluation.passed) {
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { ExpectedTextType } from "./types";
2
20
  export declare function evaluateTextResponse(expected: {
3
21
  type: ExpectedTextType;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateTextResponse = evaluateTextResponse;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -4,6 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.evaluateToolCalls = evaluateToolCalls;
7
+ /**
8
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
9
+ * http://github.com/fonoster/fonoster
10
+ *
11
+ * This file is part of Fonoster
12
+ *
13
+ * Licensed under the MIT License (the "License");
14
+ * you may not use this file except in compliance with
15
+ * the License. You may obtain a copy of the License at
16
+ *
17
+ * https://opensource.org/licenses/MIT
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
7
25
  const moment_1 = __importDefault(require("moment"));
8
26
  function evaluateToolCalls(expectedTools, toolCalls) {
9
27
  const evaluations = [];
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  export * from "./evalTestCases";
2
20
  export * from "./printEval";
3
21
  export * from "./types";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- /*
17
+ /**
18
18
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
19
19
  * http://github.com/fonoster/fonoster
20
20
  *
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.printEval = printEval;
7
- /*
7
+ /**
8
8
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
9
9
  * http://github.com/fonoster/fonoster
10
10
  *
@@ -22,8 +22,8 @@ exports.printEval = printEval;
22
22
  * See the License for the specific language governing permissions and
23
23
  * limitations under the License.
24
24
  */
25
- const cli_table3_1 = __importDefault(require("cli-table3"));
26
25
  const chalk_1 = __importDefault(require("chalk"));
26
+ const cli_table3_1 = __importDefault(require("cli-table3"));
27
27
  function printEval(results) {
28
28
  results.forEach((result) => {
29
29
  console.log(chalk_1.default.bold.blue(`\nScenario: ${result.scenarioRef}`));
@@ -1 +1,19 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  export declare const textSimilaryPrompt = "\nYou are a text similarity evaluator for a Voice Assistant application. \n\nGive Text1 and Text2, you use the following process to evaluate the similarity between the two texts:\n\n- Take the first text and determmine the intent of the text.\n- Take the second text and determine the intent of the text.\n- Compare the intents of the two texts ignoring the actual text content, the entities, and length of the text.\n\n## Example 1\n\nText1: \"You're welcome. Have a great day!\"\nText2: \"You're welcome [name]. Your appointment is confirmed. Goodbye!\"\n\nAnswer: true\n\n=== \n\nAre the intents of the two texts the same? Respond with true.\n";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.textSimilaryPrompt = void 0;
4
- /*
4
+ /**
5
5
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
6
6
  * http://github.com/fonoster/fonoster
7
7
  *
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
1
19
  import { AssistantConfig } from "../../assistants";
2
20
  import { LanguageModel } from "../types";
3
21
  declare enum ExpectedTextType {
@@ -38,9 +56,4 @@ type ScenarioEvaluationConfig = {
38
56
  languageModel: LanguageModel;
39
57
  testTextSimilarity: (text1: string, text2: string) => Promise<boolean>;
40
58
  };
41
- type AutopilotApplication = {
42
- intelligence: {
43
- config: AssistantConfig;
44
- };
45
- };
46
- export { AutopilotApplication, ExpectedTextType, ScenarioEvaluationReport, StepEvaluationReport, ToolEvaluationReport, ScenarioEvaluationConfig, EvaluateStepParams };
59
+ export { ExpectedTextType, ScenarioEvaluationReport, StepEvaluationReport, ToolEvaluationReport, ScenarioEvaluationConfig, EvaluateStepParams };
@@ -1,7 +1,7 @@
1
- import { GroqParams } from "./types";
2
1
  import { Voice } from "../../voice";
3
2
  import { AbstractLanguageModel } from "../AbstractLanguageModel";
4
3
  import { TelephonyContext } from "../types";
4
+ import { GroqParams } from "./types";
5
5
  declare const LANGUAGE_MODEL_NAME = "llm.groq";
6
6
  declare class Groq extends AbstractLanguageModel {
7
7
  constructor(params: GroqParams, voice: Voice, telephonyContext: TelephonyContext);