@agentica/core 0.24.0 → 0.25.0
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 +2 -2
- package/lib/Agentica.js +4 -4
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.d.ts +2 -2
- package/lib/MicroAgentica.js +4 -4
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +2 -2
- package/lib/context/MicroAgenticaContext.d.ts +2 -2
- package/lib/context/index.d.ts +5 -0
- package/lib/{structures/mcp → context}/index.js +5 -1
- package/lib/context/index.js.map +1 -0
- package/lib/events/AgenticaAssistantMessageEvent.d.ts +9 -0
- package/lib/{histories/AgenticaUserInputHistory.js → events/AgenticaAssistantMessageEvent.js} +1 -1
- package/lib/events/AgenticaAssistantMessageEvent.js.map +1 -0
- package/lib/events/AgenticaEvent.d.ts +9 -9
- package/lib/events/AgenticaUserMessageEvent.d.ts +9 -0
- package/lib/events/{AgenticaUserInputEvent.js → AgenticaUserMessageEvent.js} +1 -1
- package/lib/events/AgenticaUserMessageEvent.js.map +1 -0
- package/lib/events/MicroAgenticaEvent.d.ts +6 -6
- package/lib/events/index.d.ts +14 -0
- package/lib/events/index.js +31 -0
- package/lib/events/index.js.map +1 -0
- package/lib/factory/events.d.ts +8 -8
- package/lib/factory/events.js +23 -38
- package/lib/factory/events.js.map +1 -1
- package/lib/factory/histories.d.ts +1 -36
- package/lib/factory/histories.js +77 -24
- package/lib/factory/histories.js.map +1 -1
- package/lib/functional/assertHttpController.js +6 -6
- package/lib/functional/assertHttpLlmApplication.js +6 -6
- package/lib/functional/assertMcpController.d.ts +1 -2
- package/lib/functional/assertMcpController.js +6 -6
- package/lib/functional/assertMcpController.js.map +1 -1
- package/lib/functional/index.d.ts +6 -0
- package/lib/functional/index.js +23 -0
- package/lib/functional/index.js.map +1 -0
- package/lib/functional/validateHttpController.js +5 -5
- package/lib/functional/validateHttpLlmApplication.js +5 -5
- package/lib/functional/validateMcpController.d.ts +1 -2
- package/lib/functional/validateMcpController.js +11 -11
- package/lib/functional/validateMcpController.js.map +1 -1
- package/lib/histories/{AgenticaTextHistory.d.ts → AgenticaAssistantMessageHistory.d.ts} +1 -2
- package/lib/histories/AgenticaAssistantMessageHistory.js +3 -0
- package/lib/histories/AgenticaAssistantMessageHistory.js.map +1 -0
- package/lib/histories/AgenticaHistory.d.ts +7 -7
- package/lib/histories/AgenticaUserMessageHistory.d.ts +6 -0
- package/lib/{events/AgenticaTextEvent.js → histories/AgenticaUserMessageHistory.js} +1 -1
- package/lib/histories/AgenticaUserMessageHistory.js.map +1 -0
- package/lib/histories/MicroAgenticaHistory.d.ts +5 -4
- package/lib/histories/contents/AgenticaUserMessageAudioContent.d.ts +19 -0
- package/lib/histories/contents/AgenticaUserMessageAudioContent.js +3 -0
- package/lib/histories/contents/AgenticaUserMessageAudioContent.js.map +1 -0
- package/lib/histories/contents/AgenticaUserMessageContent.d.ts +14 -0
- package/lib/histories/{AgenticaTextHistory.js → contents/AgenticaUserMessageContent.js} +1 -1
- package/lib/histories/contents/AgenticaUserMessageContent.js.map +1 -0
- package/lib/histories/contents/AgenticaUserMessageContentBase.d.ts +6 -0
- package/lib/histories/contents/AgenticaUserMessageContentBase.js +3 -0
- package/lib/histories/contents/AgenticaUserMessageContentBase.js.map +1 -0
- package/lib/histories/contents/AgenticaUserMessageFileContent.d.ts +26 -0
- package/lib/histories/contents/AgenticaUserMessageFileContent.js +3 -0
- package/lib/histories/contents/AgenticaUserMessageFileContent.js.map +1 -0
- package/lib/histories/contents/AgenticaUserMessageImageContent.d.ts +20 -0
- package/lib/histories/contents/AgenticaUserMessageImageContent.js +3 -0
- package/lib/histories/contents/AgenticaUserMessageImageContent.js.map +1 -0
- package/lib/histories/contents/AgenticaUserMessageTextContent.d.ts +14 -0
- package/lib/histories/contents/AgenticaUserMessageTextContent.js +3 -0
- package/lib/histories/contents/AgenticaUserMessageTextContent.js.map +1 -0
- package/lib/histories/contents/index.d.ts +5 -0
- package/lib/histories/contents/index.js +22 -0
- package/lib/histories/contents/index.js.map +1 -0
- package/lib/histories/index.d.ts +9 -0
- package/lib/histories/index.js +26 -0
- package/lib/histories/index.js.map +1 -0
- package/lib/index.d.ts +6 -45
- package/lib/index.js +6 -46
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +148 -133
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +29 -23
- package/lib/json/IAgenticaHistoryJson.d.ts +24 -19
- package/lib/json/IMicroAgenticaEventJson.d.ts +1 -1
- package/lib/json/IMicroAgenticaHistoryJson.d.ts +1 -1
- package/lib/json/index.d.ts +7 -0
- package/lib/json/index.js +24 -0
- package/lib/json/index.js.map +1 -0
- package/lib/orchestrate/call.js +4 -4
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +1 -1
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/initialize.js +4 -4
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/select.js +3 -3
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaController.d.ts +1 -2
- package/lib/structures/index.d.ts +10 -0
- package/lib/structures/index.js +27 -0
- package/lib/structures/index.js.map +1 -0
- package/lib/transformers/transformEvent.d.ts +1 -0
- package/lib/transformers/{AgenticaEventTransformer.js → transformEvent.js} +74 -31
- package/lib/transformers/transformEvent.js.map +1 -0
- package/lib/transformers/transformHistory.d.ts +1 -0
- package/lib/transformers/{AgenticaHistoryTransformer.js → transformHistory.js} +24 -23
- package/lib/transformers/transformHistory.js.map +1 -0
- package/lib/utils/ChatGptCompletionMessageUtil.js +2 -2
- package/package.json +5 -6
- package/src/Agentica.ts +10 -9
- package/src/MicroAgentica.ts +12 -9
- package/src/context/AgenticaContext.ts +2 -2
- package/src/context/MicroAgenticaContext.ts +2 -2
- package/src/context/index.ts +5 -0
- package/src/events/AgenticaAssistantMessageEvent.ts +12 -0
- package/src/events/AgenticaEvent.ts +15 -15
- package/src/events/AgenticaUserMessageEvent.ts +12 -0
- package/src/events/MicroAgenticaEvent.ts +9 -9
- package/src/events/index.ts +14 -0
- package/src/factory/events.ts +29 -34
- package/src/factory/histories.ts +81 -32
- package/src/functional/assertMcpController.ts +4 -2
- package/src/functional/index.ts +7 -0
- package/src/functional/validateMcpController.ts +4 -2
- package/src/histories/{AgenticaTextHistory.ts → AgenticaAssistantMessageHistory.ts} +4 -2
- package/src/histories/AgenticaHistory.ts +8 -8
- package/src/histories/AgenticaUserMessageHistory.ts +11 -0
- package/src/histories/MicroAgenticaHistory.ts +6 -5
- package/src/histories/contents/AgenticaUserMessageAudioContent.ts +21 -0
- package/src/histories/contents/AgenticaUserMessageContent.ts +19 -0
- package/src/histories/contents/AgenticaUserMessageContentBase.ts +6 -0
- package/src/histories/contents/AgenticaUserMessageFileContent.ts +27 -0
- package/src/histories/contents/AgenticaUserMessageImageContent.ts +23 -0
- package/src/histories/contents/AgenticaUserMessageTextContent.ts +15 -0
- package/src/histories/contents/index.ts +5 -0
- package/src/histories/index.ts +9 -0
- package/src/index.ts +6 -54
- package/src/json/IAgenticaEventJson.ts +36 -28
- package/src/json/IAgenticaHistoryJson.ts +28 -22
- package/src/json/IMicroAgenticaEventJson.ts +2 -1
- package/src/json/IMicroAgenticaHistoryJson.ts +2 -1
- package/src/json/index.ts +7 -0
- package/src/orchestrate/call.ts +8 -8
- package/src/orchestrate/cancel.ts +2 -2
- package/src/orchestrate/initialize.ts +5 -5
- package/src/orchestrate/select.ts +5 -5
- package/src/structures/IAgenticaController.ts +4 -2
- package/src/structures/index.ts +10 -0
- package/src/transformers/{AgenticaEventTransformer.ts → transformEvent.ts} +94 -42
- package/src/transformers/{AgenticaHistoryTransformer.ts → transformHistory.ts} +30 -26
- package/lib/events/AgenticaTextEvent.d.ts +0 -10
- package/lib/events/AgenticaTextEvent.js.map +0 -1
- package/lib/events/AgenticaUserInputEvent.d.ts +0 -10
- package/lib/events/AgenticaUserInputEvent.js.map +0 -1
- package/lib/histories/AgenticaTextHistory.js.map +0 -1
- package/lib/histories/AgenticaUserInputHistory.d.ts +0 -86
- package/lib/histories/AgenticaUserInputHistory.js.map +0 -1
- package/lib/structures/mcp/IMcpLlmTransportProps.d.ts +0 -11
- package/lib/structures/mcp/IMcpLlmTransportProps.js +0 -3
- package/lib/structures/mcp/IMcpLlmTransportProps.js.map +0 -1
- package/lib/structures/mcp/index.d.ts +0 -1
- package/lib/structures/mcp/index.js.map +0 -1
- package/lib/transformers/AgenticaEventTransformer.d.ts +0 -63
- package/lib/transformers/AgenticaEventTransformer.js.map +0 -1
- package/lib/transformers/AgenticaHistoryTransformer.d.ts +0 -41
- package/lib/transformers/AgenticaHistoryTransformer.js.map +0 -1
- package/src/events/AgenticaTextEvent.ts +0 -12
- package/src/events/AgenticaUserInputEvent.ts +0 -12
- package/src/histories/AgenticaUserInputHistory.ts +0 -94
- package/src/structures/mcp/IMcpLlmTransportProps.ts +0 -13
- package/src/structures/mcp/index.ts +0 -1
|
@@ -9,21 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
12
|
+
exports.transformEvent = transformEvent;
|
|
13
|
+
exports.transformCall = transformCall;
|
|
14
14
|
const events_1 = require("../factory/events");
|
|
15
15
|
const operations_1 = require("../factory/operations");
|
|
16
16
|
const StreamUtil_1 = require("../utils/StreamUtil");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (found === undefined) {
|
|
22
|
-
throw new Error(`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`);
|
|
23
|
-
}
|
|
24
|
-
return found;
|
|
25
|
-
}
|
|
26
|
-
function transform(props) {
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function transformEvent(props) {
|
|
27
21
|
if (props.event.type === "call") {
|
|
28
22
|
return transformCall({
|
|
29
23
|
operations: props.operations,
|
|
@@ -62,15 +56,24 @@ function transform(props) {
|
|
|
62
56
|
event: props.event,
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
|
-
else if (props.event.type === "
|
|
66
|
-
return
|
|
59
|
+
else if (props.event.type === "assistantMessage") {
|
|
60
|
+
return transformAssistantMessage({
|
|
67
61
|
event: props.event,
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
|
-
else {
|
|
71
|
-
|
|
64
|
+
else if (props.event.type === "userMessage") {
|
|
65
|
+
return transformUserMessage({
|
|
66
|
+
event: props.event,
|
|
67
|
+
});
|
|
72
68
|
}
|
|
69
|
+
return transformValidateEvent({
|
|
70
|
+
operations: props.operations,
|
|
71
|
+
event: props.event,
|
|
72
|
+
});
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
74
77
|
function transformCall(props) {
|
|
75
78
|
return (0, events_1.createCallEvent)({
|
|
76
79
|
id: props.event.id,
|
|
@@ -81,6 +84,9 @@ function transformCall(props) {
|
|
|
81
84
|
arguments: props.event.arguments,
|
|
82
85
|
});
|
|
83
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
84
90
|
function transformCancel(props) {
|
|
85
91
|
return (0, events_1.createCancelEvent)({
|
|
86
92
|
selection: (0, operations_1.createOperationSelection)({
|
|
@@ -92,6 +98,9 @@ function transformCancel(props) {
|
|
|
92
98
|
}),
|
|
93
99
|
});
|
|
94
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
95
104
|
function transformDescribe(props) {
|
|
96
105
|
return (0, events_1.createDescribeEvent)({
|
|
97
106
|
executes: props.event.executes.map(next => transformExecute({
|
|
@@ -104,6 +113,9 @@ function transformDescribe(props) {
|
|
|
104
113
|
join: () => __awaiter(this, void 0, void 0, function* () { return props.event.text; }),
|
|
105
114
|
});
|
|
106
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
107
119
|
function transformExecute(props) {
|
|
108
120
|
return (0, events_1.createExecuteEvent)({
|
|
109
121
|
id: props.event.id,
|
|
@@ -115,12 +127,21 @@ function transformExecute(props) {
|
|
|
115
127
|
value: props.event.value,
|
|
116
128
|
});
|
|
117
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
118
133
|
function transformInitialize() {
|
|
119
134
|
return (0, events_1.createInitializeEvent)();
|
|
120
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
121
139
|
function transformRequest(props) {
|
|
122
140
|
return (0, events_1.createRequestEvent)(props.event);
|
|
123
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
124
145
|
function transformSelect(props) {
|
|
125
146
|
return (0, events_1.createSelectEvent)({
|
|
126
147
|
selection: (0, operations_1.createOperationSelection)({
|
|
@@ -132,24 +153,46 @@ function transformSelect(props) {
|
|
|
132
153
|
}),
|
|
133
154
|
});
|
|
134
155
|
}
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
/**
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
function transformAssistantMessage(props) {
|
|
160
|
+
return (0, events_1.creatAssistantEvent)({
|
|
137
161
|
stream: (0, StreamUtil_1.toAsyncGenerator)(props.event.text),
|
|
138
162
|
done: () => true,
|
|
139
163
|
get: () => props.event.text,
|
|
140
164
|
join: () => __awaiter(this, void 0, void 0, function* () { return props.event.text; }),
|
|
141
165
|
});
|
|
142
166
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
/**
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
function transformUserMessage(props) {
|
|
171
|
+
return (0, events_1.createUserMessageEvent)(props.event);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
function transformValidateEvent(props) {
|
|
177
|
+
return (0, events_1.createValidateEvent)({
|
|
178
|
+
id: props.event.id,
|
|
179
|
+
operation: findOperation({
|
|
180
|
+
operations: props.operations,
|
|
181
|
+
input: props.event.operation,
|
|
182
|
+
}),
|
|
183
|
+
result: props.event.result,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
function findOperation(props) {
|
|
190
|
+
var _a;
|
|
191
|
+
const found = (_a = props.operations
|
|
192
|
+
.get(props.input.controller)) === null || _a === void 0 ? void 0 : _a.get(props.input.function);
|
|
193
|
+
if (found === undefined) {
|
|
194
|
+
throw new Error(`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`);
|
|
195
|
+
}
|
|
196
|
+
return found;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=transformEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformEvent.js","sourceRoot":"","sources":["../../src/transformers/transformEvent.ts"],"names":[],"mappings":";;;;;;;;;;;AAsBA,wCAwDC;AAKD,sCAYC;AAhFD,8CAAgP;AAChP,sDAAiE;AACjE,oDAAuD;AAEvD;;GAEG;AACH,SAAgB,cAAc,CAAiC,KAG9D;IACC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO,aAAa,CAAC;YACnB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;SACI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK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
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.transformHistory = transformHistory;
|
|
4
4
|
const histories_1 = require("../factory/histories");
|
|
5
5
|
const operations_1 = require("../factory/operations");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function transformHistory(props) {
|
|
10
|
+
// USER
|
|
11
|
+
if (props.history.type === "userMessage") {
|
|
12
|
+
return transformUserMessage({
|
|
13
|
+
history: props.history,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
// ASSISTANT
|
|
17
|
+
else if (props.history.type === "assistantMessage") {
|
|
18
|
+
return transformAssistantMessage({
|
|
10
19
|
history: props.history,
|
|
11
20
|
});
|
|
12
21
|
}
|
|
@@ -30,16 +39,16 @@ function transform(props) {
|
|
|
30
39
|
history: props.history,
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
return transformDescribe({
|
|
43
|
+
operations: props.operations,
|
|
44
|
+
history: props.history,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function transformAssistantMessage(props) {
|
|
48
|
+
return (0, histories_1.createAssistantMessageHistory)(props.history);
|
|
40
49
|
}
|
|
41
|
-
function
|
|
42
|
-
return (0, histories_1.
|
|
50
|
+
function transformUserMessage(props) {
|
|
51
|
+
return (0, histories_1.createUserMessageHistory)(props.history);
|
|
43
52
|
}
|
|
44
53
|
function transformSelect(props) {
|
|
45
54
|
return (0, histories_1.createSelectHistory)({
|
|
@@ -98,12 +107,4 @@ function findOperation(props) {
|
|
|
98
107
|
}
|
|
99
108
|
return found;
|
|
100
109
|
}
|
|
101
|
-
|
|
102
|
-
transform,
|
|
103
|
-
transformText,
|
|
104
|
-
transformSelect,
|
|
105
|
-
transformCancel,
|
|
106
|
-
transformExecute,
|
|
107
|
-
transformDescribe,
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=AgenticaHistoryTransformer.js.map
|
|
110
|
+
//# sourceMappingURL=transformHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformHistory.js","sourceRoot":"","sources":["../../src/transformers/transformHistory.ts"],"names":[],"mappings":";;AAkBA,4CAwCC;AA9CD,oDAAsL;AACtL,sDAAiE;AAEjE;;GAEG;AACH,SAAgB,gBAAgB,CAAiC,KAGhE;IACC,OAAO;IACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACzC,OAAO,oBAAoB,CAAC;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,YAAY;SACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACnD,OAAO,yBAAyB,CAAC;YAC/B,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,EA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
|
function transformCompletionChunk(source) {
|
|
45
45
|
const str = source instanceof Uint8Array ? ByteArrayUtil_1.ByteArrayUtil.toUtf8(source) : source;
|
|
46
46
|
const result = JSON.parse(str);
|
|
47
|
-
const valid = (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "length" === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "
|
|
47
|
+
const valid = (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "length" === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "assistant" === input.role || "tool" === input.role) && (undefined === input.tool_calls || Array.isArray(input.tool_calls) && input.tool_calls.every(elem => "object" === typeof elem && null !== elem && _io4(elem))); const _io3 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io4 = input => "number" === typeof input.index && (undefined === input.id || "string" === typeof input.id) && (undefined === input["function"] || "object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) && _io5(input["function"])) && (undefined === input.type || "function" === input.type); const _io5 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io6 = input => (null === input.content || Array.isArray(input.content) && input.content.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (null === input.refusal || Array.isArray(input.refusal) && input.refusal.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob && (Array.isArray(input.top_logprobs) && input.top_logprobs.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob; const _io9 = input => "number" === typeof input.completion_tokens && "number" === typeof input.prompt_tokens && "number" === typeof input.total_tokens && (undefined === input.completion_tokens_details || "object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) && _io10(input.completion_tokens_details)) && (undefined === input.prompt_tokens_details || "object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) && _io11(input.prompt_tokens_details)); const _io10 = input => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens); const _io11 = input => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
|
|
48
48
|
path: _path + ".id",
|
|
49
49
|
expected: "string",
|
|
50
50
|
value: input.id
|
|
@@ -132,7 +132,7 @@ function transformCompletionChunk(source) {
|
|
|
132
132
|
path: _path + ".refusal",
|
|
133
133
|
expected: "(null | string | undefined)",
|
|
134
134
|
value: input.refusal
|
|
135
|
-
}), undefined === input.role || "
|
|
135
|
+
}), undefined === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "assistant" === input.role || "tool" === input.role || _report(_exceptionable, {
|
|
136
136
|
path: _path + ".role",
|
|
137
137
|
expected: "(\"assistant\" | \"developer\" | \"system\" | \"tool\" | \"user\" | undefined)",
|
|
138
138
|
value: input.role
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
5
5
|
"author": "Wrtn Technologies",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,14 +36,13 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@samchon/openapi": "^4.2.0",
|
|
39
|
+
"@samchon/openapi": "^4.3.0",
|
|
41
40
|
"openai": "^4.80.0",
|
|
42
|
-
"typia": "^9.0
|
|
41
|
+
"typia": "^9.3.0"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
|
-
"@samchon/openapi": "^4.
|
|
46
|
-
"typia": "^9.0
|
|
44
|
+
"@samchon/openapi": "^4.3.0",
|
|
45
|
+
"typia": "^9.3.0",
|
|
47
46
|
"uuid": "^11.0.4"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
package/src/Agentica.ts
CHANGED
|
@@ -6,8 +6,9 @@ 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 { AgenticaUserMessageContent } from "./histories";
|
|
9
10
|
import type { AgenticaHistory } from "./histories/AgenticaHistory";
|
|
10
|
-
import type {
|
|
11
|
+
import type { AgenticaUserMessageHistory } from "./histories/AgenticaUserMessageHistory";
|
|
11
12
|
import type { IAgenticaConfig } from "./structures/IAgenticaConfig";
|
|
12
13
|
import type { IAgenticaController } from "./structures/IAgenticaController";
|
|
13
14
|
import type { IAgenticaProps } from "./structures/IAgenticaProps";
|
|
@@ -16,10 +17,10 @@ import type { IAgenticaVendor } from "./structures/IAgenticaVendor";
|
|
|
16
17
|
import { AgenticaTokenUsage } from "./context/AgenticaTokenUsage";
|
|
17
18
|
import { AgenticaOperationComposer } from "./context/internal/AgenticaOperationComposer";
|
|
18
19
|
import { AgenticaTokenUsageAggregator } from "./context/internal/AgenticaTokenUsageAggregator";
|
|
19
|
-
import {
|
|
20
|
-
import { createInitializeEvent, createRequestEvent,
|
|
20
|
+
import { createUserMessageHistory } from "./factory";
|
|
21
|
+
import { createInitializeEvent, createRequestEvent, createUserMessageEvent } from "./factory/events";
|
|
21
22
|
import { execute } from "./orchestrate/execute";
|
|
22
|
-
import {
|
|
23
|
+
import { transformHistory } from "./transformers/transformHistory";
|
|
23
24
|
import { __map_take } from "./utils/__map_take";
|
|
24
25
|
import { ChatGptCompletionMessageUtil } from "./utils/ChatGptCompletionMessageUtil";
|
|
25
26
|
import { streamDefaultReaderToAsyncGenerator, StreamUtil } from "./utils/StreamUtil";
|
|
@@ -86,7 +87,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
86
87
|
this.stack_ = [];
|
|
87
88
|
this.listeners_ = new Map();
|
|
88
89
|
this.histories_ = (props.histories ?? []).map(input =>
|
|
89
|
-
|
|
90
|
+
transformHistory({
|
|
90
91
|
operations: this.operations_.group,
|
|
91
92
|
history: input,
|
|
92
93
|
}),
|
|
@@ -130,12 +131,12 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
130
131
|
* @returns List of newly created chat prompts
|
|
131
132
|
*/
|
|
132
133
|
public async conversate(
|
|
133
|
-
content: string |
|
|
134
|
+
content: string | AgenticaUserMessageContent | Array<AgenticaUserMessageContent>,
|
|
134
135
|
options: {
|
|
135
136
|
abortSignal?: AbortSignal;
|
|
136
137
|
} = {},
|
|
137
138
|
): Promise<AgenticaHistory<Model>[]> {
|
|
138
|
-
const prompt:
|
|
139
|
+
const prompt: AgenticaUserMessageHistory = createUserMessageHistory({
|
|
139
140
|
contents: Array.isArray(content)
|
|
140
141
|
? content
|
|
141
142
|
: typeof content === "string"
|
|
@@ -147,7 +148,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
this.dispatch(
|
|
150
|
-
|
|
151
|
+
createUserMessageEvent({
|
|
151
152
|
contents: prompt.contents,
|
|
152
153
|
}),
|
|
153
154
|
).catch(() => {});
|
|
@@ -226,7 +227,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
|
|
|
226
227
|
* @internal
|
|
227
228
|
*/
|
|
228
229
|
public getContext(props: {
|
|
229
|
-
prompt:
|
|
230
|
+
prompt: AgenticaUserMessageHistory;
|
|
230
231
|
usage: AgenticaTokenUsage;
|
|
231
232
|
abortSignal?: AbortSignal;
|
|
232
233
|
}): AgenticaContext<Model> {
|
package/src/MicroAgentica.ts
CHANGED
|
@@ -5,8 +5,9 @@ import type { AgenticaOperationCollection } from "./context/AgenticaOperationCol
|
|
|
5
5
|
import type { MicroAgenticaContext } from "./context/MicroAgenticaContext";
|
|
6
6
|
import type { AgenticaRequestEvent } from "./events/AgenticaRequestEvent";
|
|
7
7
|
import type { MicroAgenticaEvent } from "./events/MicroAgenticaEvent";
|
|
8
|
+
import type { AgenticaUserMessageContent } from "./histories";
|
|
8
9
|
import type { AgenticaExecuteHistory } from "./histories/AgenticaExecuteHistory";
|
|
9
|
-
import type {
|
|
10
|
+
import type { AgenticaUserMessageHistory } from "./histories/AgenticaUserMessageHistory";
|
|
10
11
|
import type { MicroAgenticaHistory } from "./histories/MicroAgenticaHistory";
|
|
11
12
|
import type { IAgenticaController } from "./structures/IAgenticaController";
|
|
12
13
|
import type { IAgenticaVendor } from "./structures/IAgenticaVendor";
|
|
@@ -16,10 +17,10 @@ import type { IMicroAgenticaProps } from "./structures/IMicroAgenticaProps";
|
|
|
16
17
|
import { AgenticaTokenUsage } from "./context/AgenticaTokenUsage";
|
|
17
18
|
import { AgenticaOperationComposer } from "./context/internal/AgenticaOperationComposer";
|
|
18
19
|
import { AgenticaTokenUsageAggregator } from "./context/internal/AgenticaTokenUsageAggregator";
|
|
19
|
-
import {
|
|
20
|
-
import { createRequestEvent,
|
|
20
|
+
import { createUserMessageHistory } from "./factory";
|
|
21
|
+
import { createRequestEvent, createUserMessageEvent } from "./factory/events";
|
|
21
22
|
import { call, describe } from "./orchestrate";
|
|
22
|
-
import {
|
|
23
|
+
import { transformHistory } from "./transformers/transformHistory";
|
|
23
24
|
import { __map_take } from "./utils/__map_take";
|
|
24
25
|
import { ChatGptCompletionMessageUtil } from "./utils/ChatGptCompletionMessageUtil";
|
|
25
26
|
import { streamDefaultReaderToAsyncGenerator, StreamUtil } from "./utils/StreamUtil";
|
|
@@ -74,7 +75,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
|
|
|
74
75
|
config: props.config,
|
|
75
76
|
});
|
|
76
77
|
this.histories_ = (props.histories ?? []).map(input =>
|
|
77
|
-
|
|
78
|
+
transformHistory({
|
|
78
79
|
operations: this.operations_.group,
|
|
79
80
|
history: input,
|
|
80
81
|
}),
|
|
@@ -108,8 +109,10 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
|
|
|
108
109
|
* @param content The content to talk
|
|
109
110
|
* @returns List of newly created histories
|
|
110
111
|
*/
|
|
111
|
-
public async conversate(
|
|
112
|
-
|
|
112
|
+
public async conversate(
|
|
113
|
+
content: string | AgenticaUserMessageContent | Array<AgenticaUserMessageContent>,
|
|
114
|
+
): Promise<MicroAgenticaHistory<Model>[]> {
|
|
115
|
+
const talk = createUserMessageHistory({
|
|
113
116
|
contents: Array.isArray(content)
|
|
114
117
|
? content
|
|
115
118
|
: typeof content === "string"
|
|
@@ -120,7 +123,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
|
|
|
120
123
|
: [content],
|
|
121
124
|
});
|
|
122
125
|
this.dispatch(
|
|
123
|
-
|
|
126
|
+
createUserMessageEvent({
|
|
124
127
|
contents: talk.contents,
|
|
125
128
|
}),
|
|
126
129
|
).catch(() => {});
|
|
@@ -207,7 +210,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
|
|
|
207
210
|
* @internal
|
|
208
211
|
*/
|
|
209
212
|
public getContext(props: {
|
|
210
|
-
prompt:
|
|
213
|
+
prompt: AgenticaUserMessageHistory;
|
|
211
214
|
usage: AgenticaTokenUsage;
|
|
212
215
|
}): MicroAgenticaContext<Model> {
|
|
213
216
|
const dispatch = this.dispatch.bind(this);
|
|
@@ -4,7 +4,7 @@ import type OpenAI from "openai";
|
|
|
4
4
|
import type { AgenticaEvent } from "../events/AgenticaEvent";
|
|
5
5
|
import type { AgenticaEventSource } from "../events/AgenticaEventSource";
|
|
6
6
|
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
7
|
-
import type {
|
|
7
|
+
import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
|
|
8
8
|
import type { IAgenticaConfig } from "../structures/IAgenticaConfig";
|
|
9
9
|
|
|
10
10
|
import type { AgenticaOperationCollection } from "./AgenticaOperationCollection";
|
|
@@ -85,7 +85,7 @@ export interface AgenticaContext<Model extends ILlmSchema.Model> {
|
|
|
85
85
|
* The user input history written by the user through the
|
|
86
86
|
* {@link Agentica.conversate} function.
|
|
87
87
|
*/
|
|
88
|
-
prompt:
|
|
88
|
+
prompt: AgenticaUserMessageHistory;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Abort signal.
|
|
@@ -2,7 +2,7 @@ import type { ILlmSchema } from "@samchon/openapi";
|
|
|
2
2
|
import type OpenAI from "openai";
|
|
3
3
|
|
|
4
4
|
import type { MicroAgenticaEvent } from "../events/MicroAgenticaEvent";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
|
|
6
6
|
import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
|
|
7
7
|
import type { IMicroAgenticaConfig } from "../structures/IMicroAgenticaConfig";
|
|
8
8
|
|
|
@@ -66,7 +66,7 @@ export interface MicroAgenticaContext<Model extends ILlmSchema.Model> {
|
|
|
66
66
|
* Text conversation written the by user through the
|
|
67
67
|
* {@link Agentica.conversate} function.
|
|
68
68
|
*/
|
|
69
|
-
prompt:
|
|
69
|
+
prompt: AgenticaUserMessageHistory;
|
|
70
70
|
|
|
71
71
|
// ----
|
|
72
72
|
// HANDLERS
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgenticaAssistantMessageHistory } from "../histories/AgenticaAssistantMessageHistory";
|
|
2
|
+
import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
3
|
+
|
|
4
|
+
import type { AgenticaEventBase } from "./AgenticaEventBase";
|
|
5
|
+
|
|
6
|
+
export interface AgenticaAssistantMessageEvent
|
|
7
|
+
extends AgenticaEventBase<"assistantMessage"> {
|
|
8
|
+
stream: AsyncGenerator<string, undefined, undefined>;
|
|
9
|
+
join: () => Promise<string>;
|
|
10
|
+
toJSON: () => IAgenticaEventJson.IAssistantMessage;
|
|
11
|
+
toHistory: () => AgenticaAssistantMessageHistory;
|
|
12
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
|
|
3
|
+
import type { AgenticaAssistantMessageEvent } from "./AgenticaAssistantMessageEvent";
|
|
3
4
|
import type { AgenticaCallEvent } from "./AgenticaCallEvent";
|
|
4
5
|
import type { AgenticaCancelEvent } from "./AgenticaCancelEvent";
|
|
5
6
|
import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
|
|
@@ -8,8 +9,7 @@ import type { AgenticaInitializeEvent } from "./AgenticaInitializeEvent";
|
|
|
8
9
|
import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
|
|
9
10
|
import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
|
|
10
11
|
import type { AgenticaSelectEvent } from "./AgenticaSelectEvent";
|
|
11
|
-
import type {
|
|
12
|
-
import type { AgenticaUserInputEvent } from "./AgenticaUserInputEvent";
|
|
12
|
+
import type { AgenticaUserMessageEvent } from "./AgenticaUserMessageEvent";
|
|
13
13
|
import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -23,31 +23,31 @@ import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
|
|
|
23
23
|
* @author Samchon
|
|
24
24
|
*/
|
|
25
25
|
export type AgenticaEvent<Model extends ILlmSchema.Model> =
|
|
26
|
+
| AgenticaUserMessageEvent
|
|
27
|
+
| AgenticaAssistantMessageEvent
|
|
28
|
+
| AgenticaInitializeEvent
|
|
29
|
+
| AgenticaSelectEvent<Model>
|
|
26
30
|
| AgenticaCallEvent<Model>
|
|
27
31
|
| AgenticaCancelEvent<Model>
|
|
28
|
-
| AgenticaDescribeEvent<Model>
|
|
29
32
|
| AgenticaExecuteEvent<Model>
|
|
30
|
-
|
|
|
31
|
-
| AgenticaRequestEvent
|
|
32
|
-
| AgenticaResponseEvent
|
|
33
|
-
| AgenticaSelectEvent<Model>
|
|
34
|
-
| AgenticaTextEvent
|
|
33
|
+
| AgenticaDescribeEvent<Model>
|
|
35
34
|
| AgenticaValidateEvent<Model>
|
|
36
|
-
|
|
|
35
|
+
| AgenticaRequestEvent
|
|
36
|
+
| AgenticaResponseEvent;
|
|
37
37
|
export namespace AgenticaEvent {
|
|
38
38
|
export type Type = AgenticaEvent<any>["type"];
|
|
39
39
|
export interface Mapper<Model extends ILlmSchema.Model> {
|
|
40
|
+
userMessage: AgenticaUserMessageEvent;
|
|
41
|
+
assistantMessage: AgenticaAssistantMessageEvent;
|
|
42
|
+
select: AgenticaSelectEvent<Model>;
|
|
43
|
+
initialize: AgenticaInitializeEvent;
|
|
40
44
|
call: AgenticaCallEvent<Model>;
|
|
41
45
|
cancel: AgenticaCancelEvent<Model>;
|
|
42
|
-
describe: AgenticaDescribeEvent<Model>;
|
|
43
46
|
execute: AgenticaExecuteEvent<Model>;
|
|
44
|
-
|
|
47
|
+
describe: AgenticaDescribeEvent<Model>;
|
|
48
|
+
validate: AgenticaValidateEvent<Model>;
|
|
45
49
|
request: AgenticaRequestEvent;
|
|
46
50
|
response: AgenticaResponseEvent;
|
|
47
|
-
select: AgenticaSelectEvent<Model>;
|
|
48
|
-
text: AgenticaTextEvent;
|
|
49
|
-
validate: AgenticaValidateEvent<Model>;
|
|
50
|
-
user_input: AgenticaUserInputEvent;
|
|
51
51
|
}
|
|
52
52
|
export type Source =
|
|
53
53
|
| "initialize"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgenticaUserMessageContent } from "../histories";
|
|
2
|
+
import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
|
|
3
|
+
import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
4
|
+
|
|
5
|
+
import type { AgenticaEventBase } from "./AgenticaEventBase";
|
|
6
|
+
|
|
7
|
+
export interface AgenticaUserMessageEvent
|
|
8
|
+
extends AgenticaEventBase<"userMessage"> {
|
|
9
|
+
contents: Array<AgenticaUserMessageContent>;
|
|
10
|
+
toJSON: () => IAgenticaEventJson.IUserMessage;
|
|
11
|
+
toHistory: () => AgenticaUserMessageHistory;
|
|
12
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
|
|
3
|
+
import type { AgenticaAssistantMessageEvent } from "./AgenticaAssistantMessageEvent";
|
|
3
4
|
import type { AgenticaCallEvent } from "./AgenticaCallEvent";
|
|
4
5
|
import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
|
|
5
6
|
import type { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
|
|
6
7
|
import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
|
|
7
8
|
import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
|
|
8
|
-
import type {
|
|
9
|
-
import type { AgenticaUserInputEvent } from "./AgenticaUserInputEvent";
|
|
9
|
+
import type { AgenticaUserMessageEvent } from "./AgenticaUserMessageEvent";
|
|
10
10
|
import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -20,25 +20,25 @@ import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
|
|
|
20
20
|
* @author Samchon
|
|
21
21
|
*/
|
|
22
22
|
export type MicroAgenticaEvent<Model extends ILlmSchema.Model> =
|
|
23
|
+
| AgenticaUserMessageEvent
|
|
24
|
+
| AgenticaAssistantMessageEvent
|
|
23
25
|
| AgenticaCallEvent<Model>
|
|
24
|
-
| AgenticaDescribeEvent<Model>
|
|
25
26
|
| AgenticaExecuteEvent<Model>
|
|
27
|
+
| AgenticaDescribeEvent<Model>
|
|
26
28
|
| AgenticaRequestEvent
|
|
27
29
|
| AgenticaResponseEvent
|
|
28
|
-
|
|
|
29
|
-
| AgenticaValidateEvent<Model>
|
|
30
|
-
| AgenticaUserInputEvent;
|
|
30
|
+
| AgenticaValidateEvent<Model>;
|
|
31
31
|
export namespace MicroAgenticaEvent {
|
|
32
32
|
export type Type = MicroAgenticaEvent<any>["type"];
|
|
33
33
|
export interface Mapper<Model extends ILlmSchema.Model> {
|
|
34
|
+
userMessage: AgenticaUserMessageEvent;
|
|
35
|
+
assistantMessage: AgenticaAssistantMessageEvent;
|
|
34
36
|
call: AgenticaCallEvent<Model>;
|
|
35
|
-
describe: AgenticaDescribeEvent<Model>;
|
|
36
37
|
execute: AgenticaExecuteEvent<Model>;
|
|
38
|
+
describe: AgenticaDescribeEvent<Model>;
|
|
37
39
|
request: AgenticaRequestEvent;
|
|
38
40
|
response: AgenticaResponseEvent;
|
|
39
|
-
text: AgenticaTextEvent;
|
|
40
41
|
validate: AgenticaValidateEvent<Model>;
|
|
41
|
-
user_input: AgenticaUserInputEvent;
|
|
42
42
|
}
|
|
43
43
|
export type Source = "call" | "describe";
|
|
44
44
|
}
|