@agentica/core 0.15.7 → 0.16.1
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.
- package/lib/Agentica.d.ts +21 -21
- package/lib/Agentica.js +29 -29
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.d.ts +115 -0
- package/lib/MicroAgentica.js +279 -0
- package/lib/MicroAgentica.js.map +1 -0
- package/lib/constants/AgenticaDefaultPrompt.d.ts +2 -1
- package/lib/constants/AgenticaDefaultPrompt.js +4 -4
- package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
- package/lib/context/AgenticaCancelPrompt.d.ts +3 -3
- package/lib/context/AgenticaContext.d.ts +12 -12
- package/lib/context/AgenticaOperationCollection.d.ts +1 -1
- package/lib/context/MicroAgenticaContext.d.ts +75 -0
- package/lib/{prompts/AgenticaCancelPrompt.js → context/MicroAgenticaContext.js} +1 -1
- package/lib/context/MicroAgenticaContext.js.map +1 -0
- package/lib/context/internal/AgenticaOperationComposer.d.ts +2 -1
- package/lib/context/internal/AgenticaOperationComposer.js +3 -2
- package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/context/internal/isAgenticaContext.d.ts +1 -0
- package/lib/context/internal/isAgenticaContext.js +10 -0
- package/lib/context/internal/isAgenticaContext.js.map +1 -0
- package/lib/events/AgenticaDescribeEvent.d.ts +4 -4
- package/lib/events/AgenticaEvent.d.ts +1 -0
- package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
- package/lib/events/AgenticaSelectEvent.d.ts +2 -2
- package/lib/events/AgenticaTextEvent.d.ts +2 -2
- package/lib/events/MicroAgenticaEvent.d.ts +32 -0
- package/lib/{prompts/AgenticaTextPrompt.js → events/MicroAgenticaEvent.js} +1 -1
- package/lib/events/MicroAgenticaEvent.js.map +1 -0
- package/lib/factory/events.d.ts +2 -2
- package/lib/factory/events.js +5 -5
- package/lib/factory/events.js.map +1 -1
- package/lib/factory/histories.d.ts +33 -0
- package/lib/factory/{prompts.js → histories.js} +13 -13
- package/lib/factory/histories.js.map +1 -0
- package/lib/factory/index.d.ts +1 -1
- package/lib/factory/index.js +1 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/functional/assertHttpLlmApplication.js +577 -387
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateHttpLlmApplication.js +500 -348
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/histories/AgenticaCancelHistory.d.ts +8 -0
- package/lib/{prompts/AgenticaExecutePrompt.js → histories/AgenticaCancelHistory.js} +1 -1
- package/lib/histories/AgenticaCancelHistory.js.map +1 -0
- package/lib/histories/AgenticaDescribeHistory.d.ts +16 -0
- package/lib/histories/AgenticaDescribeHistory.js +3 -0
- package/lib/histories/AgenticaDescribeHistory.js.map +1 -0
- package/lib/{prompts/AgenticaExecutePrompt.d.ts → histories/AgenticaExecuteHistory.d.ts} +5 -5
- package/lib/{prompts/AgenticaDescribePrompt.js → histories/AgenticaExecuteHistory.js} +1 -1
- package/lib/histories/AgenticaExecuteHistory.js.map +1 -0
- package/lib/histories/AgenticaHistory.d.ts +17 -0
- package/lib/{prompts/AgenticaPrompt.js → histories/AgenticaHistory.js} +1 -1
- package/lib/histories/AgenticaHistory.js.map +1 -0
- package/lib/{prompts/AgenticaPromptBase.d.ts → histories/AgenticaHistoryBase.d.ts} +4 -4
- package/lib/{json/IAgenticaPromptJson.js → histories/AgenticaHistoryBase.js} +1 -1
- package/lib/histories/AgenticaHistoryBase.js.map +1 -0
- package/lib/histories/AgenticaSelectHistory.d.ts +8 -0
- package/lib/histories/AgenticaSelectHistory.js +3 -0
- package/lib/histories/AgenticaSelectHistory.js.map +1 -0
- package/lib/histories/AgenticaTextHistory.d.ts +6 -0
- package/lib/{prompts/AgenticaPromptBase.js → histories/AgenticaTextHistory.js} +1 -1
- package/lib/histories/AgenticaTextHistory.js.map +1 -0
- package/lib/histories/MicroAgenticaHistory.d.ts +13 -0
- package/lib/histories/MicroAgenticaHistory.js +3 -0
- package/lib/histories/MicroAgenticaHistory.js.map +1 -0
- package/lib/index.d.ts +12 -7
- package/lib/index.js +12 -7
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1408 -917
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +6 -5
- package/lib/json/{IAgenticaPromptJson.d.ts → IAgenticaHistoryJson.d.ts} +8 -8
- package/lib/json/IAgenticaHistoryJson.js +3 -0
- package/lib/json/IAgenticaHistoryJson.js.map +1 -0
- package/lib/json/IAgenticaOperationSelectionJson.d.ts +7 -1
- package/lib/json/IMicroAgenticaEventJson.d.ts +13 -0
- package/lib/json/IMicroAgenticaEventJson.js +3 -0
- package/lib/json/IMicroAgenticaEventJson.js.map +1 -0
- package/lib/json/IMicroAgenticaHistoryJson.d.ts +19 -0
- package/lib/json/IMicroAgenticaHistoryJson.js +3 -0
- package/lib/json/IMicroAgenticaHistoryJson.js.map +1 -0
- package/lib/orchestrate/call.d.ts +4 -2
- package/lib/orchestrate/call.js +58 -49
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +4 -4
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/describe.d.ts +4 -3
- package/lib/orchestrate/describe.js +5 -5
- package/lib/orchestrate/describe.js.map +1 -1
- package/lib/orchestrate/execute.d.ts +2 -2
- package/lib/orchestrate/execute.js +1 -1
- package/lib/orchestrate/execute.js.map +1 -1
- package/lib/orchestrate/initialize.d.ts +2 -2
- package/lib/orchestrate/initialize.js +5 -5
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/internal/selectFunction.d.ts +1 -5
- package/lib/orchestrate/internal/selectFunction.js +5 -2
- package/lib/orchestrate/internal/selectFunction.js.map +1 -1
- package/lib/orchestrate/select.d.ts +2 -2
- package/lib/orchestrate/select.js +5 -5
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +6 -5
- package/lib/structures/IAgenticaController.d.ts +1 -1
- package/lib/structures/IAgenticaExecutor.d.ts +11 -9
- package/lib/structures/IAgenticaProps.d.ts +3 -3
- package/lib/structures/IAgenticaSystemPrompt.d.ts +13 -13
- package/lib/structures/IAgenticaVendor.d.ts +1 -1
- package/lib/structures/IMicroAgenticaConfig.d.ts +74 -0
- package/lib/structures/IMicroAgenticaConfig.js +3 -0
- package/lib/structures/IMicroAgenticaConfig.js.map +1 -0
- package/lib/structures/IMicroAgenticaExecutor.d.ts +57 -0
- package/lib/structures/IMicroAgenticaExecutor.js +3 -0
- package/lib/structures/IMicroAgenticaExecutor.js.map +1 -0
- package/lib/structures/IMicroAgenticaProps.d.ts +63 -0
- package/lib/structures/IMicroAgenticaProps.js +3 -0
- package/lib/structures/IMicroAgenticaProps.js.map +1 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +66 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.js +3 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.js.map +1 -0
- package/lib/transformers/AgenticaPromptTransformer.d.ts +19 -19
- package/lib/transformers/AgenticaPromptTransformer.js +27 -27
- package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
- package/package.json +7 -7
- package/src/Agentica.ts +36 -36
- package/src/MicroAgentica.ts +337 -0
- package/src/constants/AgenticaDefaultPrompt.ts +4 -2
- package/src/context/AgenticaCancelPrompt.ts +3 -3
- package/src/context/AgenticaContext.ts +12 -12
- package/src/context/AgenticaOperationCollection.ts +1 -1
- package/src/context/MicroAgenticaContext.ts +95 -0
- package/src/context/internal/AgenticaOperationComposer.ts +6 -3
- package/src/context/internal/isAgenticaContext.ts +13 -0
- package/src/events/AgenticaDescribeEvent.ts +4 -4
- package/src/events/AgenticaEvent.ts +6 -0
- package/src/events/AgenticaExecuteEvent.ts +5 -5
- package/src/events/AgenticaSelectEvent.ts +2 -2
- package/src/events/AgenticaTextEvent.ts +2 -2
- package/src/events/MicroAgenticaEvent.ts +41 -0
- package/src/factory/events.ts +8 -8
- package/src/factory/{prompts.ts → histories.ts} +18 -18
- package/src/factory/index.ts +1 -1
- package/src/histories/AgenticaCancelHistory.ts +13 -0
- package/src/histories/AgenticaDescribeHistory.ts +22 -0
- package/src/{prompts/AgenticaExecutePrompt.ts → histories/AgenticaExecuteHistory.ts} +7 -7
- package/src/histories/AgenticaHistory.ts +25 -0
- package/src/{prompts/AgenticaPromptBase.ts → histories/AgenticaHistoryBase.ts} +4 -4
- package/src/histories/AgenticaSelectHistory.ts +13 -0
- package/src/histories/AgenticaTextHistory.ts +10 -0
- package/src/histories/MicroAgenticaHistory.ts +18 -0
- package/src/index.ts +18 -15
- package/src/json/IAgenticaEventJson.ts +6 -5
- package/src/json/{IAgenticaPromptJson.ts → IAgenticaHistoryJson.ts} +13 -13
- package/src/json/IAgenticaOperationSelectionJson.ts +8 -1
- package/src/json/IMicroAgenticaEventJson.ts +21 -0
- package/src/json/IMicroAgenticaHistoryJson.ts +23 -0
- package/src/orchestrate/call.ts +91 -67
- package/src/orchestrate/cancel.ts +4 -4
- package/src/orchestrate/describe.ts +13 -9
- package/src/orchestrate/execute.ts +7 -7
- package/src/orchestrate/initialize.ts +8 -8
- package/src/orchestrate/internal/selectFunction.ts +5 -2
- package/src/orchestrate/select.ts +13 -13
- package/src/structures/IAgenticaConfig.ts +6 -5
- package/src/structures/IAgenticaController.ts +1 -1
- package/src/structures/IAgenticaExecutor.ts +12 -10
- package/src/structures/IAgenticaProps.ts +3 -3
- package/src/structures/IAgenticaSystemPrompt.ts +13 -13
- package/src/structures/IAgenticaVendor.ts +1 -1
- package/src/structures/IMicroAgenticaConfig.ts +82 -0
- package/src/structures/IMicroAgenticaExecutor.ts +63 -0
- package/src/structures/IMicroAgenticaProps.ts +70 -0
- package/src/structures/IMicroAgenticaSystemPrompt.ts +71 -0
- package/src/transformers/AgenticaPromptTransformer.ts +46 -46
- package/lib/factory/prompts.d.ts +0 -33
- package/lib/factory/prompts.js.map +0 -1
- package/lib/json/IAgenticaPromptJson.js.map +0 -1
- package/lib/prompts/AgenticaCancelPrompt.d.ts +0 -8
- package/lib/prompts/AgenticaCancelPrompt.js.map +0 -1
- package/lib/prompts/AgenticaDescribePrompt.d.ts +0 -16
- package/lib/prompts/AgenticaDescribePrompt.js.map +0 -1
- package/lib/prompts/AgenticaExecutePrompt.js.map +0 -1
- package/lib/prompts/AgenticaPrompt.d.ts +0 -17
- package/lib/prompts/AgenticaPrompt.js.map +0 -1
- package/lib/prompts/AgenticaPromptBase.js.map +0 -1
- package/lib/prompts/AgenticaSelectPrompt.d.ts +0 -8
- package/lib/prompts/AgenticaSelectPrompt.js +0 -3
- package/lib/prompts/AgenticaSelectPrompt.js.map +0 -1
- package/lib/prompts/AgenticaTextPrompt.d.ts +0 -6
- package/lib/prompts/AgenticaTextPrompt.js.map +0 -1
- package/src/prompts/AgenticaCancelPrompt.ts +0 -13
- package/src/prompts/AgenticaDescribePrompt.ts +0 -22
- package/src/prompts/AgenticaPrompt.ts +0 -25
- package/src/prompts/AgenticaSelectPrompt.ts +0 -13
- package/src/prompts/AgenticaTextPrompt.ts +0 -10
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import type { AgenticaOperation } from "../context/AgenticaOperation";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
3
|
+
import type { AgenticaCancelHistory } from "../histories/AgenticaCancelHistory";
|
|
4
|
+
import type { AgenticaDescribeHistory } from "../histories/AgenticaDescribeHistory";
|
|
5
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
6
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
7
|
+
import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
|
|
8
|
+
import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
|
|
9
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
10
10
|
declare function transform<Model extends ILlmSchema.Model>(props: {
|
|
11
11
|
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
12
|
-
|
|
13
|
-
}):
|
|
12
|
+
history: IAgenticaHistoryJson;
|
|
13
|
+
}): AgenticaHistory<Model>;
|
|
14
14
|
declare function transformText(props: {
|
|
15
|
-
|
|
16
|
-
}):
|
|
15
|
+
history: IAgenticaHistoryJson.IText;
|
|
16
|
+
}): AgenticaTextHistory;
|
|
17
17
|
declare function transformSelect<Model extends ILlmSchema.Model>(props: {
|
|
18
18
|
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
19
|
-
|
|
20
|
-
}):
|
|
19
|
+
history: IAgenticaHistoryJson.ISelect;
|
|
20
|
+
}): AgenticaSelectHistory<Model>;
|
|
21
21
|
declare function transformCancel<Model extends ILlmSchema.Model>(props: {
|
|
22
22
|
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
23
|
-
|
|
24
|
-
}):
|
|
23
|
+
history: IAgenticaHistoryJson.ICancel;
|
|
24
|
+
}): AgenticaCancelHistory<Model>;
|
|
25
25
|
declare function transformExecute<Model extends ILlmSchema.Model>(props: {
|
|
26
26
|
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
27
|
-
|
|
28
|
-
}):
|
|
27
|
+
history: IAgenticaHistoryJson.IExecute;
|
|
28
|
+
}): AgenticaExecuteHistory<Model>;
|
|
29
29
|
declare function transformDescribe<Model extends ILlmSchema.Model>(props: {
|
|
30
30
|
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
31
|
-
|
|
32
|
-
}):
|
|
31
|
+
history: IAgenticaHistoryJson.IDescribe;
|
|
32
|
+
}): AgenticaDescribeHistory<Model>;
|
|
33
33
|
export declare const AgenticaPromptTransformer: {
|
|
34
34
|
transform: typeof transform;
|
|
35
35
|
transformText: typeof transformText;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AgenticaPromptTransformer = void 0;
|
|
4
|
+
const histories_1 = require("../factory/histories");
|
|
4
5
|
const operations_1 = require("../factory/operations");
|
|
5
|
-
const prompts_1 = require("../factory/prompts");
|
|
6
6
|
function transform(props) {
|
|
7
7
|
// TEXT
|
|
8
|
-
if (props.
|
|
8
|
+
if (props.history.type === "text") {
|
|
9
9
|
return transformText({
|
|
10
|
-
|
|
10
|
+
history: props.history,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
// SELECT & CANCEL
|
|
14
|
-
else if (props.
|
|
14
|
+
else if (props.history.type === "select") {
|
|
15
15
|
return transformSelect({
|
|
16
16
|
operations: props.operations,
|
|
17
|
-
|
|
17
|
+
history: props.history,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
else if (props.
|
|
20
|
+
else if (props.history.type === "cancel") {
|
|
21
21
|
return transformCancel({
|
|
22
22
|
operations: props.operations,
|
|
23
|
-
|
|
23
|
+
history: props.history,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
// EXECUTE
|
|
27
|
-
else if (props.
|
|
27
|
+
else if (props.history.type === "execute") {
|
|
28
28
|
return transformExecute({
|
|
29
29
|
operations: props.operations,
|
|
30
|
-
|
|
30
|
+
history: props.history,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
else if (props.
|
|
33
|
+
else if (props.history.type === "describe") {
|
|
34
34
|
return transformDescribe({
|
|
35
35
|
operations: props.operations,
|
|
36
|
-
|
|
36
|
+
history: props.history,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
throw new Error("Invalid prompt type.");
|
|
40
40
|
}
|
|
41
41
|
function transformText(props) {
|
|
42
|
-
return (0,
|
|
42
|
+
return (0, histories_1.createTextHistory)(props.history);
|
|
43
43
|
}
|
|
44
44
|
function transformSelect(props) {
|
|
45
|
-
return (0,
|
|
46
|
-
id: props.
|
|
47
|
-
selections: props.
|
|
45
|
+
return (0, histories_1.createSelectHistory)({
|
|
46
|
+
id: props.history.id,
|
|
47
|
+
selections: props.history.selections.map(select => (0, operations_1.createOperationSelection)({
|
|
48
48
|
operation: findOperation({
|
|
49
49
|
operations: props.operations,
|
|
50
50
|
input: select.operation,
|
|
@@ -54,9 +54,9 @@ function transformSelect(props) {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function transformCancel(props) {
|
|
57
|
-
return (0,
|
|
58
|
-
id: props.
|
|
59
|
-
selections: props.
|
|
57
|
+
return (0, histories_1.createCancelHistory)({
|
|
58
|
+
id: props.history.id,
|
|
59
|
+
selections: props.history.selections.map(select => (0, operations_1.createOperationSelection)({
|
|
60
60
|
operation: findOperation({
|
|
61
61
|
operations: props.operations,
|
|
62
62
|
input: select.operation,
|
|
@@ -66,26 +66,26 @@ function transformCancel(props) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
function transformExecute(props) {
|
|
69
|
-
return (0,
|
|
70
|
-
id: props.
|
|
69
|
+
return (0, histories_1.createExecuteHistory)({
|
|
70
|
+
id: props.history.id,
|
|
71
71
|
operation: findOperation({
|
|
72
72
|
operations: props.operations,
|
|
73
|
-
input: props.
|
|
73
|
+
input: props.history.operation,
|
|
74
74
|
}),
|
|
75
|
-
arguments: props.
|
|
75
|
+
arguments: props.history.arguments,
|
|
76
76
|
/**
|
|
77
77
|
* @TODO fix it
|
|
78
78
|
* The property and value have a type mismatch, but it works.
|
|
79
79
|
*/
|
|
80
|
-
value: props.
|
|
80
|
+
value: props.history.value,
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
function transformDescribe(props) {
|
|
84
|
-
return (0,
|
|
85
|
-
text: props.
|
|
86
|
-
executes: props.
|
|
84
|
+
return (0, histories_1.createDescribeHistory)({
|
|
85
|
+
text: props.history.text,
|
|
86
|
+
executes: props.history.executes.map(next => transformExecute({
|
|
87
87
|
operations: props.operations,
|
|
88
|
-
|
|
88
|
+
history: next,
|
|
89
89
|
})),
|
|
90
90
|
});
|
|
91
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgenticaPromptTransformer.js","sourceRoot":"","sources":["../../src/transformers/AgenticaPromptTransformer.ts"],"names":[],"mappings":";;;AAWA,
|
|
1
|
+
{"version":3,"file":"AgenticaPromptTransformer.js","sourceRoot":"","sources":["../../src/transformers/AgenticaPromptTransformer.ts"],"names":[],"mappings":";;;AAWA,oDAAgJ;AAChJ,sDAAiE;AAEjE,SAAS,SAAS,CAAiC,KAGlD;IACC,OAAO;IACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAClC,OAAO,aAAa,CAAC;YACnB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,kBAAkB;SACb,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,eAAe,CAAC;YACrB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;SACI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,eAAe,CAAC;YACrB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,UAAU;SACL,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,gBAAgB,CAAC;YACtB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;SACI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC3C,OAAO,iBAAiB,CAAC;YACvB,UA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|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
5
5
|
"author": "Wrtn Technologies",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@samchon/openapi": ">=
|
|
39
|
+
"@samchon/openapi": ">=4.0.0 <5.0.0",
|
|
40
40
|
"openai": ">=4.80.0",
|
|
41
|
-
"typia": ">=
|
|
41
|
+
"typia": ">=9.0.1 <10.0.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@samchon/openapi": "^
|
|
45
|
-
"typia": "^
|
|
44
|
+
"@samchon/openapi": "^4.0.0",
|
|
45
|
+
"typia": "^9.0.1",
|
|
46
46
|
"uuid": "^11.0.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@nestia/e2e": "^0.
|
|
49
|
+
"@nestia/e2e": "^6.0.1",
|
|
50
50
|
"@rollup/plugin-terser": "^0.4.4",
|
|
51
51
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
52
52
|
"@types/node": "^22.13.4",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"ts-node": "^10.9.2",
|
|
58
58
|
"ts-patch": "^3.3.0",
|
|
59
59
|
"typedoc": "^0.27.7",
|
|
60
|
-
"typescript": "~5.8.
|
|
60
|
+
"typescript": "~5.8.3"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "rimraf lib && pnpm build:prompt && tsc && rollup -c",
|
package/src/Agentica.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type { AgenticaOperationCollection } from "./context/AgenticaOperationCol
|
|
|
6
6
|
import type { AgenticaOperationSelection } from "./context/AgenticaOperationSelection";
|
|
7
7
|
import type { AgenticaEvent } from "./events/AgenticaEvent";
|
|
8
8
|
import type { AgenticaRequestEvent } from "./events/AgenticaRequestEvent";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
9
|
+
import type { AgenticaHistory } from "./histories/AgenticaHistory";
|
|
10
|
+
import type { AgenticaTextHistory } from "./histories/AgenticaTextHistory";
|
|
11
11
|
import type { IAgenticaConfig } from "./structures/IAgenticaConfig";
|
|
12
12
|
import type { IAgenticaController } from "./structures/IAgenticaController";
|
|
13
13
|
import type { IAgenticaProps } from "./structures/IAgenticaProps";
|
|
@@ -17,7 +17,7 @@ import { AgenticaTokenUsage } from "./context/AgenticaTokenUsage";
|
|
|
17
17
|
import { AgenticaOperationComposer } from "./context/internal/AgenticaOperationComposer";
|
|
18
18
|
import { AgenticaTokenUsageAggregator } from "./context/internal/AgenticaTokenUsageAggregator";
|
|
19
19
|
import { createInitializeEvent, createRequestEvent, createTextEvent } from "./factory/events";
|
|
20
|
-
import {
|
|
20
|
+
import { createTextHistory } from "./factory/histories";
|
|
21
21
|
import { execute } from "./orchestrate/execute";
|
|
22
22
|
import { AgenticaPromptTransformer } from "./transformers/AgenticaPromptTransformer";
|
|
23
23
|
import { __map_take } from "./utils/__map_take";
|
|
@@ -25,12 +25,12 @@ import { ChatGptCompletionMessageUtil } from "./utils/ChatGptCompletionMessageUt
|
|
|
25
25
|
import { StreamUtil } from "./utils/StreamUtil";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Agentica AI chatbot agent.
|
|
29
29
|
*
|
|
30
|
-
* `Agentica` is a facade class for the super
|
|
31
|
-
* which performs
|
|
32
|
-
*
|
|
33
|
-
* {@link
|
|
30
|
+
* `Agentica` is a facade class for the super AI chatbot agent
|
|
31
|
+
* which performs LLM (Large Language Model) function calling from the
|
|
32
|
+
* {@link conversate user's conversation}, and manages the
|
|
33
|
+
* {@link getHistories prompt histories}.
|
|
34
34
|
*
|
|
35
35
|
* To understand and compose the `Agentica` class exactly, reference
|
|
36
36
|
* below types concentrating on the documentation comments please.
|
|
@@ -45,7 +45,7 @@ import { StreamUtil } from "./utils/StreamUtil";
|
|
|
45
45
|
* - {@link IAgenticaSystemPrompt}
|
|
46
46
|
* - Accessors
|
|
47
47
|
* - {@link IAgenticaOperation}
|
|
48
|
-
* - {@link
|
|
48
|
+
* - {@link IAgenticaHistoryJson}
|
|
49
49
|
* - {@link IAgenticaEventJson}
|
|
50
50
|
* - {@link IAgenticaTokenUsageJson}
|
|
51
51
|
*
|
|
@@ -57,7 +57,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
57
57
|
|
|
58
58
|
// STACK
|
|
59
59
|
private readonly stack_: AgenticaOperationSelection<Model>[];
|
|
60
|
-
private readonly
|
|
60
|
+
private readonly histories_: AgenticaHistory<Model>[];
|
|
61
61
|
private readonly listeners_: Map<string, Set<(event: AgenticaEvent<Model>) => Promise<void> | void>>;
|
|
62
62
|
|
|
63
63
|
// STATUS
|
|
@@ -65,7 +65,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
65
65
|
private ready_: boolean;
|
|
66
66
|
private readonly executor_: (
|
|
67
67
|
ctx: AgenticaContext<Model>,
|
|
68
|
-
) => Promise<
|
|
68
|
+
) => Promise<AgenticaHistory<Model>[]>;
|
|
69
69
|
|
|
70
70
|
/* -----------------------------------------------------------
|
|
71
71
|
CONSTRUCTOR
|
|
@@ -85,10 +85,10 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
85
85
|
// STATUS
|
|
86
86
|
this.stack_ = [];
|
|
87
87
|
this.listeners_ = new Map();
|
|
88
|
-
this.
|
|
88
|
+
this.histories_ = (props.histories ?? []).map(input =>
|
|
89
89
|
AgenticaPromptTransformer.transform({
|
|
90
90
|
operations: this.operations_.group,
|
|
91
|
-
|
|
91
|
+
history: input,
|
|
92
92
|
}),
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -115,19 +115,19 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
115
115
|
ACCESSORS
|
|
116
116
|
----------------------------------------------------------- */
|
|
117
117
|
/**
|
|
118
|
-
* Conversate with the
|
|
118
|
+
* Conversate with the AI chatbot.
|
|
119
119
|
*
|
|
120
|
-
* User talks to the
|
|
120
|
+
* User talks to the AI chatbot with the given content.
|
|
121
121
|
*
|
|
122
|
-
* When the user's conversation implies the
|
|
122
|
+
* When the user's conversation implies the AI chatbot to execute a
|
|
123
123
|
* function calling, the returned chat prompts will contain the
|
|
124
|
-
* function calling information like {@link
|
|
124
|
+
* function calling information like {@link AgenticaExecuteHistory}.
|
|
125
125
|
*
|
|
126
126
|
* @param content The content to talk
|
|
127
127
|
* @returns List of newly created chat prompts
|
|
128
128
|
*/
|
|
129
|
-
public async conversate(content: string): Promise<
|
|
130
|
-
const
|
|
129
|
+
public async conversate(content: string): Promise<AgenticaHistory<Model>[]> {
|
|
130
|
+
const text: AgenticaTextHistory<"user"> = createTextHistory<"user">({
|
|
131
131
|
role: "user",
|
|
132
132
|
text: content,
|
|
133
133
|
});
|
|
@@ -141,14 +141,14 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
141
141
|
}),
|
|
142
142
|
);
|
|
143
143
|
|
|
144
|
-
const newbie:
|
|
144
|
+
const newbie: AgenticaHistory<Model>[] = await this.executor_(
|
|
145
145
|
this.getContext({
|
|
146
|
-
prompt,
|
|
146
|
+
prompt: text,
|
|
147
147
|
usage: this.token_usage_,
|
|
148
148
|
}),
|
|
149
149
|
);
|
|
150
|
-
this.
|
|
151
|
-
return [
|
|
150
|
+
this.histories_.push(text, ...newbie);
|
|
151
|
+
return [text, ...newbie];
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
@@ -169,7 +169,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
169
169
|
* Get controllers.
|
|
170
170
|
*
|
|
171
171
|
* Get list of controllers, which are the collection of functions that
|
|
172
|
-
* the "Super
|
|
172
|
+
* the "Super AI Chatbot" can execute.
|
|
173
173
|
*/
|
|
174
174
|
public getControllers(): ReadonlyArray<IAgenticaController<Model>> {
|
|
175
175
|
return this.props.controllers;
|
|
@@ -188,23 +188,23 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
* Get the chatbot's
|
|
191
|
+
* Get the chatbot's histories.
|
|
192
192
|
*
|
|
193
|
-
* Get list of chat
|
|
193
|
+
* Get list of chat histories that the chatbot has been conversated.
|
|
194
194
|
*
|
|
195
|
-
* @returns List of chat
|
|
195
|
+
* @returns List of chat histories
|
|
196
196
|
*/
|
|
197
|
-
public
|
|
198
|
-
return this.
|
|
197
|
+
public getHistories(): AgenticaHistory<Model>[] {
|
|
198
|
+
return this.histories_;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
|
-
* Get token usage of the
|
|
202
|
+
* Get token usage of the AI chatbot.
|
|
203
203
|
*
|
|
204
|
-
* Entire token usage of the
|
|
204
|
+
* Entire token usage of the AI chatbot during the conversating
|
|
205
205
|
* with the user by {@link conversate} method callings.
|
|
206
206
|
*
|
|
207
|
-
* @returns Cost of the
|
|
207
|
+
* @returns Cost of the AI chatbot
|
|
208
208
|
*/
|
|
209
209
|
public getTokenUsage(): AgenticaTokenUsage {
|
|
210
210
|
return this.token_usage_;
|
|
@@ -214,7 +214,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
214
214
|
* @internal
|
|
215
215
|
*/
|
|
216
216
|
public getContext(props: {
|
|
217
|
-
prompt:
|
|
217
|
+
prompt: AgenticaTextHistory<"user">;
|
|
218
218
|
usage: AgenticaTokenUsage;
|
|
219
219
|
}): AgenticaContext<Model> {
|
|
220
220
|
const dispatch = async (event: AgenticaEvent<Model>) => this.dispatch(event);
|
|
@@ -224,7 +224,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
224
224
|
config: this.props.config,
|
|
225
225
|
|
|
226
226
|
// STATES
|
|
227
|
-
histories: this.
|
|
227
|
+
histories: this.histories_,
|
|
228
228
|
stack: this.stack_,
|
|
229
229
|
ready: () => this.ready_,
|
|
230
230
|
prompt: props.prompt,
|
|
@@ -261,7 +261,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
261
261
|
|
|
262
262
|
const [streamForAggregate, streamForReturn] = temporaryStream.tee();
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
(async () => {
|
|
265
265
|
const reader = streamForAggregate.getReader();
|
|
266
266
|
while (true) {
|
|
267
267
|
const chunk = await reader.read();
|
|
@@ -276,7 +276,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
})();
|
|
279
|
+
})().catch(() => {});
|
|
280
280
|
|
|
281
281
|
const [streamForStream, streamForJoin] = streamForEvent.tee();
|
|
282
282
|
await dispatch({
|