@agentica/core 0.16.4 → 0.16.7-fix-for-wrtn
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/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +17 -426
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/call.js +13 -18
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +3 -2
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/execute.js +0 -7
- package/lib/orchestrate/execute.js.map +1 -1
- package/lib/orchestrate/internal/cancelFunction.js +13 -24
- package/lib/orchestrate/internal/cancelFunction.js.map +1 -1
- package/lib/utils/ChatGptCompletionMessageUtil.js +7 -407
- package/lib/utils/ChatGptCompletionMessageUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/orchestrate/call.ts +15 -22
- package/src/orchestrate/cancel.ts +3 -2
- package/src/orchestrate/execute.ts +0 -7
- package/src/orchestrate/internal/cancelFunction.ts +4 -4
- package/src/utils/ChatGptCompletionMessageUtil.ts +7 -6
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.cancelFunction = cancelFunction;
|
|
13
4
|
const events_1 = require("../../factory/events");
|
|
@@ -16,20 +7,18 @@ const operations_1 = require("../../factory/operations");
|
|
|
16
7
|
* @internal
|
|
17
8
|
*/
|
|
18
9
|
function cancelFunction(ctx, reference) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return item;
|
|
33
|
-
});
|
|
10
|
+
const index = ctx.stack.findIndex(item => item.operation.name === reference.name);
|
|
11
|
+
if (index === -1) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const item = ctx.stack[index];
|
|
15
|
+
ctx.stack.splice(index, 1);
|
|
16
|
+
ctx.dispatch((0, events_1.createCancelEvent)({
|
|
17
|
+
selection: (0, operations_1.createOperationSelection)({
|
|
18
|
+
operation: item.operation,
|
|
19
|
+
reason: reference.reason,
|
|
20
|
+
}),
|
|
21
|
+
})).catch(() => { });
|
|
22
|
+
return item;
|
|
34
23
|
}
|
|
35
24
|
//# sourceMappingURL=cancelFunction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelFunction.js","sourceRoot":"","sources":["../../../src/orchestrate/internal/cancelFunction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cancelFunction.js","sourceRoot":"","sources":["../../../src/orchestrate/internal/cancelFunction.ts"],"names":[],"mappings":";;AAYA,wCAsBC;AA5BD,iDAAyD;AACzD,yDAAoE;AAEpE;;GAEG;AACH,SAAgB,cAAc,CAC5B,GAA2B,EAC3B,SAAmC;IAEnC,MAAM,KAAK,GAAW,GAAG,CAAC,KAAK,CAAC,SAAS,CACvC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAC/C,CAAC;IACF,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAsC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;IAClE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3B,GAAG,CAAC,QAAQ,CACV,IAAA,0BAAiB,EAAC;QAChB,SAAS,EAAE,IAAA,qCAAwB,EAAC;YAClC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB,CAAC;KACH,CAAC,CACH,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,417 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.ChatGptCompletionMessageUtil = void 0;
|
|
37
|
-
|
|
38
|
-
const typia_1 = require("typia");
|
|
4
|
+
// import typia from "typia";
|
|
39
5
|
const ByteArrayUtil_1 = require("./ByteArrayUtil");
|
|
40
6
|
const ChatGptTokenUsageAggregator_1 = require("./ChatGptTokenUsageAggregator");
|
|
41
7
|
function transformCompletionChunk(source) {
|
|
42
8
|
const str = source instanceof Uint8Array ? ByteArrayUtil_1.ByteArrayUtil.toUtf8(source) : source;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
method: "json.assertParse",
|
|
50
|
-
path: _path + ".choices",
|
|
51
|
-
expected: "Array<ChatCompletionChunk.Choice>",
|
|
52
|
-
value: input.choices
|
|
53
|
-
}, _errorFactory)) && input.choices.every((elem, _index8) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
54
|
-
method: "json.assertParse",
|
|
55
|
-
path: _path + ".choices[" + _index8 + "]",
|
|
56
|
-
expected: "ChatCompletionChunk.Choice",
|
|
57
|
-
value: elem
|
|
58
|
-
}, _errorFactory)) && _ao1(elem, _path + ".choices[" + _index8 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
59
|
-
method: "json.assertParse",
|
|
60
|
-
path: _path + ".choices[" + _index8 + "]",
|
|
61
|
-
expected: "ChatCompletionChunk.Choice",
|
|
62
|
-
value: elem
|
|
63
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
64
|
-
method: "json.assertParse",
|
|
65
|
-
path: _path + ".choices",
|
|
66
|
-
expected: "Array<ChatCompletionChunk.Choice>",
|
|
67
|
-
value: input.choices
|
|
68
|
-
}, _errorFactory)) && ("number" === typeof input.created || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
69
|
-
method: "json.assertParse",
|
|
70
|
-
path: _path + ".created",
|
|
71
|
-
expected: "number",
|
|
72
|
-
value: input.created
|
|
73
|
-
}, _errorFactory)) && ("string" === typeof input.model || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
74
|
-
method: "json.assertParse",
|
|
75
|
-
path: _path + ".model",
|
|
76
|
-
expected: "string",
|
|
77
|
-
value: input.model
|
|
78
|
-
}, _errorFactory)) && ("chat.completion.chunk" === input.object || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
79
|
-
method: "json.assertParse",
|
|
80
|
-
path: _path + ".object",
|
|
81
|
-
expected: "\"chat.completion.chunk\"",
|
|
82
|
-
value: input.object
|
|
83
|
-
}, _errorFactory)) && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
84
|
-
method: "json.assertParse",
|
|
85
|
-
path: _path + ".service_tier",
|
|
86
|
-
expected: "(\"default\" | \"scale\" | null | undefined)",
|
|
87
|
-
value: input.service_tier
|
|
88
|
-
}, _errorFactory)) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
89
|
-
method: "json.assertParse",
|
|
90
|
-
path: _path + ".system_fingerprint",
|
|
91
|
-
expected: "(string | undefined)",
|
|
92
|
-
value: input.system_fingerprint
|
|
93
|
-
}, _errorFactory)) && (null === input.usage || undefined === input.usage || ("object" === typeof input.usage && null !== input.usage || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
94
|
-
method: "json.assertParse",
|
|
95
|
-
path: _path + ".usage",
|
|
96
|
-
expected: "(CompletionUsage | null | undefined)",
|
|
97
|
-
value: input.usage
|
|
98
|
-
}, _errorFactory)) && _ao9(input.usage, _path + ".usage", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
99
|
-
method: "json.assertParse",
|
|
100
|
-
path: _path + ".usage",
|
|
101
|
-
expected: "(CompletionUsage | null | undefined)",
|
|
102
|
-
value: input.usage
|
|
103
|
-
}, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => (("object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
104
|
-
method: "json.assertParse",
|
|
105
|
-
path: _path + ".delta",
|
|
106
|
-
expected: "ChatCompletionChunk.Choice.Delta",
|
|
107
|
-
value: input.delta
|
|
108
|
-
}, _errorFactory)) && _ao2(input.delta, _path + ".delta", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
109
|
-
method: "json.assertParse",
|
|
110
|
-
path: _path + ".delta",
|
|
111
|
-
expected: "ChatCompletionChunk.Choice.Delta",
|
|
112
|
-
value: input.delta
|
|
113
|
-
}, _errorFactory)) && (null === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "length" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
114
|
-
method: "json.assertParse",
|
|
115
|
-
path: _path + ".finish_reason",
|
|
116
|
-
expected: "(\"content_filter\" | \"function_call\" | \"length\" | \"stop\" | \"tool_calls\" | null)",
|
|
117
|
-
value: input.finish_reason
|
|
118
|
-
}, _errorFactory)) && ("number" === typeof input.index || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
119
|
-
method: "json.assertParse",
|
|
120
|
-
path: _path + ".index",
|
|
121
|
-
expected: "number",
|
|
122
|
-
value: input.index
|
|
123
|
-
}, _errorFactory)) && (null === input.logprobs || undefined === input.logprobs || ("object" === typeof input.logprobs && null !== input.logprobs || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
124
|
-
method: "json.assertParse",
|
|
125
|
-
path: _path + ".logprobs",
|
|
126
|
-
expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
|
|
127
|
-
value: input.logprobs
|
|
128
|
-
}, _errorFactory)) && _ao6(input.logprobs, _path + ".logprobs", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
129
|
-
method: "json.assertParse",
|
|
130
|
-
path: _path + ".logprobs",
|
|
131
|
-
expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
|
|
132
|
-
value: input.logprobs
|
|
133
|
-
}, _errorFactory)); const _ao2 = (input, _path, _exceptionable = true) => (null === input.content || undefined === input.content || "string" === typeof input.content || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
134
|
-
method: "json.assertParse",
|
|
135
|
-
path: _path + ".content",
|
|
136
|
-
expected: "(null | string | undefined)",
|
|
137
|
-
value: input.content
|
|
138
|
-
}, _errorFactory)) && (undefined === input.function_call || ("object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
139
|
-
method: "json.assertParse",
|
|
140
|
-
path: _path + ".function_call",
|
|
141
|
-
expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
|
|
142
|
-
value: input.function_call
|
|
143
|
-
}, _errorFactory)) && _ao3(input.function_call, _path + ".function_call", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
144
|
-
method: "json.assertParse",
|
|
145
|
-
path: _path + ".function_call",
|
|
146
|
-
expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
|
|
147
|
-
value: input.function_call
|
|
148
|
-
}, _errorFactory)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
149
|
-
method: "json.assertParse",
|
|
150
|
-
path: _path + ".refusal",
|
|
151
|
-
expected: "(null | string | undefined)",
|
|
152
|
-
value: input.refusal
|
|
153
|
-
}, _errorFactory)) && (undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
154
|
-
method: "json.assertParse",
|
|
155
|
-
path: _path + ".role",
|
|
156
|
-
expected: "(\"assistant\" | \"developer\" | \"system\" | \"tool\" | \"user\" | undefined)",
|
|
157
|
-
value: input.role
|
|
158
|
-
}, _errorFactory)) && (undefined === input.tool_calls || (Array.isArray(input.tool_calls) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
159
|
-
method: "json.assertParse",
|
|
160
|
-
path: _path + ".tool_calls",
|
|
161
|
-
expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
|
|
162
|
-
value: input.tool_calls
|
|
163
|
-
}, _errorFactory)) && input.tool_calls.every((elem, _index9) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
164
|
-
method: "json.assertParse",
|
|
165
|
-
path: _path + ".tool_calls[" + _index9 + "]",
|
|
166
|
-
expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
|
|
167
|
-
value: elem
|
|
168
|
-
}, _errorFactory)) && _ao4(elem, _path + ".tool_calls[" + _index9 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
169
|
-
method: "json.assertParse",
|
|
170
|
-
path: _path + ".tool_calls[" + _index9 + "]",
|
|
171
|
-
expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
|
|
172
|
-
value: elem
|
|
173
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
174
|
-
method: "json.assertParse",
|
|
175
|
-
path: _path + ".tool_calls",
|
|
176
|
-
expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
|
|
177
|
-
value: input.tool_calls
|
|
178
|
-
}, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => (undefined === input.arguments || "string" === typeof input.arguments || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
179
|
-
method: "json.assertParse",
|
|
180
|
-
path: _path + ".arguments",
|
|
181
|
-
expected: "(string | undefined)",
|
|
182
|
-
value: input.arguments
|
|
183
|
-
}, _errorFactory)) && (undefined === input.name || "string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
184
|
-
method: "json.assertParse",
|
|
185
|
-
path: _path + ".name",
|
|
186
|
-
expected: "(string | undefined)",
|
|
187
|
-
value: input.name
|
|
188
|
-
}, _errorFactory)); const _ao4 = (input, _path, _exceptionable = true) => ("number" === typeof input.index || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
189
|
-
method: "json.assertParse",
|
|
190
|
-
path: _path + ".index",
|
|
191
|
-
expected: "number",
|
|
192
|
-
value: input.index
|
|
193
|
-
}, _errorFactory)) && (undefined === input.id || "string" === typeof input.id || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
194
|
-
method: "json.assertParse",
|
|
195
|
-
path: _path + ".id",
|
|
196
|
-
expected: "(string | undefined)",
|
|
197
|
-
value: input.id
|
|
198
|
-
}, _errorFactory)) && (undefined === input["function"] || ("object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
199
|
-
method: "json.assertParse",
|
|
200
|
-
path: _path + "[\"function\"]",
|
|
201
|
-
expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
|
|
202
|
-
value: input["function"]
|
|
203
|
-
}, _errorFactory)) && _ao5(input["function"], _path + "[\"function\"]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
204
|
-
method: "json.assertParse",
|
|
205
|
-
path: _path + "[\"function\"]",
|
|
206
|
-
expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
|
|
207
|
-
value: input["function"]
|
|
208
|
-
}, _errorFactory)) && (undefined === input.type || "function" === input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
209
|
-
method: "json.assertParse",
|
|
210
|
-
path: _path + ".type",
|
|
211
|
-
expected: "(\"function\" | undefined)",
|
|
212
|
-
value: input.type
|
|
213
|
-
}, _errorFactory)); const _ao5 = (input, _path, _exceptionable = true) => (undefined === input.arguments || "string" === typeof input.arguments || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
214
|
-
method: "json.assertParse",
|
|
215
|
-
path: _path + ".arguments",
|
|
216
|
-
expected: "(string | undefined)",
|
|
217
|
-
value: input.arguments
|
|
218
|
-
}, _errorFactory)) && (undefined === input.name || "string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
219
|
-
method: "json.assertParse",
|
|
220
|
-
path: _path + ".name",
|
|
221
|
-
expected: "(string | undefined)",
|
|
222
|
-
value: input.name
|
|
223
|
-
}, _errorFactory)); const _ao6 = (input, _path, _exceptionable = true) => (null === input.content || (Array.isArray(input.content) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
224
|
-
method: "json.assertParse",
|
|
225
|
-
path: _path + ".content",
|
|
226
|
-
expected: "(Array<ChatCompletionTokenLogprob> | null)",
|
|
227
|
-
value: input.content
|
|
228
|
-
}, _errorFactory)) && input.content.every((elem, _index10) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
229
|
-
method: "json.assertParse",
|
|
230
|
-
path: _path + ".content[" + _index10 + "]",
|
|
231
|
-
expected: "ChatCompletionTokenLogprob",
|
|
232
|
-
value: elem
|
|
233
|
-
}, _errorFactory)) && _ao7(elem, _path + ".content[" + _index10 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
234
|
-
method: "json.assertParse",
|
|
235
|
-
path: _path + ".content[" + _index10 + "]",
|
|
236
|
-
expected: "ChatCompletionTokenLogprob",
|
|
237
|
-
value: elem
|
|
238
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
239
|
-
method: "json.assertParse",
|
|
240
|
-
path: _path + ".content",
|
|
241
|
-
expected: "(Array<ChatCompletionTokenLogprob> | null)",
|
|
242
|
-
value: input.content
|
|
243
|
-
}, _errorFactory)) && (null === input.refusal || (Array.isArray(input.refusal) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
244
|
-
method: "json.assertParse",
|
|
245
|
-
path: _path + ".refusal",
|
|
246
|
-
expected: "(Array<ChatCompletionTokenLogprob> | null)",
|
|
247
|
-
value: input.refusal
|
|
248
|
-
}, _errorFactory)) && input.refusal.every((elem, _index11) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
249
|
-
method: "json.assertParse",
|
|
250
|
-
path: _path + ".refusal[" + _index11 + "]",
|
|
251
|
-
expected: "ChatCompletionTokenLogprob",
|
|
252
|
-
value: elem
|
|
253
|
-
}, _errorFactory)) && _ao7(elem, _path + ".refusal[" + _index11 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
254
|
-
method: "json.assertParse",
|
|
255
|
-
path: _path + ".refusal[" + _index11 + "]",
|
|
256
|
-
expected: "ChatCompletionTokenLogprob",
|
|
257
|
-
value: elem
|
|
258
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
259
|
-
method: "json.assertParse",
|
|
260
|
-
path: _path + ".refusal",
|
|
261
|
-
expected: "(Array<ChatCompletionTokenLogprob> | null)",
|
|
262
|
-
value: input.refusal
|
|
263
|
-
}, _errorFactory)); const _ao7 = (input, _path, _exceptionable = true) => ("string" === typeof input.token || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
264
|
-
method: "json.assertParse",
|
|
265
|
-
path: _path + ".token",
|
|
266
|
-
expected: "string",
|
|
267
|
-
value: input.token
|
|
268
|
-
}, _errorFactory)) && (null === input.bytes || (Array.isArray(input.bytes) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
269
|
-
method: "json.assertParse",
|
|
270
|
-
path: _path + ".bytes",
|
|
271
|
-
expected: "(Array<number> | null)",
|
|
272
|
-
value: input.bytes
|
|
273
|
-
}, _errorFactory)) && input.bytes.every((elem, _index12) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
274
|
-
method: "json.assertParse",
|
|
275
|
-
path: _path + ".bytes[" + _index12 + "]",
|
|
276
|
-
expected: "number",
|
|
277
|
-
value: elem
|
|
278
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
279
|
-
method: "json.assertParse",
|
|
280
|
-
path: _path + ".bytes",
|
|
281
|
-
expected: "(Array<number> | null)",
|
|
282
|
-
value: input.bytes
|
|
283
|
-
}, _errorFactory)) && ("number" === typeof input.logprob || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
284
|
-
method: "json.assertParse",
|
|
285
|
-
path: _path + ".logprob",
|
|
286
|
-
expected: "number",
|
|
287
|
-
value: input.logprob
|
|
288
|
-
}, _errorFactory)) && ((Array.isArray(input.top_logprobs) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
289
|
-
method: "json.assertParse",
|
|
290
|
-
path: _path + ".top_logprobs",
|
|
291
|
-
expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
|
|
292
|
-
value: input.top_logprobs
|
|
293
|
-
}, _errorFactory)) && input.top_logprobs.every((elem, _index13) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
294
|
-
method: "json.assertParse",
|
|
295
|
-
path: _path + ".top_logprobs[" + _index13 + "]",
|
|
296
|
-
expected: "ChatCompletionTokenLogprob.TopLogprob",
|
|
297
|
-
value: elem
|
|
298
|
-
}, _errorFactory)) && _ao8(elem, _path + ".top_logprobs[" + _index13 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
299
|
-
method: "json.assertParse",
|
|
300
|
-
path: _path + ".top_logprobs[" + _index13 + "]",
|
|
301
|
-
expected: "ChatCompletionTokenLogprob.TopLogprob",
|
|
302
|
-
value: elem
|
|
303
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
304
|
-
method: "json.assertParse",
|
|
305
|
-
path: _path + ".top_logprobs",
|
|
306
|
-
expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
|
|
307
|
-
value: input.top_logprobs
|
|
308
|
-
}, _errorFactory)); const _ao8 = (input, _path, _exceptionable = true) => ("string" === typeof input.token || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
309
|
-
method: "json.assertParse",
|
|
310
|
-
path: _path + ".token",
|
|
311
|
-
expected: "string",
|
|
312
|
-
value: input.token
|
|
313
|
-
}, _errorFactory)) && (null === input.bytes || (Array.isArray(input.bytes) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
314
|
-
method: "json.assertParse",
|
|
315
|
-
path: _path + ".bytes",
|
|
316
|
-
expected: "(Array<number> | null)",
|
|
317
|
-
value: input.bytes
|
|
318
|
-
}, _errorFactory)) && input.bytes.every((elem, _index14) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
319
|
-
method: "json.assertParse",
|
|
320
|
-
path: _path + ".bytes[" + _index14 + "]",
|
|
321
|
-
expected: "number",
|
|
322
|
-
value: elem
|
|
323
|
-
}, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
324
|
-
method: "json.assertParse",
|
|
325
|
-
path: _path + ".bytes",
|
|
326
|
-
expected: "(Array<number> | null)",
|
|
327
|
-
value: input.bytes
|
|
328
|
-
}, _errorFactory)) && ("number" === typeof input.logprob || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
329
|
-
method: "json.assertParse",
|
|
330
|
-
path: _path + ".logprob",
|
|
331
|
-
expected: "number",
|
|
332
|
-
value: input.logprob
|
|
333
|
-
}, _errorFactory)); const _ao9 = (input, _path, _exceptionable = true) => ("number" === typeof input.completion_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
334
|
-
method: "json.assertParse",
|
|
335
|
-
path: _path + ".completion_tokens",
|
|
336
|
-
expected: "number",
|
|
337
|
-
value: input.completion_tokens
|
|
338
|
-
}, _errorFactory)) && ("number" === typeof input.prompt_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
339
|
-
method: "json.assertParse",
|
|
340
|
-
path: _path + ".prompt_tokens",
|
|
341
|
-
expected: "number",
|
|
342
|
-
value: input.prompt_tokens
|
|
343
|
-
}, _errorFactory)) && ("number" === typeof input.total_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
344
|
-
method: "json.assertParse",
|
|
345
|
-
path: _path + ".total_tokens",
|
|
346
|
-
expected: "number",
|
|
347
|
-
value: input.total_tokens
|
|
348
|
-
}, _errorFactory)) && (undefined === input.completion_tokens_details || ("object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
349
|
-
method: "json.assertParse",
|
|
350
|
-
path: _path + ".completion_tokens_details",
|
|
351
|
-
expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
|
|
352
|
-
value: input.completion_tokens_details
|
|
353
|
-
}, _errorFactory)) && _ao10(input.completion_tokens_details, _path + ".completion_tokens_details", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
354
|
-
method: "json.assertParse",
|
|
355
|
-
path: _path + ".completion_tokens_details",
|
|
356
|
-
expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
|
|
357
|
-
value: input.completion_tokens_details
|
|
358
|
-
}, _errorFactory)) && (undefined === input.prompt_tokens_details || ("object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
359
|
-
method: "json.assertParse",
|
|
360
|
-
path: _path + ".prompt_tokens_details",
|
|
361
|
-
expected: "(CompletionUsage.PromptTokensDetails | undefined)",
|
|
362
|
-
value: input.prompt_tokens_details
|
|
363
|
-
}, _errorFactory)) && _ao11(input.prompt_tokens_details, _path + ".prompt_tokens_details", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
364
|
-
method: "json.assertParse",
|
|
365
|
-
path: _path + ".prompt_tokens_details",
|
|
366
|
-
expected: "(CompletionUsage.PromptTokensDetails | undefined)",
|
|
367
|
-
value: input.prompt_tokens_details
|
|
368
|
-
}, _errorFactory)); const _ao10 = (input, _path, _exceptionable = true) => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
369
|
-
method: "json.assertParse",
|
|
370
|
-
path: _path + ".accepted_prediction_tokens",
|
|
371
|
-
expected: "(number | undefined)",
|
|
372
|
-
value: input.accepted_prediction_tokens
|
|
373
|
-
}, _errorFactory)) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
374
|
-
method: "json.assertParse",
|
|
375
|
-
path: _path + ".audio_tokens",
|
|
376
|
-
expected: "(number | undefined)",
|
|
377
|
-
value: input.audio_tokens
|
|
378
|
-
}, _errorFactory)) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
379
|
-
method: "json.assertParse",
|
|
380
|
-
path: _path + ".reasoning_tokens",
|
|
381
|
-
expected: "(number | undefined)",
|
|
382
|
-
value: input.reasoning_tokens
|
|
383
|
-
}, _errorFactory)) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
384
|
-
method: "json.assertParse",
|
|
385
|
-
path: _path + ".rejected_prediction_tokens",
|
|
386
|
-
expected: "(number | undefined)",
|
|
387
|
-
value: input.rejected_prediction_tokens
|
|
388
|
-
}, _errorFactory)); const _ao11 = (input, _path, _exceptionable = true) => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
389
|
-
method: "json.assertParse",
|
|
390
|
-
path: _path + ".audio_tokens",
|
|
391
|
-
expected: "(number | undefined)",
|
|
392
|
-
value: input.audio_tokens
|
|
393
|
-
}, _errorFactory)) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
394
|
-
method: "json.assertParse",
|
|
395
|
-
path: _path + ".cached_tokens",
|
|
396
|
-
expected: "(number | undefined)",
|
|
397
|
-
value: input.cached_tokens
|
|
398
|
-
}, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => {
|
|
399
|
-
if (false === __is(input)) {
|
|
400
|
-
_errorFactory = errorFactory;
|
|
401
|
-
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
|
|
402
|
-
method: "json.assertParse",
|
|
403
|
-
path: _path + "",
|
|
404
|
-
expected: "ChatCompletionChunk & { usage: CompletionUsage | null | undefined; }",
|
|
405
|
-
value: input
|
|
406
|
-
}, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
|
|
407
|
-
method: "json.assertParse",
|
|
408
|
-
path: _path + "",
|
|
409
|
-
expected: "ChatCompletionChunk & { usage: CompletionUsage | null | undefined; }",
|
|
410
|
-
value: input
|
|
411
|
-
}, _errorFactory))(input, "$input", true);
|
|
412
|
-
}
|
|
413
|
-
return input;
|
|
414
|
-
}; return (input, errorFactory) => __assert(JSON.parse(input), errorFactory); })()(str);
|
|
9
|
+
const result = JSON.parse(str);
|
|
10
|
+
// const valid = typia.validate<ChatCompletionChunk>(result);
|
|
11
|
+
// if (valid.success === false) {
|
|
12
|
+
// console.error("Invalid ChatCompletionChunk", valid.errors);
|
|
13
|
+
// }
|
|
14
|
+
return result;
|
|
415
15
|
}
|
|
416
16
|
function accumulate(origin, chunk) {
|
|
417
17
|
const choices = origin.choices;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatGptCompletionMessageUtil.js","sourceRoot":"","sources":["../../src/utils/ChatGptCompletionMessageUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatGptCompletionMessageUtil.js","sourceRoot":"","sources":["../../src/utils/ChatGptCompletionMessageUtil.ts"],"names":[],"mappings":";;;AAOA,6BAA6B;AAC7B,mDAAgD;AAChD,+EAA4E;AAE5E,SAAS,wBAAwB,CAAC,MAA2B;IAC3D,MAAM,GAAG,GACH,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,6BAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,MAAM,MAAM,GAAwB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAwB,CAAC;IAC3E,6DAA6D;IAC7D,iCAAiC;IACjC,gEAAgE;IAChE,IAAI;IACJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,MAAsB,EAAE,KAA0B;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;;QAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,SAAS,EAAE,M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,IAAI,EAAE,MAAA,MAAA,QAAQ,CAAC,QAAQ,0CAAE,IAAI,mCAAI,EAAE;oBACnC,SAAS,EAAE,MAAA,MAAA,QAAQ,CAAC,QAAQ,0CAAE,SAAS,mCAAI,EAAE;iBAC9C;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,cAAc,CAAC,GAAkC,EAAE,GAA8C;;IACxG,IAAI,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QACzB,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,MAAA,GAAG,CAAC,QAAQ,CAAC,SAAS,mCAAI,EAAE,CAAC;QACvD,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAA,GAAG,CAAC,QAAQ,CAAC,IAAI,mCAAI,EAAE,CAAC;IAC/C,CAAC;IAED,GAAG,CAAC,EAAE,IAAI,MAAA,GAAG,CAAC,EAAE,mCAAI,EAAE,CAAC;IAEvB,OAAO,GAAG,CAAC;AACb,CAAC;AAEY,QAAA,4BAA4B,GAAG;IAC1C,wBAAwB;IACxB,UAAU;IACV,KAAK;IACL,WAAW;IACX,cAAc;CACf,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -37,6 +37,8 @@ export * from "./json/IAgenticaHistoryJson";
|
|
|
37
37
|
export * from "./json/IAgenticaOperationJson";
|
|
38
38
|
export * from "./json/IAgenticaOperationSelectionJson";
|
|
39
39
|
export * from "./json/IAgenticaTokenUsageJson";
|
|
40
|
+
export * from "./json/IMicroAgenticaEventJson";
|
|
41
|
+
export * from "./json/IMicroAgenticaHistoryJson";
|
|
40
42
|
export * from "./MicroAgentica";
|
|
41
43
|
export * as orchestrate from "./orchestrate";
|
|
42
44
|
|
package/src/orchestrate/call.ts
CHANGED
|
@@ -27,7 +27,7 @@ import { AgenticaConstant } from "../constants/AgenticaConstant";
|
|
|
27
27
|
import { AgenticaDefaultPrompt } from "../constants/AgenticaDefaultPrompt";
|
|
28
28
|
import { AgenticaSystemPrompt } from "../constants/AgenticaSystemPrompt";
|
|
29
29
|
import { isAgenticaContext } from "../context/internal/isAgenticaContext";
|
|
30
|
-
import { createCallEvent,
|
|
30
|
+
import { createCallEvent, createExecuteEvent, createTextEvent, createValidateEvent } from "../factory/events";
|
|
31
31
|
import { createCancelHistory, createExecuteHistory, createTextHistory, decodeHistory } from "../factory/histories";
|
|
32
32
|
import { createOperationSelection } from "../factory/operations";
|
|
33
33
|
import { ChatGptCompletionMessageUtil } from "../utils/ChatGptCompletionMessageUtil";
|
|
@@ -116,7 +116,7 @@ export async function call<Model extends ILlmSchema.Model>(
|
|
|
116
116
|
}
|
|
117
117
|
closures.push(
|
|
118
118
|
async (): Promise<
|
|
119
|
-
|
|
119
|
+
Array<AgenticaExecuteHistory<Model> | AgenticaCancelHistory<Model>>
|
|
120
120
|
> => {
|
|
121
121
|
const call: AgenticaCallEvent<Model> = createCallEvent({
|
|
122
122
|
id: tc.id,
|
|
@@ -147,31 +147,24 @@ export async function call<Model extends ILlmSchema.Model>(
|
|
|
147
147
|
).catch(() => {});
|
|
148
148
|
|
|
149
149
|
if (isAgenticaContext(ctx)) {
|
|
150
|
-
|
|
150
|
+
cancelFunction(ctx, {
|
|
151
151
|
name: call.operation.name,
|
|
152
152
|
reason: "completed",
|
|
153
153
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
return [
|
|
155
|
+
execute,
|
|
156
|
+
createCancelHistory({
|
|
157
|
+
id: call.id,
|
|
158
|
+
selections: [
|
|
159
|
+
createOperationSelection({
|
|
160
|
+
operation: call.operation,
|
|
161
|
+
reason: "complete",
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
160
164
|
}),
|
|
161
|
-
|
|
165
|
+
];
|
|
162
166
|
}
|
|
163
|
-
return [
|
|
164
|
-
execute,
|
|
165
|
-
createCancelHistory({
|
|
166
|
-
id: call.id,
|
|
167
|
-
selections: [
|
|
168
|
-
createOperationSelection({
|
|
169
|
-
operation: call.operation,
|
|
170
|
-
reason: "complete",
|
|
171
|
-
}),
|
|
172
|
-
],
|
|
173
|
-
}),
|
|
174
|
-
] as const;
|
|
167
|
+
return [execute];
|
|
175
168
|
},
|
|
176
169
|
);
|
|
177
170
|
}
|
|
@@ -34,6 +34,7 @@ interface IFailure {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export async function cancel<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<AgenticaCancelHistory<Model>[]> {
|
|
37
|
+
console.error("orchestrate.cancel");
|
|
37
38
|
if (ctx.operations.divided === undefined) {
|
|
38
39
|
return step(ctx, ctx.operations.array, 0);
|
|
39
40
|
}
|
|
@@ -85,7 +86,7 @@ export async function cancel<Model extends ILlmSchema.Model>(ctx: AgenticaContex
|
|
|
85
86
|
for (const e of events) {
|
|
86
87
|
if (e.type === "select") {
|
|
87
88
|
collection.selections.push(e.selection);
|
|
88
|
-
|
|
89
|
+
cancelFunction(ctx, {
|
|
89
90
|
name: e.selection.operation.name,
|
|
90
91
|
reason: e.selection.reason,
|
|
91
92
|
});
|
|
@@ -231,7 +232,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
|
|
|
231
232
|
});
|
|
232
233
|
|
|
233
234
|
for (const reference of input.functions) {
|
|
234
|
-
const operation =
|
|
235
|
+
const operation = cancelFunction(ctx, reference);
|
|
235
236
|
if (operation !== null) {
|
|
236
237
|
collection.selections.push(operation);
|
|
237
238
|
}
|