@agentica/core 0.12.21 → 0.13.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/README.md +50 -47
- package/lib/Agentica.d.ts +9 -9
- package/lib/Agentica.js +23 -16
- package/lib/Agentica.js.map +1 -1
- package/lib/chatgpt/ChatGptAgent.d.ts +7 -7
- package/lib/chatgpt/ChatGptAgent.js +17 -12
- package/lib/chatgpt/ChatGptAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +7 -6
- package/lib/chatgpt/ChatGptCallFunctionAgent.js +121 -81
- package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +9 -7
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js +177 -145
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCompletionMessageUtil.d.ts +13 -8
- package/lib/chatgpt/ChatGptCompletionMessageUtil.js +499 -489
- package/lib/chatgpt/ChatGptCompletionMessageUtil.js.map +1 -1
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +7 -6
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +33 -32
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +7 -6
- package/lib/chatgpt/ChatGptHistoryDecoder.js +60 -56
- package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +7 -6
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +121 -116
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +20 -5
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js +183 -150
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptUsageAggregator.d.ts +9 -6
- package/lib/chatgpt/ChatGptUsageAggregator.js +46 -41
- package/lib/chatgpt/ChatGptUsageAggregator.js.map +1 -1
- package/lib/context/AgenticaCancelPrompt.d.ts +3 -3
- package/lib/context/AgenticaCancelPrompt.js +1 -1
- package/lib/context/AgenticaCancelPrompt.js.map +1 -1
- package/lib/context/AgenticaClassOperation.d.ts +1 -1
- package/lib/context/AgenticaClassOperation.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +9 -9
- package/lib/context/AgenticaHttpOperation.d.ts +1 -1
- package/lib/context/AgenticaHttpOperation.js.map +1 -1
- package/lib/context/AgenticaOperation.d.ts +4 -4
- package/lib/context/AgenticaOperationBase.d.ts +1 -1
- package/lib/context/AgenticaOperationCollection.d.ts +2 -2
- package/lib/context/AgenticaOperationSelection.d.ts +3 -3
- package/lib/context/AgenticaTokenUsage.d.ts +1 -1
- package/lib/context/AgenticaTokenUsage.js.map +1 -1
- package/lib/context/internal/AgenticaTokenUsageAggregator.d.ts +11 -10
- package/lib/context/internal/AgenticaTokenUsageAggregator.js +42 -43
- package/lib/context/internal/AgenticaTokenUsageAggregator.js.map +1 -1
- package/lib/context/internal/__IChatCancelFunctionsApplication.d.ts +2 -2
- package/lib/context/internal/__IChatInitialApplication.d.ts +2 -2
- package/lib/context/internal/__IChatSelectFunctionsApplication.d.ts +2 -2
- package/lib/events/AgenticaCallEvent.d.ts +3 -3
- package/lib/events/AgenticaCancelEvent.d.ts +3 -3
- package/lib/events/AgenticaDescribeEvent.d.ts +3 -3
- package/lib/events/AgenticaDescribeEvent.js +13 -2
- package/lib/events/AgenticaDescribeEvent.js.map +1 -1
- package/lib/events/AgenticaEvent.d.ts +12 -12
- package/lib/events/AgenticaExecuteEvent.d.ts +7 -7
- package/lib/events/AgenticaInitializeEvent.d.ts +1 -1
- package/lib/events/AgenticaRequestEvent.d.ts +3 -3
- package/lib/events/AgenticaRequestEvent.js.map +1 -1
- package/lib/events/AgenticaResponseEvent.d.ts +2 -2
- package/lib/events/AgenticaResponseEvent.js.map +1 -1
- package/lib/events/AgenticaSelectEvent.d.ts +3 -3
- package/lib/events/AgenticaSelectEvent.js.map +1 -1
- package/lib/events/AgenticaTextEvent.d.ts +1 -1
- package/lib/events/AgenticaTextEvent.js +12 -1
- package/lib/events/AgenticaTextEvent.js.map +1 -1
- package/lib/functional/assertHttpLlmApplication.d.ts +4 -3
- package/lib/functional/assertHttpLlmApplication.js +9339 -9338
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateHttpLlmApplication.d.ts +5 -4
- package/lib/functional/validateHttpLlmApplication.js +19 -19
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/index.d.ts +19 -19
- package/lib/index.js +21 -21
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +19211 -18997
- package/lib/index.mjs.map +1 -1
- package/lib/internal/AgenticaDefaultPrompt.d.ts +6 -5
- package/lib/internal/AgenticaDefaultPrompt.js +39 -19
- package/lib/internal/AgenticaDefaultPrompt.js.map +1 -1
- package/lib/internal/AgenticaOperationComposer.d.ts +11 -10
- package/lib/internal/AgenticaOperationComposer.js +60 -59
- package/lib/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/internal/AgenticaSystemPrompt.d.ts +8 -8
- package/lib/internal/AgenticaSystemPrompt.js +9 -9
- package/lib/internal/AgenticaSystemPrompt.js.map +1 -1
- package/lib/internal/AsyncQueue.d.ts +15 -0
- package/lib/internal/AsyncQueue.js +82 -0
- package/lib/internal/AsyncQueue.js.map +1 -0
- package/lib/internal/ByteArrayUtil.d.ts +1 -1
- package/lib/internal/ByteArrayUtil.js +3 -2
- package/lib/internal/ByteArrayUtil.js.map +1 -1
- package/lib/internal/MPSC.d.ts +10 -0
- package/lib/internal/MPSC.js +49 -0
- package/lib/internal/MPSC.js.map +1 -0
- package/lib/internal/Singleton.js +6 -5
- package/lib/internal/Singleton.js.map +1 -1
- package/lib/internal/StreamUtil.d.ts +16 -6
- package/lib/internal/StreamUtil.js +43 -29
- package/lib/internal/StreamUtil.js.map +1 -1
- package/lib/internal/__map_take.js +5 -5
- package/lib/internal/__map_take.js.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +7 -7
- package/lib/json/IAgenticaOperationSelectionJson.d.ts +1 -1
- package/lib/json/IAgenticaPromptJson.d.ts +2 -2
- package/lib/prompts/AgenticaCancelPrompt.d.ts +3 -3
- package/lib/prompts/AgenticaCancelPrompt.js +1 -1
- package/lib/prompts/AgenticaCancelPrompt.js.map +1 -1
- package/lib/prompts/AgenticaDescribePrompt.d.ts +3 -3
- package/lib/prompts/AgenticaDescribePrompt.js +1 -1
- package/lib/prompts/AgenticaDescribePrompt.js.map +1 -1
- package/lib/prompts/AgenticaExecutePrompt.d.ts +5 -5
- package/lib/prompts/AgenticaExecutePrompt.js.map +1 -1
- package/lib/prompts/AgenticaPrompt.d.ts +6 -6
- package/lib/prompts/AgenticaSelectPrompt.d.ts +3 -3
- package/lib/prompts/AgenticaSelectPrompt.js +1 -1
- package/lib/prompts/AgenticaSelectPrompt.js.map +1 -1
- package/lib/prompts/AgenticaTextPrompt.d.ts +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +5 -5
- package/lib/structures/IAgenticaController.d.ts +1 -1
- package/lib/structures/IAgenticaExecutor.d.ts +4 -4
- package/lib/structures/IAgenticaProps.d.ts +5 -5
- package/lib/structures/IAgenticaSystemPrompt.d.ts +4 -4
- package/lib/structures/IAgenticaVendor.d.ts +1 -1
- package/lib/transformers/AgenticaEventTransformer.d.ts +55 -37
- package/lib/transformers/AgenticaEventTransformer.js +105 -58
- package/lib/transformers/AgenticaEventTransformer.js.map +1 -1
- package/lib/transformers/AgenticaPromptTransformer.d.ts +35 -29
- package/lib/transformers/AgenticaPromptTransformer.js +74 -45
- package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
- package/package.json +20 -23
- package/prompts/cancel.md +1 -1
- package/prompts/common.md +1 -1
- package/prompts/describe.md +1 -1
- package/prompts/execute.md +1 -1
- package/prompts/initialize.md +1 -1
- package/prompts/select.md +1 -1
- package/src/Agentica.ts +41 -31
- package/src/chatgpt/ChatGptAgent.ts +63 -57
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +363 -337
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +188 -164
- package/src/chatgpt/ChatGptCompletionMessageUtil.ts +136 -137
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +105 -101
- package/src/chatgpt/ChatGptHistoryDecoder.ts +69 -65
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +128 -123
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +215 -189
- package/src/chatgpt/ChatGptUsageAggregator.ts +49 -54
- package/src/context/AgenticaCancelPrompt.ts +4 -4
- package/src/context/AgenticaClassOperation.ts +5 -5
- package/src/context/AgenticaContext.ts +15 -15
- package/src/context/AgenticaHttpOperation.ts +5 -5
- package/src/context/AgenticaOperation.ts +4 -4
- package/src/context/AgenticaOperationBase.ts +1 -1
- package/src/context/AgenticaOperationCollection.ts +2 -2
- package/src/context/AgenticaOperationSelection.ts +3 -3
- package/src/context/AgenticaTokenUsage.ts +4 -3
- package/src/context/internal/AgenticaTokenUsageAggregator.ts +59 -59
- package/src/context/internal/__IChatCancelFunctionsApplication.ts +2 -2
- package/src/context/internal/__IChatInitialApplication.ts +2 -2
- package/src/context/internal/__IChatSelectFunctionsApplication.ts +2 -2
- package/src/events/AgenticaCallEvent.ts +3 -3
- package/src/events/AgenticaCancelEvent.ts +3 -3
- package/src/events/AgenticaDescribeEvent.ts +5 -5
- package/src/events/AgenticaEvent.ts +12 -12
- package/src/events/AgenticaExecuteEvent.ts +7 -7
- package/src/events/AgenticaInitializeEvent.ts +1 -1
- package/src/events/AgenticaRequestEvent.ts +3 -3
- package/src/events/AgenticaResponseEvent.ts +2 -2
- package/src/events/AgenticaSelectEvent.ts +4 -4
- package/src/events/AgenticaTextEvent.ts +2 -2
- package/src/functional/assertHttpLlmApplication.ts +9 -6
- package/src/functional/validateHttpLlmApplication.ts +14 -8
- package/src/index.ts +24 -24
- package/src/internal/AgenticaDefaultPrompt.ts +42 -28
- package/src/internal/AgenticaOperationComposer.ts +63 -61
- package/src/internal/AgenticaSystemPrompt.ts +15 -14
- package/src/internal/AsyncQueue.ts +67 -0
- package/src/internal/ByteArrayUtil.ts +2 -2
- package/src/internal/MPSC.ts +40 -0
- package/src/internal/Singleton.ts +8 -6
- package/src/internal/StreamUtil.ts +62 -53
- package/src/internal/__map_take.ts +5 -7
- package/src/json/IAgenticaEventJson.ts +7 -8
- package/src/json/IAgenticaOperationSelectionJson.ts +1 -1
- package/src/json/IAgenticaPromptJson.ts +2 -2
- package/src/prompts/AgenticaCancelPrompt.ts +4 -4
- package/src/prompts/AgenticaDescribePrompt.ts +4 -4
- package/src/prompts/AgenticaExecutePrompt.ts +6 -5
- package/src/prompts/AgenticaPrompt.ts +6 -6
- package/src/prompts/AgenticaSelectPrompt.ts +4 -4
- package/src/prompts/AgenticaTextPrompt.ts +1 -1
- package/src/structures/IAgenticaConfig.ts +5 -5
- package/src/structures/IAgenticaController.ts +14 -14
- package/src/structures/IAgenticaExecutor.ts +4 -4
- package/src/structures/IAgenticaProps.ts +5 -5
- package/src/structures/IAgenticaSystemPrompt.ts +4 -4
- package/src/structures/IAgenticaVendor.ts +1 -1
- package/src/transformers/AgenticaEventTransformer.ts +169 -136
- package/src/transformers/AgenticaPromptTransformer.ts +125 -103
- package/lib/internal/MPSCUtil.d.ts +0 -35
- package/lib/internal/MPSCUtil.js +0 -105
- package/lib/internal/MPSCUtil.js.map +0 -1
- package/src/internal/MPSCUtil.ts +0 -111
|
@@ -46,6 +46,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.ChatGptCancelFunctionAgent = void 0;
|
|
49
|
+
exports.execute = execute;
|
|
50
|
+
exports.cancelFunction = cancelFunction;
|
|
49
51
|
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
|
|
50
52
|
const typia_1 = __importDefault(require("typia"));
|
|
51
53
|
const uuid_1 = require("uuid");
|
|
@@ -58,46 +60,154 @@ const AgenticaSystemPrompt_1 = require("../internal/AgenticaSystemPrompt");
|
|
|
58
60
|
const StreamUtil_1 = require("../internal/StreamUtil");
|
|
59
61
|
const ChatGptCompletionMessageUtil_1 = require("./ChatGptCompletionMessageUtil");
|
|
60
62
|
const ChatGptHistoryDecoder_1 = require("./ChatGptHistoryDecoder");
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const CONTAINER = {
|
|
64
|
+
model: "chatgpt",
|
|
65
|
+
options: {
|
|
66
|
+
reference: false,
|
|
67
|
+
strict: false,
|
|
68
|
+
separate: null
|
|
69
|
+
},
|
|
70
|
+
functions: [
|
|
71
|
+
{
|
|
72
|
+
name: "cancelFunctions",
|
|
73
|
+
parameters: {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: {
|
|
76
|
+
functions: {
|
|
77
|
+
title: "List of target functions",
|
|
78
|
+
description: "List of target functions.",
|
|
79
|
+
type: "array",
|
|
80
|
+
items: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
reason: {
|
|
84
|
+
title: "The reason of the function selection",
|
|
85
|
+
description: "The reason of the function selection.\n\nJust write the reason why you've determined to select this function.",
|
|
86
|
+
type: "string"
|
|
87
|
+
},
|
|
88
|
+
name: {
|
|
89
|
+
title: "Name of the target function to call",
|
|
90
|
+
description: "Name of the target function to call.",
|
|
91
|
+
type: "string"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
required: [
|
|
95
|
+
"reason",
|
|
96
|
+
"name"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
required: [
|
|
102
|
+
"functions"
|
|
103
|
+
],
|
|
104
|
+
additionalProperties: false,
|
|
105
|
+
$defs: {}
|
|
106
|
+
},
|
|
107
|
+
description: "Cancel a function from the candidate list to call.\n\nIf you A.I. agent has understood that the user wants to cancel\nsome candidate functions to call from the conversation, please cancel\nthem through this function.\n\nAlso, when you A.I. find a function that has been selected by the candidate\npooling, cancel the function by calling this function. For reference, the\ncandidate pooling means that user wants only one function to call, but you A.I.\nagent selects multiple candidate functions because the A.I. agent can't specify\nonly one thing due to lack of specificity or homogeneity of candidate functions.\n\nAdditionally, if you A.I. agent wants to cancel same function multiply, you can\ndo it by assigning the same function name multiply in the `functions` property.",
|
|
108
|
+
validate: (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.functions) || _report(_exceptionable, {
|
|
109
|
+
path: _path + ".functions",
|
|
110
|
+
expected: "Array<___IChatFunctionReference>",
|
|
111
|
+
value: input.functions
|
|
112
|
+
})) && input.functions.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
113
|
+
path: _path + ".functions[" + _index2 + "]",
|
|
114
|
+
expected: "___IChatFunctionReference",
|
|
115
|
+
value: elem
|
|
116
|
+
})) && _vo1(elem, _path + ".functions[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
117
|
+
path: _path + ".functions[" + _index2 + "]",
|
|
118
|
+
expected: "___IChatFunctionReference",
|
|
119
|
+
value: elem
|
|
120
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
121
|
+
path: _path + ".functions",
|
|
122
|
+
expected: "Array<___IChatFunctionReference>",
|
|
123
|
+
value: input.functions
|
|
124
|
+
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.reason || _report(_exceptionable, {
|
|
125
|
+
path: _path + ".reason",
|
|
126
|
+
expected: "string",
|
|
127
|
+
value: input.reason
|
|
128
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
129
|
+
path: _path + ".name",
|
|
130
|
+
expected: "string",
|
|
131
|
+
value: input.name
|
|
132
|
+
})].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
|
|
133
|
+
if (false === __is(input)) {
|
|
134
|
+
errors = [];
|
|
135
|
+
_report = __typia_transform__validateReport._validateReport(errors);
|
|
136
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
137
|
+
path: _path + "",
|
|
138
|
+
expected: "__IChatFunctionReference.IProps",
|
|
139
|
+
value: input
|
|
140
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
141
|
+
path: _path + "",
|
|
142
|
+
expected: "__IChatFunctionReference.IProps",
|
|
143
|
+
value: input
|
|
144
|
+
}))(input, "$input", true);
|
|
145
|
+
const success = 0 === errors.length;
|
|
146
|
+
return success ? {
|
|
147
|
+
success,
|
|
148
|
+
data: input
|
|
149
|
+
} : {
|
|
150
|
+
success,
|
|
151
|
+
errors,
|
|
152
|
+
data: input
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
data: input
|
|
158
|
+
};
|
|
159
|
+
}; })()
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
function execute(ctx) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
165
|
var _a, _b;
|
|
65
|
-
if (ctx.operations.divided === undefined)
|
|
166
|
+
if (ctx.operations.divided === undefined) {
|
|
66
167
|
return step(ctx, ctx.operations.array, 0);
|
|
168
|
+
}
|
|
67
169
|
const stacks = ctx.operations.divided.map(() => []);
|
|
68
170
|
const events = [];
|
|
69
|
-
const prompts = yield Promise.all(ctx.operations.divided.map((operations, i) =>
|
|
70
|
-
|
|
71
|
-
|
|
171
|
+
const prompts = yield Promise.all(ctx.operations.divided.map((operations, i) => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
return step(Object.assign(Object.assign({}, ctx), { stack: stacks[i], dispatch: (e) => __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
events.push(e);
|
|
174
|
+
}) }), operations, 0);
|
|
175
|
+
})));
|
|
72
176
|
// NO FUNCTION SELECTION, SO THAT ONLY TEXT LEFT
|
|
73
|
-
if (stacks.every(
|
|
177
|
+
if (stacks.every(s => s.length === 0)) {
|
|
74
178
|
return prompts[0];
|
|
179
|
+
}
|
|
75
180
|
// ELITICISM
|
|
76
|
-
else if (((_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.eliticism) !== null && _b !== void 0 ? _b : AgenticaConstant_1.AgenticaConstant.ELITICISM) === true)
|
|
181
|
+
else if (((_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.eliticism) !== null && _b !== void 0 ? _b : AgenticaConstant_1.AgenticaConstant.ELITICISM) === true) {
|
|
77
182
|
return step(ctx, stacks
|
|
78
183
|
.flat()
|
|
79
|
-
.map(
|
|
184
|
+
.map(s => ctx.operations.group
|
|
80
185
|
.get(s.operation.controller.name)
|
|
81
186
|
.get(s.operation.function.name)), 0);
|
|
187
|
+
}
|
|
82
188
|
// RE-COLLECT SELECT FUNCTION EVENTS
|
|
83
189
|
const collection = new AgenticaCancelPrompt_1.AgenticaCancelPrompt({
|
|
84
190
|
id: (0, uuid_1.v4)(),
|
|
85
191
|
selections: [],
|
|
86
192
|
});
|
|
87
|
-
for (const e of events)
|
|
193
|
+
for (const e of events) {
|
|
88
194
|
if (e.type === "select") {
|
|
89
195
|
collection.selections.push(e.selection);
|
|
90
|
-
yield
|
|
196
|
+
yield cancelFunction(ctx, {
|
|
91
197
|
name: e.selection.operation.name,
|
|
92
198
|
reason: e.selection.reason,
|
|
93
199
|
});
|
|
94
200
|
}
|
|
201
|
+
}
|
|
95
202
|
return [collection];
|
|
96
203
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
204
|
+
}
|
|
205
|
+
function cancelFunction(ctx, reference) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const index = ctx.stack.findIndex(item => item.operation.name === reference.name);
|
|
208
|
+
if (index === -1) {
|
|
100
209
|
return null;
|
|
210
|
+
}
|
|
101
211
|
const item = ctx.stack[index];
|
|
102
212
|
ctx.stack.splice(index, 1);
|
|
103
213
|
yield ctx.dispatch(new AgenticaCancelEvent_1.AgenticaCancelEvent({
|
|
@@ -108,11 +218,13 @@ var ChatGptCancelFunctionAgent;
|
|
|
108
218
|
}));
|
|
109
219
|
return item;
|
|
110
220
|
});
|
|
111
|
-
|
|
221
|
+
}
|
|
222
|
+
function step(ctx, operations, retry, failures) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
224
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
113
|
-
|
|
225
|
+
// ----
|
|
114
226
|
// EXECUTE CHATGPT API
|
|
115
|
-
|
|
227
|
+
// ----
|
|
116
228
|
const completionStream = yield ctx.request("cancel", {
|
|
117
229
|
messages: [
|
|
118
230
|
// COMMON SYSTEM PROMPT
|
|
@@ -137,7 +249,7 @@ var ChatGptCancelFunctionAgent;
|
|
|
137
249
|
{
|
|
138
250
|
role: "tool",
|
|
139
251
|
tool_call_id: "getApiFunctions",
|
|
140
|
-
content: JSON.stringify(operations.map(
|
|
252
|
+
content: JSON.stringify(operations.map(op => (Object.assign({ name: op.name, description: op.function.description }, (op.protocol === "http"
|
|
141
253
|
? {
|
|
142
254
|
method: op.function.method,
|
|
143
255
|
path: op.function.path,
|
|
@@ -161,11 +273,15 @@ var ChatGptCancelFunctionAgent;
|
|
|
161
273
|
...emendMessages(failures !== null && failures !== void 0 ? failures : []),
|
|
162
274
|
],
|
|
163
275
|
// STACK FUNCTIONS
|
|
164
|
-
tools: CONTAINER.functions.map(
|
|
276
|
+
tools: CONTAINER.functions.map(func => ({
|
|
165
277
|
type: "function",
|
|
166
278
|
function: {
|
|
167
279
|
name: func.name,
|
|
168
280
|
description: func.description,
|
|
281
|
+
/**
|
|
282
|
+
* @TODO fix it
|
|
283
|
+
* The property and value have a type mismatch, but it works.
|
|
284
|
+
*/
|
|
169
285
|
parameters: func.parameters,
|
|
170
286
|
},
|
|
171
287
|
})),
|
|
@@ -174,15 +290,16 @@ var ChatGptCancelFunctionAgent;
|
|
|
174
290
|
});
|
|
175
291
|
const chunks = yield StreamUtil_1.StreamUtil.readAll(completionStream);
|
|
176
292
|
const completion = ChatGptCompletionMessageUtil_1.ChatGptCompletionMessageUtil.merge(chunks);
|
|
177
|
-
|
|
293
|
+
// ----
|
|
178
294
|
// VALIDATION
|
|
179
|
-
|
|
295
|
+
// ----
|
|
180
296
|
if (retry++ < ((_f = (_e = ctx.config) === null || _e === void 0 ? void 0 : _e.retry) !== null && _f !== void 0 ? _f : AgenticaConstant_1.AgenticaConstant.RETRY)) {
|
|
181
297
|
const failures = [];
|
|
182
|
-
for (const choice of completion.choices)
|
|
298
|
+
for (const choice of completion.choices) {
|
|
183
299
|
for (const tc of (_g = choice.message.tool_calls) !== null && _g !== void 0 ? _g : []) {
|
|
184
|
-
if (tc.function.name !== "cancelFunctions")
|
|
300
|
+
if (tc.function.name !== "cancelFunctions") {
|
|
185
301
|
continue;
|
|
302
|
+
}
|
|
186
303
|
const input = JSON.parse(tc.function.arguments);
|
|
187
304
|
const validation = (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.functions) || _report(_exceptionable, {
|
|
188
305
|
path: _path + ".functions",
|
|
@@ -236,48 +353,59 @@ var ChatGptCancelFunctionAgent;
|
|
|
236
353
|
data: input
|
|
237
354
|
};
|
|
238
355
|
}; })()(input);
|
|
239
|
-
if (validation.success === false)
|
|
356
|
+
if (validation.success === false) {
|
|
240
357
|
failures.push({
|
|
241
358
|
id: tc.id,
|
|
242
359
|
name: tc.function.name,
|
|
243
360
|
validation,
|
|
244
361
|
});
|
|
362
|
+
}
|
|
245
363
|
}
|
|
246
|
-
|
|
364
|
+
}
|
|
365
|
+
if (failures.length > 0) {
|
|
247
366
|
return step(ctx, operations, retry, failures);
|
|
367
|
+
}
|
|
248
368
|
}
|
|
249
|
-
|
|
369
|
+
// ----
|
|
250
370
|
// PROCESS COMPLETION
|
|
251
|
-
|
|
371
|
+
// ----
|
|
252
372
|
const prompts = [];
|
|
253
373
|
for (const choice of completion.choices) {
|
|
254
374
|
// TOOL CALLING HANDLER
|
|
255
|
-
if (choice.message.tool_calls)
|
|
375
|
+
if (choice.message.tool_calls != null) {
|
|
256
376
|
for (const tc of choice.message.tool_calls) {
|
|
257
|
-
if (tc.type !== "function")
|
|
377
|
+
if (tc.type !== "function") {
|
|
258
378
|
continue;
|
|
259
|
-
|
|
260
|
-
if (
|
|
379
|
+
}
|
|
380
|
+
if (tc.function.name !== "cancelFunctions") {
|
|
261
381
|
continue;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
382
|
+
}
|
|
383
|
+
const input = (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const __is = input => "object" === typeof input && null !== input && _io0(input); return input => { input = JSON.parse(input); return __is(input) ? input : null; }; })()(tc.function.arguments);
|
|
384
|
+
if (input === null) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const collection = new AgenticaCancelPrompt_1.AgenticaCancelPrompt({
|
|
388
|
+
id: tc.id,
|
|
389
|
+
selections: [],
|
|
390
|
+
});
|
|
391
|
+
for (const reference of input.functions) {
|
|
392
|
+
const operation = yield cancelFunction(ctx, reference);
|
|
393
|
+
if (operation !== null) {
|
|
394
|
+
collection.selections.push(operation);
|
|
271
395
|
}
|
|
272
|
-
|
|
273
|
-
|
|
396
|
+
}
|
|
397
|
+
if (collection.selections.length !== 0) {
|
|
398
|
+
prompts.push(collection);
|
|
274
399
|
}
|
|
275
400
|
}
|
|
401
|
+
}
|
|
276
402
|
}
|
|
277
403
|
return prompts;
|
|
278
404
|
});
|
|
279
|
-
|
|
280
|
-
|
|
405
|
+
}
|
|
406
|
+
function emendMessages(failures) {
|
|
407
|
+
return failures
|
|
408
|
+
.map(f => [
|
|
281
409
|
{
|
|
282
410
|
role: "assistant",
|
|
283
411
|
tool_calls: [
|
|
@@ -306,105 +434,9 @@ var ChatGptCancelFunctionAgent;
|
|
|
306
434
|
},
|
|
307
435
|
])
|
|
308
436
|
.flat();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
reference: false,
|
|
314
|
-
strict: false,
|
|
315
|
-
separate: null
|
|
316
|
-
},
|
|
317
|
-
functions: [
|
|
318
|
-
{
|
|
319
|
-
name: "cancelFunctions",
|
|
320
|
-
parameters: {
|
|
321
|
-
type: "object",
|
|
322
|
-
properties: {
|
|
323
|
-
functions: {
|
|
324
|
-
title: "List of target functions",
|
|
325
|
-
description: "List of target functions.",
|
|
326
|
-
type: "array",
|
|
327
|
-
items: {
|
|
328
|
-
type: "object",
|
|
329
|
-
properties: {
|
|
330
|
-
reason: {
|
|
331
|
-
title: "The reason of the function selection",
|
|
332
|
-
description: "The reason of the function selection.\n\nJust write the reason why you've determined to select this function.",
|
|
333
|
-
type: "string"
|
|
334
|
-
},
|
|
335
|
-
name: {
|
|
336
|
-
title: "Name of the target function to call",
|
|
337
|
-
description: "Name of the target function to call.",
|
|
338
|
-
type: "string"
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
required: [
|
|
342
|
-
"reason",
|
|
343
|
-
"name"
|
|
344
|
-
]
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
required: [
|
|
349
|
-
"functions"
|
|
350
|
-
],
|
|
351
|
-
additionalProperties: false,
|
|
352
|
-
$defs: {}
|
|
353
|
-
},
|
|
354
|
-
description: "Cancel a function from the candidate list to call.\n\nIf you A.I. agent has understood that the user wants to cancel\nsome candidate functions to call from the conversation, please cancel\nthem through this function.\n\nAlso, when you A.I. find a function that has been selected by the candidate\npooling, cancel the function by calling this function. For reference, the\ncandidate pooling means that user wants only one function to call, but you A.I.\nagent selects multiple candidate functions because the A.I. agent can't specify\nonly one thing due to lack of specificity or homogeneity of candidate functions.\n\nAdditionally, if you A.I. agent wants to cancel same function multiply, you can\ndo it by assigning the same function name multiply in the `functions` property.",
|
|
355
|
-
validate: (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.functions) || _report(_exceptionable, {
|
|
356
|
-
path: _path + ".functions",
|
|
357
|
-
expected: "Array<___IChatFunctionReference>",
|
|
358
|
-
value: input.functions
|
|
359
|
-
})) && input.functions.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
360
|
-
path: _path + ".functions[" + _index2 + "]",
|
|
361
|
-
expected: "___IChatFunctionReference",
|
|
362
|
-
value: elem
|
|
363
|
-
})) && _vo1(elem, _path + ".functions[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
364
|
-
path: _path + ".functions[" + _index2 + "]",
|
|
365
|
-
expected: "___IChatFunctionReference",
|
|
366
|
-
value: elem
|
|
367
|
-
})).every(flag => flag) || _report(_exceptionable, {
|
|
368
|
-
path: _path + ".functions",
|
|
369
|
-
expected: "Array<___IChatFunctionReference>",
|
|
370
|
-
value: input.functions
|
|
371
|
-
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.reason || _report(_exceptionable, {
|
|
372
|
-
path: _path + ".reason",
|
|
373
|
-
expected: "string",
|
|
374
|
-
value: input.reason
|
|
375
|
-
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
376
|
-
path: _path + ".name",
|
|
377
|
-
expected: "string",
|
|
378
|
-
value: input.name
|
|
379
|
-
})].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
|
|
380
|
-
if (false === __is(input)) {
|
|
381
|
-
errors = [];
|
|
382
|
-
_report = __typia_transform__validateReport._validateReport(errors);
|
|
383
|
-
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
384
|
-
path: _path + "",
|
|
385
|
-
expected: "__IChatFunctionReference.IProps",
|
|
386
|
-
value: input
|
|
387
|
-
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
388
|
-
path: _path + "",
|
|
389
|
-
expected: "__IChatFunctionReference.IProps",
|
|
390
|
-
value: input
|
|
391
|
-
}))(input, "$input", true);
|
|
392
|
-
const success = 0 === errors.length;
|
|
393
|
-
return success ? {
|
|
394
|
-
success,
|
|
395
|
-
data: input
|
|
396
|
-
} : {
|
|
397
|
-
success,
|
|
398
|
-
errors,
|
|
399
|
-
data: input
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
return {
|
|
403
|
-
success: true,
|
|
404
|
-
data: input
|
|
405
|
-
};
|
|
406
|
-
}; })()
|
|
407
|
-
}
|
|
408
|
-
]
|
|
437
|
+
}
|
|
438
|
+
exports.ChatGptCancelFunctionAgent = {
|
|
439
|
+
execute,
|
|
440
|
+
cancelFunction,
|
|
409
441
|
};
|
|
410
442
|
//# sourceMappingURL=ChatGptCancelFunctionAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatGptCancelFunctionAgent.js","sourceRoot":"","sources":["../../src/chatgpt/ChatGptCancelFunctionAgent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatGptCancelFunctionAgent.js","sourceRoot":"","sources":["../../src/chatgpt/ChatGptCancelFunctionAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;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;YACjB,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,UAAU;oBAChB,EAAE,EAAE,CAAC,CAAC,EAAE;oBACR,QAAQ,EAAE;wBACR,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;qBAC7C;iBACF;aACF;SACmD;QACtD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;YAC5C,YAAY,EAAE,CAAC,CAAC,EAAE;SAC6B;QACjD;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,wDAAwD;gBACxD,EAAE;gBACF,0CAA0C;aAC3C,CAAC,IAAI,CAAC,IAAI,CAAC;SACqC;KACtD,CAAC;SACD,IAAI,EAAE,CAAC;AACZ,CAAC;AAEY,QAAA,0BAA0B,GAAG;IACxC,OAAO;IACP,cAAc;CACf,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { ChatCompletion, ChatCompletionChunk, ChatCompletionMessageToolCall } from "openai/resources";
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { ChatCompletion, ChatCompletionChunk, ChatCompletionMessageToolCall } from "openai/resources";
|
|
2
|
+
export declare function transformCompletionChunk(source: string | Uint8Array): ChatCompletionChunk;
|
|
3
|
+
export declare function accumulate(origin: ChatCompletion, chunk: ChatCompletionChunk): ChatCompletion;
|
|
4
|
+
export declare function merge(chunks: ChatCompletionChunk[]): ChatCompletion;
|
|
5
|
+
export declare function mergeChoice(acc: ChatCompletion.Choice, cur: ChatCompletionChunk.Choice): ChatCompletion.Choice;
|
|
6
|
+
export declare function mergeToolCalls(acc: ChatCompletionMessageToolCall, cur: ChatCompletionChunk.Choice.Delta.ToolCall): ChatCompletionMessageToolCall;
|
|
7
|
+
export declare const ChatGptCompletionMessageUtil: {
|
|
8
|
+
transformCompletionChunk: typeof transformCompletionChunk;
|
|
9
|
+
accumulate: typeof accumulate;
|
|
10
|
+
merge: typeof merge;
|
|
11
|
+
mergeChoice: typeof mergeChoice;
|
|
12
|
+
mergeToolCalls: typeof mergeToolCalls;
|
|
13
|
+
};
|