@agentica/benchmark 0.8.3 → 0.9.0-dev.20250302

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 (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +326 -324
  3. package/lib/AgenticaCallBenchmark.d.ts +7 -6
  4. package/lib/AgenticaCallBenchmark.js.map +1 -1
  5. package/lib/AgenticaSelectBenchmark.d.ts +7 -6
  6. package/lib/AgenticaSelectBenchmark.js.map +1 -1
  7. package/lib/index.mjs +46 -1
  8. package/lib/index.mjs.map +1 -1
  9. package/lib/internal/AgenticaBenchmarkPredicator.d.ts +5 -4
  10. package/lib/internal/AgenticaBenchmarkPredicator.js +74 -2
  11. package/lib/internal/AgenticaBenchmarkPredicator.js.map +1 -1
  12. package/lib/internal/AgenticaBenchmarkUtil.d.ts +2 -1
  13. package/lib/internal/AgenticaBenchmarkUtil.js.map +1 -1
  14. package/lib/internal/AgenticaCallBenchmarkReporter.d.ts +2 -1
  15. package/lib/internal/AgenticaCallBenchmarkReporter.js.map +1 -1
  16. package/lib/internal/AgenticaPromptReporter.d.ts +2 -1
  17. package/lib/internal/AgenticaPromptReporter.js.map +1 -1
  18. package/lib/internal/AgenticaSelectBenchmarkReporter.js.map +1 -1
  19. package/lib/structures/IAgenticaBenchmarkExpected.d.ts +10 -9
  20. package/lib/structures/IAgenticaCallBenchmarkEvent.d.ts +8 -7
  21. package/lib/structures/IAgenticaCallBenchmarkResult.d.ts +6 -5
  22. package/lib/structures/IAgenticaCallBenchmarkScenario.d.ts +3 -2
  23. package/lib/structures/IAgenticaSelectBenchmarkEvent.d.ts +9 -8
  24. package/lib/structures/IAgenticaSelectBenchmarkResult.d.ts +6 -5
  25. package/lib/structures/IAgenticaSelectBenchmarkScenario.d.ts +3 -2
  26. package/package.json +5 -5
  27. package/src/AgenticaCallBenchmark.ts +268 -265
  28. package/src/AgenticaSelectBenchmark.ts +256 -254
  29. package/src/index.ts +3 -3
  30. package/src/internal/AgenticaBenchmarkPredicator.ts +224 -216
  31. package/src/internal/AgenticaBenchmarkUtil.ts +44 -40
  32. package/src/internal/AgenticaCallBenchmarkReporter.ts +183 -180
  33. package/src/internal/AgenticaPromptReporter.ts +46 -43
  34. package/src/internal/AgenticaSelectBenchmarkReporter.ts +213 -210
  35. package/src/structures/IAgenticaBenchmarkExpected.ts +68 -58
  36. package/src/structures/IAgenticaCallBenchmarkEvent.ts +113 -109
  37. package/src/structures/IAgenticaCallBenchmarkResult.ts +70 -69
  38. package/src/structures/IAgenticaCallBenchmarkScenario.ts +43 -39
  39. package/src/structures/IAgenticaSelectBenchmarkEvent.ts +114 -110
  40. package/src/structures/IAgenticaSelectBenchmarkResult.ts +72 -69
  41. package/src/structures/IAgenticaSelectBenchmarkScenario.ts +43 -39
  42. package/src/utils/MathUtil.ts +3 -3
@@ -1,110 +1,114 @@
1
- import {
2
- IAgenticaOperationSelection,
3
- IAgenticaPrompt,
4
- IAgenticaTokenUsage,
5
- } from "@agentica/core";
6
-
7
- import { IAgenticaSelectBenchmarkScenario } from "./IAgenticaSelectBenchmarkScenario";
8
-
9
- /**
10
- * Event of LLM function selection benchmark.
11
- *
12
- * `IAgenticaSelectBenchmarkEvent` is an union type of the events occurred
13
- * during the LLM function selection benchmark, representing one phase of
14
- * the benchmark testing about a scenario.
15
- *
16
- * In other words, when {@link AgenticaSelectBenchmark} executes the
17
- * benchmark, it will run the benchmark will test a scenario repeately with
18
- * the given configuration {@link AgenticaSelectBenchmark.IConfig.repeat}.
19
- * And in the repeated benchmark about a scenario,
20
- * `IAgenticaSelectBenchmarkEvent` is one of the repeated testing.
21
- *
22
- * For reference, `IAgenticaSelectBenchmarkEvent` is categorized into three
23
- * types: `success`, `failure`, and `error`. The `success` means the
24
- * benchmark testing is fully meet the expected scenario, and `failure`
25
- * means that the `selector` had not selected the expected operations. The
26
- * last type, `error`, means that an error had been occurred during the
27
- * benchmark testing.
28
- *
29
- * @author Samchon
30
- */
31
- export type IAgenticaSelectBenchmarkEvent =
32
- | IAgenticaSelectBenchmarkEvent.ISuccess
33
- | IAgenticaSelectBenchmarkEvent.IFailure
34
- | IAgenticaSelectBenchmarkEvent.IError;
35
- export namespace IAgenticaSelectBenchmarkEvent {
36
- /**
37
- * Success event type.
38
- *
39
- * The `success` event type represents that the benchmark testing is
40
- * fully meet the expected scenario.
41
- */
42
- export interface ISuccess extends IEventBase<"success"> {
43
- /**
44
- * Usage of the token during the benchmark.
45
- */
46
- usage: IAgenticaTokenUsage;
47
-
48
- /**
49
- * Selected operations in the benchmark.
50
- */
51
- selected: IAgenticaOperationSelection[];
52
-
53
- /**
54
- * Prompt messages from the assistant.
55
- */
56
- assistantPrompts: IAgenticaPrompt.IText<"assistant">[];
57
- }
58
-
59
- /**
60
- * Failure event type.
61
- *
62
- * The `failure` event type represents that the `selector` had not
63
- * selected the expected scenario in the benchmark testing.
64
- */
65
- export interface IFailure extends IEventBase<"failure"> {
66
- /**
67
- * Usage of the token during the benchmark.
68
- */
69
- usage: IAgenticaTokenUsage;
70
-
71
- /**
72
- * Selected operations in the benchmark.
73
- */
74
- selected: IAgenticaOperationSelection[];
75
-
76
- /**
77
- * Prompt messages from the assistant.
78
- */
79
- assistantPrompts: IAgenticaPrompt.IText<"assistant">[];
80
- }
81
-
82
- export interface IError extends IEventBase<"error"> {
83
- /**
84
- * Error occurred during the benchmark.
85
- */
86
- error: unknown;
87
- }
88
-
89
- interface IEventBase<Type extends string> {
90
- /**
91
- * Discriminant type.
92
- */
93
- type: Type;
94
-
95
- /**
96
- * Expected scenario.
97
- */
98
- scenario: IAgenticaSelectBenchmarkScenario;
99
-
100
- /**
101
- * When the benchmark testing started.
102
- */
103
- started_at: Date;
104
-
105
- /**
106
- * When the benchmark testing completed.
107
- */
108
- completed_at: Date;
109
- }
110
- }
1
+ import {
2
+ IAgenticaOperationSelection,
3
+ IAgenticaPrompt,
4
+ IAgenticaTokenUsage,
5
+ } from "@agentica/core";
6
+ import { ILlmSchema } from "@samchon/openapi";
7
+
8
+ import { IAgenticaSelectBenchmarkScenario } from "./IAgenticaSelectBenchmarkScenario";
9
+
10
+ /**
11
+ * Event of LLM function selection benchmark.
12
+ *
13
+ * `IAgenticaSelectBenchmarkEvent` is an union type of the events occurred
14
+ * during the LLM function selection benchmark, representing one phase of
15
+ * the benchmark testing about a scenario.
16
+ *
17
+ * In other words, when {@link AgenticaSelectBenchmark} executes the
18
+ * benchmark, it will run the benchmark will test a scenario repeately with
19
+ * the given configuration {@link AgenticaSelectBenchmark.IConfig.repeat}.
20
+ * And in the repeated benchmark about a scenario,
21
+ * `IAgenticaSelectBenchmarkEvent` is one of the repeated testing.
22
+ *
23
+ * For reference, `IAgenticaSelectBenchmarkEvent` is categorized into three
24
+ * types: `success`, `failure`, and `error`. The `success` means the
25
+ * benchmark testing is fully meet the expected scenario, and `failure`
26
+ * means that the `selector` had not selected the expected operations. The
27
+ * last type, `error`, means that an error had been occurred during the
28
+ * benchmark testing.
29
+ *
30
+ * @author Samchon
31
+ */
32
+ export type IAgenticaSelectBenchmarkEvent<Model extends ILlmSchema.Model> =
33
+ | IAgenticaSelectBenchmarkEvent.ISuccess<Model>
34
+ | IAgenticaSelectBenchmarkEvent.IFailure<Model>
35
+ | IAgenticaSelectBenchmarkEvent.IError<Model>;
36
+ export namespace IAgenticaSelectBenchmarkEvent {
37
+ /**
38
+ * Success event type.
39
+ *
40
+ * The `success` event type represents that the benchmark testing is
41
+ * fully meet the expected scenario.
42
+ */
43
+ export interface ISuccess<Model extends ILlmSchema.Model>
44
+ extends IEventBase<"success", Model> {
45
+ /**
46
+ * Usage of the token during the benchmark.
47
+ */
48
+ usage: IAgenticaTokenUsage;
49
+
50
+ /**
51
+ * Selected operations in the benchmark.
52
+ */
53
+ selected: IAgenticaOperationSelection<Model>[];
54
+
55
+ /**
56
+ * Prompt messages from the assistant.
57
+ */
58
+ assistantPrompts: IAgenticaPrompt.IText<"assistant">[];
59
+ }
60
+
61
+ /**
62
+ * Failure event type.
63
+ *
64
+ * The `failure` event type represents that the `selector` had not
65
+ * selected the expected scenario in the benchmark testing.
66
+ */
67
+ export interface IFailure<Model extends ILlmSchema.Model>
68
+ extends IEventBase<"failure", Model> {
69
+ /**
70
+ * Usage of the token during the benchmark.
71
+ */
72
+ usage: IAgenticaTokenUsage;
73
+
74
+ /**
75
+ * Selected operations in the benchmark.
76
+ */
77
+ selected: IAgenticaOperationSelection<Model>[];
78
+
79
+ /**
80
+ * Prompt messages from the assistant.
81
+ */
82
+ assistantPrompts: IAgenticaPrompt.IText<"assistant">[];
83
+ }
84
+
85
+ export interface IError<Model extends ILlmSchema.Model>
86
+ extends IEventBase<"error", Model> {
87
+ /**
88
+ * Error occurred during the benchmark.
89
+ */
90
+ error: unknown;
91
+ }
92
+
93
+ interface IEventBase<Type extends string, Model extends ILlmSchema.Model> {
94
+ /**
95
+ * Discriminant type.
96
+ */
97
+ type: Type;
98
+
99
+ /**
100
+ * Expected scenario.
101
+ */
102
+ scenario: IAgenticaSelectBenchmarkScenario<Model>;
103
+
104
+ /**
105
+ * When the benchmark testing started.
106
+ */
107
+ started_at: Date;
108
+
109
+ /**
110
+ * When the benchmark testing completed.
111
+ */
112
+ completed_at: Date;
113
+ }
114
+ }
@@ -1,69 +1,72 @@
1
- import { IAgenticaTokenUsage } from "@agentica/core";
2
-
3
- import { IAgenticaSelectBenchmarkEvent } from "./IAgenticaSelectBenchmarkEvent";
4
- import { IAgenticaSelectBenchmarkScenario } from "./IAgenticaSelectBenchmarkScenario";
5
-
6
- /**
7
- * Result of the LLM function selection benchmark.
8
- *
9
- * `IAgenticaSelectBenchmarkResult` is a structure representing the result
10
- * of the LLM function selection benchmark executed by the
11
- * {@link AgenticaSelectBenchmark.execute execute} function.
12
- *
13
- * It contains every experiment results for each scenario, and aggregated
14
- * LLM token cost in the benchmark process.
15
- *
16
- * In each scenario, as the benchmark program experiments multiple times
17
- * about a scenario, it will contain multiple events. Also, because of the
18
- * characteristics of the LLM which is not predictable, the result can be
19
- * different in each event.
20
- *
21
- * @author Samchon
22
- */
23
- export interface IAgenticaSelectBenchmarkResult {
24
- /**
25
- * Experiments for each scenario.
26
- */
27
- experiments: IAgenticaSelectBenchmarkResult.IExperiment[];
28
-
29
- /**
30
- * Aggregated token usage information.
31
- */
32
- usage: IAgenticaTokenUsage;
33
-
34
- /**
35
- * Start time of the benchmark.
36
- */
37
- started_at: Date;
38
-
39
- /**
40
- * End time of the benchmark.
41
- */
42
- completed_at: Date;
43
- }
44
- export namespace IAgenticaSelectBenchmarkResult {
45
- /**
46
- * Experiment result about a scenario.
47
- */
48
- export interface IExperiment {
49
- /**
50
- * Expected scenario.
51
- */
52
- scenario: IAgenticaSelectBenchmarkScenario;
53
-
54
- /**
55
- * Events occurred during the benchmark in the scenario.
56
- *
57
- * When benchmarking a scenario, {@link AgenticaSelectBenchmark} will
58
- * test a scenario multiple times with the given
59
- * {@link AgenticaSelectBenchmark.IConfig.repeat repeat} count.
60
- * And the event is one of the repeated benchmark results.
61
- */
62
- events: IAgenticaSelectBenchmarkEvent[];
63
-
64
- /**
65
- * LLM token usage information.
66
- */
67
- usage: IAgenticaTokenUsage;
68
- }
69
- }
1
+ import { IAgenticaTokenUsage } from "@agentica/core";
2
+ import { ILlmSchema } from "@samchon/openapi";
3
+
4
+ import { IAgenticaSelectBenchmarkEvent } from "./IAgenticaSelectBenchmarkEvent";
5
+ import { IAgenticaSelectBenchmarkScenario } from "./IAgenticaSelectBenchmarkScenario";
6
+
7
+ /**
8
+ * Result of the LLM function selection benchmark.
9
+ *
10
+ * `IAgenticaSelectBenchmarkResult` is a structure representing the result
11
+ * of the LLM function selection benchmark executed by the
12
+ * {@link AgenticaSelectBenchmark.execute execute} function.
13
+ *
14
+ * It contains every experiment results for each scenario, and aggregated
15
+ * LLM token cost in the benchmark process.
16
+ *
17
+ * In each scenario, as the benchmark program experiments multiple times
18
+ * about a scenario, it will contain multiple events. Also, because of the
19
+ * characteristics of the LLM which is not predictable, the result can be
20
+ * different in each event.
21
+ *
22
+ * @author Samchon
23
+ */
24
+ export interface IAgenticaSelectBenchmarkResult<
25
+ Model extends ILlmSchema.Model,
26
+ > {
27
+ /**
28
+ * Experiments for each scenario.
29
+ */
30
+ experiments: IAgenticaSelectBenchmarkResult.IExperiment<Model>[];
31
+
32
+ /**
33
+ * Aggregated token usage information.
34
+ */
35
+ usage: IAgenticaTokenUsage;
36
+
37
+ /**
38
+ * Start time of the benchmark.
39
+ */
40
+ started_at: Date;
41
+
42
+ /**
43
+ * End time of the benchmark.
44
+ */
45
+ completed_at: Date;
46
+ }
47
+ export namespace IAgenticaSelectBenchmarkResult {
48
+ /**
49
+ * Experiment result about a scenario.
50
+ */
51
+ export interface IExperiment<Model extends ILlmSchema.Model> {
52
+ /**
53
+ * Expected scenario.
54
+ */
55
+ scenario: IAgenticaSelectBenchmarkScenario<Model>;
56
+
57
+ /**
58
+ * Events occurred during the benchmark in the scenario.
59
+ *
60
+ * When benchmarking a scenario, {@link AgenticaSelectBenchmark} will
61
+ * test a scenario multiple times with the given
62
+ * {@link AgenticaSelectBenchmark.IConfig.repeat repeat} count.
63
+ * And the event is one of the repeated benchmark results.
64
+ */
65
+ events: IAgenticaSelectBenchmarkEvent<Model>[];
66
+
67
+ /**
68
+ * LLM token usage information.
69
+ */
70
+ usage: IAgenticaTokenUsage;
71
+ }
72
+ }
@@ -1,39 +1,43 @@
1
- import { IAgenticaBenchmarkExpected } from "./IAgenticaBenchmarkExpected";
2
-
3
- /**
4
- * Scenario of function selection.
5
- *
6
- * `IAgenticaSelectBenchmarkScenario` is a data structure which
7
- * represents a function selection benchmark scenario. It contains two
8
- * properties; {@linkk text} and {@link operations}.
9
- *
10
- * The {@link text} means the conversation text from the user, and
11
- * the other {@link operations} are the expected operations that
12
- * should be selected by the `selector` agent through the {@link text}
13
- * conversation.
14
- *
15
- * @author Samchon
16
- */
17
- export interface IAgenticaSelectBenchmarkScenario {
18
- /**
19
- * Name of the scenario.
20
- *
21
- * It must be unique within the benchmark scenarios.
22
- */
23
- name: string;
24
-
25
- /**
26
- * The prompt text from user.
27
- */
28
- text: string;
29
-
30
- /**
31
- * Expected function selection sequence.
32
- *
33
- * Sequence of operations (API operation or class function) that
34
- * should be selected by the `selector` agent from the user's
35
- * {@link text} conversation for the LLM (Large Language Model)
36
- * function selection.
37
- */
38
- expected: IAgenticaBenchmarkExpected;
39
- }
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { IAgenticaBenchmarkExpected } from "./IAgenticaBenchmarkExpected";
4
+
5
+ /**
6
+ * Scenario of function selection.
7
+ *
8
+ * `IAgenticaSelectBenchmarkScenario` is a data structure which
9
+ * represents a function selection benchmark scenario. It contains two
10
+ * properties; {@linkk text} and {@link operations}.
11
+ *
12
+ * The {@link text} means the conversation text from the user, and
13
+ * the other {@link operations} are the expected operations that
14
+ * should be selected by the `selector` agent through the {@link text}
15
+ * conversation.
16
+ *
17
+ * @author Samchon
18
+ */
19
+ export interface IAgenticaSelectBenchmarkScenario<
20
+ Model extends ILlmSchema.Model,
21
+ > {
22
+ /**
23
+ * Name of the scenario.
24
+ *
25
+ * It must be unique within the benchmark scenarios.
26
+ */
27
+ name: string;
28
+
29
+ /**
30
+ * The prompt text from user.
31
+ */
32
+ text: string;
33
+
34
+ /**
35
+ * Expected function selection sequence.
36
+ *
37
+ * Sequence of operations (API operation or class function) that
38
+ * should be selected by the `selector` agent from the user's
39
+ * {@link text} conversation for the LLM (Large Language Model)
40
+ * function selection.
41
+ */
42
+ expected: IAgenticaBenchmarkExpected<Model>;
43
+ }
@@ -1,3 +1,3 @@
1
- export namespace MathUtil {
2
- export const round = (value: number): number => Math.floor(value * 100) / 100;
3
- }
1
+ export namespace MathUtil {
2
+ export const round = (value: number): number => Math.floor(value * 100) / 100;
3
+ }