@fonoster/autopilot 0.13.4 → 0.13.5

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.
@@ -0,0 +1,120 @@
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";
20
+ export declare function createEvalEffectiveConfig(config: AssistantConfig, credentials: {
21
+ apiKey: string;
22
+ }, evaluationApiKey: {
23
+ apiKey: string;
24
+ }): {
25
+ languageModel: {
26
+ apiKey: string;
27
+ provider?: import("@fonoster/common").LanguageModelProvider;
28
+ model?: string;
29
+ temperature?: number;
30
+ maxTokens?: number;
31
+ baseUrl?: string;
32
+ knowledgeBase?: {
33
+ type?: "s3";
34
+ title?: string;
35
+ document?: string;
36
+ }[];
37
+ tools?: {
38
+ name?: string;
39
+ description?: string;
40
+ parameters?: {
41
+ type?: "object" | "array";
42
+ properties?: Record<string, {
43
+ type?: string;
44
+ format?: "enum" | "date-time";
45
+ pattern?: string;
46
+ }>;
47
+ required?: string[];
48
+ };
49
+ requestStartMessage?: string;
50
+ operation?: {
51
+ url?: string;
52
+ method?: import("@fonoster/common").AllowedHttpMethod;
53
+ headers?: Record<string, string>;
54
+ waitForResponse?: boolean;
55
+ };
56
+ }[];
57
+ };
58
+ testCases: {
59
+ evalsLanguageModel: {
60
+ apiKey: string;
61
+ provider?: "openai";
62
+ model?: string;
63
+ };
64
+ evalsSystemPrompt?: string;
65
+ scenarios?: {
66
+ description?: string;
67
+ ref?: string;
68
+ telephonyContext?: {
69
+ callDirection?: import("@fonoster/types").CallDirection;
70
+ ingressNumber?: string;
71
+ callerNumber?: string;
72
+ metadata?: Record<string, string>;
73
+ };
74
+ conversation?: {
75
+ expected?: {
76
+ tools?: {
77
+ parameters?: Record<string, any>;
78
+ tool?: string;
79
+ }[];
80
+ text?: {
81
+ type?: "EXACT" | "SIMILAR";
82
+ response?: string;
83
+ };
84
+ };
85
+ userInput?: string;
86
+ }[];
87
+ }[];
88
+ };
89
+ conversationSettings?: {
90
+ firstMessage?: string;
91
+ systemPrompt?: string;
92
+ goodbyeMessage?: string;
93
+ systemErrorMessage?: string;
94
+ initialDtmf?: string;
95
+ maxSessionDuration?: number;
96
+ maxSpeechWaitTimeout?: number;
97
+ transferOptions?: {
98
+ message?: string;
99
+ phoneNumber?: string;
100
+ timeout?: number;
101
+ };
102
+ idleOptions?: {
103
+ message?: string;
104
+ timeout?: number;
105
+ maxTimeoutCount?: number;
106
+ };
107
+ allowUserBargeIn?: boolean;
108
+ vad?: {
109
+ pathToModel?: string;
110
+ activationThreshold?: number;
111
+ deactivationThreshold?: number;
112
+ debounceFrames?: number;
113
+ };
114
+ };
115
+ eventsHook?: {
116
+ url?: string;
117
+ headers?: Record<string, string>;
118
+ events?: import("@fonoster/common").EventsHookAllowedEvents[];
119
+ };
120
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEvalEffectiveConfig = createEvalEffectiveConfig;
4
+ function createEvalEffectiveConfig(config, credentials, evaluationApiKey) {
5
+ return {
6
+ ...config,
7
+ languageModel: {
8
+ ...config.languageModel,
9
+ apiKey: credentials.apiKey
10
+ },
11
+ testCases: {
12
+ ...config.testCases,
13
+ evalsLanguageModel: {
14
+ ...config.testCases.evalsLanguageModel,
15
+ apiKey: evaluationApiKey.apiKey
16
+ }
17
+ }
18
+ };
19
+ }
@@ -0,0 +1,23 @@
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 { GrpcErrorMessage, IntegrationConfig } from "@fonoster/common";
20
+ declare function createEvaluateIntelligence(integrations: IntegrationConfig[]): (call: {
21
+ request: unknown;
22
+ }, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
23
+ export { createEvaluateIntelligence };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEvaluateIntelligence = createEvaluateIntelligence;
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
+ */
22
+ const common_1 = require("@fonoster/common");
23
+ const logger_1 = require("@fonoster/logger");
24
+ const pb_util_1 = require("pb-util");
25
+ const zod_1 = require("zod");
26
+ const createEvalEffectiveConfig_1 = require("./createEvalEffectiveConfig");
27
+ const evalTestCases_1 = require("./evalTestCases");
28
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
29
+ function createEvaluateIntelligence(integrations) {
30
+ const evaluateIntelligence = async (call, callback) => {
31
+ const { request } = call;
32
+ const { intelligence } = request;
33
+ const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
34
+ logger.verbose("call to evaluateIntelligence", {
35
+ accessKeyId,
36
+ llmProductRef: intelligence.productRef,
37
+ evalLlmProductRef: "llm.openai"
38
+ });
39
+ const config = pb_util_1.struct.decode(intelligence.config);
40
+ const parsedIntelligence = zod_1.z
41
+ .object({
42
+ productRef: zod_1.z.string(),
43
+ config: common_1.assistantSchema
44
+ })
45
+ .parse({
46
+ productRef: intelligence.productRef,
47
+ config: config
48
+ });
49
+ const credentials = (0, common_1.findIntegrationsCredentials)(integrations, intelligence.productRef);
50
+ const evaluationApiKey = (0, common_1.findIntegrationsCredentials)(integrations, "llm.openai");
51
+ const effectiveConfig = (0, createEvalEffectiveConfig_1.createEvalEffectiveConfig)(parsedIntelligence.config, credentials, evaluationApiKey);
52
+ const results = await (0, evalTestCases_1.evalTestCases)({
53
+ intelligence: {
54
+ config: effectiveConfig
55
+ }
56
+ });
57
+ callback(null, { results });
58
+ };
59
+ return (0, common_1.withErrorHandling)(evaluateIntelligence);
60
+ }
@@ -16,8 +16,8 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
+ import { ScenarioEvaluationReport } from "@fonoster/types";
19
20
  import { AssistantConfig } from "../../assistants";
20
- import { ScenarioEvaluationReport } from "./types";
21
21
  export declare function evalTestCases(autopilotApplication: {
22
22
  intelligence: {
23
23
  config: AssistantConfig;
@@ -1,2 +1,21 @@
1
- import { ScenarioEvaluationConfig, ScenarioEvaluationReport } from "./types";
2
- export declare function evaluateScenario(config: ScenarioEvaluationConfig): Promise<ScenarioEvaluationReport>;
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 { ScenarioEvaluationReport } from "@fonoster/types";
20
+ import { ScenarioEvaluationRequest } from "./types";
21
+ export declare function evaluateScenario(config: ScenarioEvaluationRequest): Promise<ScenarioEvaluationReport>;
@@ -1,24 +1,6 @@
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
- */
22
4
  const evaluateStep_1 = require("./evaluateStep");
23
5
  async function evaluateScenario(config) {
24
6
  const { scenario, languageModel, testTextSimilarity, assistantConfig } = config;
@@ -1,2 +1,21 @@
1
- import { EvaluateStepParams, StepEvaluationReport } from "./types";
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 { StepEvaluationReport } from "@fonoster/types";
20
+ import { EvaluateStepParams } from "./types";
2
21
  export declare function evaluateStep({ step, languageModel, testTextSimilarity, assistantConfig }: EvaluateStepParams): Promise<StepEvaluationReport>;
@@ -1,24 +1,6 @@
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
- */
22
4
  const evaluateTextResponse_1 = require("./evaluateTextResponse");
23
5
  const evaluateToolCalls_1 = require("./evaluateToolCalls");
24
6
  async function evaluateStep({ step, languageModel, testTextSimilarity, assistantConfig }) {
@@ -16,7 +16,7 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- import { ExpectedTextType } from "./types";
19
+ import { ExpectedTextType } from "@fonoster/types";
20
20
  export declare function evaluateTextResponse(expected: {
21
21
  type: ExpectedTextType;
22
22
  response: string;
@@ -19,7 +19,7 @@ exports.evaluateTextResponse = evaluateTextResponse;
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- const types_1 = require("./types");
22
+ const types_1 = require("@fonoster/types");
23
23
  async function evaluateTextResponse(expected, aiResponse, testTextSimilarity) {
24
24
  if (expected.type === types_1.ExpectedTextType.EXACT) {
25
25
  if (aiResponse !== expected.response) {
@@ -1,4 +1,22 @@
1
- import { ToolEvaluationReport } from "./types";
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 { ToolEvaluationReport } from "@fonoster/types";
2
20
  export declare function evaluateToolCalls(expectedTools: any[], toolCalls: any[] | undefined): {
3
21
  evaluations: ToolEvaluationReport[];
4
22
  passed: boolean;
@@ -4,24 +4,6 @@ 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
- */
25
7
  const moment_1 = __importDefault(require("moment"));
26
8
  function evaluateToolCalls(expectedTools, toolCalls) {
27
9
  const evaluations = [];
@@ -17,5 +17,5 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  export * from "./evalTestCases";
20
- export * from "./printEval";
21
20
  export * from "./types";
21
+ export * from "./createEvaluateIntelligence";
@@ -33,5 +33,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  * limitations under the License.
34
34
  */
35
35
  __exportStar(require("./evalTestCases"), exports);
36
- __exportStar(require("./printEval"), exports);
37
36
  __exportStar(require("./types"), exports);
37
+ __exportStar(require("./createEvaluateIntelligence"), exports);
@@ -18,23 +18,11 @@
18
18
  */
19
19
  import { AssistantConfig } from "../../assistants";
20
20
  import { LanguageModel } from "../types";
21
- declare enum ExpectedTextType {
22
- EXACT = "exact",
23
- SIMILAR = "similar"
24
- }
25
- type ScenarioEvaluationReport = {
26
- scenarioRef: string;
27
- overallPassed: boolean;
28
- steps: StepEvaluationReport[];
29
- };
30
- type StepEvaluationReport = {
31
- humanInput: string;
32
- expectedResponse: string;
33
- aiResponse: string;
34
- evaluationType: ExpectedTextType;
35
- passed: boolean;
36
- errorMessage?: string;
37
- toolEvaluations?: ToolEvaluationReport[];
21
+ type EvaluateIntelligenceRequest = {
22
+ intelligence: {
23
+ productRef: string;
24
+ config: AssistantConfig;
25
+ };
38
26
  };
39
27
  type EvaluateStepParams = {
40
28
  step: any;
@@ -42,18 +30,10 @@ type EvaluateStepParams = {
42
30
  testTextSimilarity: (text1: string, text2: string) => Promise<boolean>;
43
31
  assistantConfig: AssistantConfig;
44
32
  };
45
- type ToolEvaluationReport = {
46
- expectedTool: string;
47
- actualTool: string;
48
- passed: boolean;
49
- expectedParameters?: Record<string, unknown>;
50
- actualParameters?: Record<string, unknown>;
51
- errorMessage?: string;
52
- };
53
- type ScenarioEvaluationConfig = {
33
+ type ScenarioEvaluationRequest = {
54
34
  assistantConfig: AssistantConfig;
55
35
  scenario: any;
56
36
  languageModel: LanguageModel;
57
37
  testTextSimilarity: (text1: string, text2: string) => Promise<boolean>;
58
38
  };
59
- export { ExpectedTextType, ScenarioEvaluationReport, StepEvaluationReport, ToolEvaluationReport, ScenarioEvaluationConfig, EvaluateStepParams };
39
+ export { EvaluateIntelligenceRequest, ScenarioEvaluationRequest, EvaluateStepParams };
@@ -1,8 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExpectedTextType = void 0;
4
- var ExpectedTextType;
5
- (function (ExpectedTextType) {
6
- ExpectedTextType["EXACT"] = "exact";
7
- ExpectedTextType["SIMILAR"] = "similar";
8
- })(ExpectedTextType || (exports.ExpectedTextType = ExpectedTextType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/autopilot",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
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",
@@ -34,11 +34,11 @@
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-s3": "^3.712.0",
36
36
  "@dmitryrechkin/json-schema-to-zod": "^1.0.1",
37
- "@fonoster/common": "^0.13.4",
38
- "@fonoster/logger": "^0.13.4",
39
- "@fonoster/sdk": "^0.13.4",
40
- "@fonoster/types": "^0.13.4",
41
- "@fonoster/voice": "^0.13.4",
37
+ "@fonoster/common": "^0.13.5",
38
+ "@fonoster/logger": "^0.13.5",
39
+ "@fonoster/sdk": "^0.13.5",
40
+ "@fonoster/types": "^0.13.5",
41
+ "@fonoster/voice": "^0.13.5",
42
42
  "@langchain/anthropic": "^0.3.15",
43
43
  "@langchain/community": "^0.3.32",
44
44
  "@langchain/core": "^0.3.40",
@@ -46,9 +46,7 @@
46
46
  "@langchain/groq": "^0.1.3",
47
47
  "@langchain/ollama": "^0.1.6",
48
48
  "@langchain/openai": "^0.4.4",
49
- "ansis": "^3.17.0",
50
49
  "cheerio": "^1.0.0",
51
- "cli-table3": "^0.6.5",
52
50
  "dotenv": "^16.4.5",
53
51
  "js-yaml": "^4.1.0",
54
52
  "langchain": "^0.3.6",
@@ -59,5 +57,5 @@
59
57
  "xstate": "^5.17.3",
60
58
  "zod": "^3.23.8"
61
59
  },
62
- "gitHead": "78653d90bfd64bb1fe2f5279dfb832894642f17f"
60
+ "gitHead": "a502dc44c7b180a4424eea51952e41194e4ffaf4"
63
61
  }
@@ -1,2 +0,0 @@
1
- import { ScenarioEvaluationReport } from "./types";
2
- export declare function printEval(results: ScenarioEvaluationReport[]): void;
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.printEval = printEval;
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
- */
25
- const ansis_1 = __importDefault(require("ansis"));
26
- const cli_table3_1 = __importDefault(require("cli-table3"));
27
- function printEval(results) {
28
- results.forEach((result) => {
29
- console.log(ansis_1.default.bold.blue(`\nScenario: ${result.scenarioRef}`));
30
- console.log(ansis_1.default.bold(`Overall Passed: ${result.overallPassed ? ansis_1.default.green("✔") : ansis_1.default.red("✘")}`));
31
- const table = new cli_table3_1.default({
32
- head: [
33
- "Step",
34
- "Human Input",
35
- "Expected",
36
- "AI Response",
37
- "Tool Calls",
38
- "Passed"
39
- ],
40
- colWidths: [
41
- 6, // Step
42
- 28, // Human Input
43
- 28, // Expected
44
- 28, // AI Response
45
- null, // Tool Calls - dynamic width
46
- 8 // Passed
47
- ],
48
- wordWrap: true
49
- });
50
- result.steps.forEach((step, index) => {
51
- // Format tool evaluations if they exist
52
- let toolEvalText = "";
53
- if (step.toolEvaluations && step.toolEvaluations.length > 0) {
54
- toolEvalText = step.toolEvaluations
55
- .map((toolEval) => {
56
- if (!Object.keys(toolEval.actualParameters || {}).length) {
57
- return `${toolEval.actualTool}()`;
58
- }
59
- const params = JSON.stringify(toolEval.actualParameters || {}, null, 1)
60
- .split("\n")
61
- .map((line, index, arr) => {
62
- if (index === 0)
63
- return "";
64
- if (index === arr.length - 1)
65
- return "";
66
- return " " + line.trim();
67
- })
68
- .join("\n");
69
- return `${toolEval.actualTool}({${params}})`;
70
- })
71
- .join("\n\n"); // Add extra line between multiple tool calls
72
- }
73
- table.push([
74
- index + 1,
75
- step.humanInput,
76
- step.expectedResponse,
77
- step.aiResponse,
78
- toolEvalText,
79
- step.passed ? ansis_1.default.green("✔") : ansis_1.default.red("✘")
80
- ]);
81
- // Print error message if step failed
82
- if (!step.passed && step.errorMessage) {
83
- console.log(ansis_1.default.red(`\nError in step ${index + 1}:`));
84
- console.log(ansis_1.default.red(step.errorMessage));
85
- }
86
- // Print tool evaluation errors if any
87
- if (step.toolEvaluations) {
88
- step.toolEvaluations.forEach((toolEval) => {
89
- if (!toolEval.passed && toolEval.errorMessage) {
90
- console.log(ansis_1.default.red(`\nTool Error in step ${index + 1}:`));
91
- console.log(ansis_1.default.red(toolEval.errorMessage));
92
- }
93
- });
94
- }
95
- });
96
- console.log(table.toString());
97
- });
98
- }