@agentica/core 0.32.3-dev.1 → 0.32.3-dev.3
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.js +20 -17
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.js +19 -16
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +1 -1
- package/lib/context/MicroAgenticaContext.d.ts +1 -1
- package/lib/index.mjs +97 -77
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/call.js +13 -11
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +5 -4
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/select.js +15 -12
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/utils/ChatGptCompletionStreamingUtil.js +41 -29
- package/lib/utils/ChatGptCompletionStreamingUtil.js.map +1 -1
- package/lib/utils/ChatGptCompletionStreamingUtil.spec.d.ts +1 -0
- package/lib/utils/ChatGptCompletionStreamingUtil.spec.js +855 -0
- package/lib/utils/ChatGptCompletionStreamingUtil.spec.js.map +1 -0
- package/lib/utils/MPSC.js +8 -6
- package/lib/utils/MPSC.js.map +1 -1
- package/lib/utils/StreamUtil.d.ts +1 -1
- package/lib/utils/StreamUtil.js +2 -2
- package/lib/utils/StreamUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/Agentica.ts +20 -17
- package/src/MicroAgentica.ts +19 -16
- package/src/context/AgenticaContext.ts +1 -1
- package/src/context/MicroAgenticaContext.ts +1 -1
- package/src/orchestrate/call.ts +9 -7
- package/src/orchestrate/cancel.ts +4 -3
- package/src/orchestrate/select.ts +10 -7
- package/src/utils/ChatGptCompletionStreamingUtil.spec.ts +908 -0
- package/src/utils/ChatGptCompletionStreamingUtil.ts +45 -36
- package/src/utils/MPSC.ts +8 -6
- package/src/utils/StreamUtil.ts +2 -2
package/lib/Agentica.js
CHANGED
|
@@ -117,20 +117,23 @@ class Agentica {
|
|
|
117
117
|
conversate(content_1) {
|
|
118
118
|
return __awaiter(this, arguments, void 0, function* (content, options = {}) {
|
|
119
119
|
const historyGetters = [];
|
|
120
|
-
const dispatch = (event) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if ("
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
120
|
+
const dispatch = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
try {
|
|
122
|
+
yield this.dispatch(event);
|
|
123
|
+
if ("toHistory" in event) {
|
|
124
|
+
if ("join" in event) {
|
|
125
|
+
historyGetters.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
yield event.join();
|
|
127
|
+
return event.toHistory();
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
historyGetters.push(() => __awaiter(this, void 0, void 0, function* () { return event.toHistory(); }));
|
|
132
|
+
}
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
catch (_a) { }
|
|
136
|
+
});
|
|
134
137
|
const prompt = (0, events_1.createUserMessageEvent)({
|
|
135
138
|
contents: Array.isArray(content)
|
|
136
139
|
? content
|
|
@@ -141,7 +144,7 @@ class Agentica {
|
|
|
141
144
|
}]
|
|
142
145
|
: [content],
|
|
143
146
|
});
|
|
144
|
-
dispatch(prompt);
|
|
147
|
+
void dispatch(prompt).catch(() => { });
|
|
145
148
|
yield this.executor_(this.getContext({
|
|
146
149
|
dispatch,
|
|
147
150
|
prompt: prompt.toHistory(),
|
|
@@ -219,7 +222,7 @@ class Agentica {
|
|
|
219
222
|
} }),
|
|
220
223
|
options: Object.assign(Object.assign({}, this.props.vendor.options), { signal: props.abortSignal }),
|
|
221
224
|
});
|
|
222
|
-
props.dispatch(event);
|
|
225
|
+
yield props.dispatch(event);
|
|
223
226
|
// completion
|
|
224
227
|
const backoffStrategy = (_b = (_a = this.props.config) === null || _a === void 0 ? void 0 : _a.backoffStrategy) !== null && _b !== void 0 ? _b : ((props) => {
|
|
225
228
|
throw props.error;
|
|
@@ -256,7 +259,7 @@ class Agentica {
|
|
|
256
259
|
}
|
|
257
260
|
}))().catch(() => { });
|
|
258
261
|
const [streamForStream, streamForJoin] = streamForEvent.tee();
|
|
259
|
-
props.dispatch({
|
|
262
|
+
void props.dispatch({
|
|
260
263
|
id: (0, uuid_1.v4)(),
|
|
261
264
|
type: "response",
|
|
262
265
|
source,
|
|
@@ -268,7 +271,7 @@ class Agentica {
|
|
|
268
271
|
return ChatGptCompletionMessageUtil_1.ChatGptCompletionMessageUtil.merge(chunks);
|
|
269
272
|
}),
|
|
270
273
|
created_at: new Date().toISOString(),
|
|
271
|
-
});
|
|
274
|
+
}).catch(() => { });
|
|
272
275
|
return streamForReturn;
|
|
273
276
|
});
|
|
274
277
|
return {
|
|
@@ -296,7 +299,7 @@ class Agentica {
|
|
|
296
299
|
}),
|
|
297
300
|
initialize: () => __awaiter(this, void 0, void 0, function* () {
|
|
298
301
|
this.ready_ = true;
|
|
299
|
-
props.dispatch((0, events_1.createInitializeEvent)());
|
|
302
|
+
void props.dispatch((0, events_1.createInitializeEvent)()).catch(() => { });
|
|
300
303
|
}),
|
|
301
304
|
};
|
|
302
305
|
}
|
package/lib/Agentica.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agentica.js","sourceRoot":"","sources":["../src/Agentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,+BAAiC;AACjC,+BAA0B;AAkB1B,qEAAkE;AAClE,4FAAyF;AACzF,kGAA+F;AAC/F,6CAAqG;AACrG,mDAAgD;AAChD,sEAAmE;AACnE,mDAAgD;AAChD,uFAAoF;AACpF,mDAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,QAAQ;IAenB;;kEAE8D;IAC9D;;;;OAIG;IACH,YAAoC,KAA4B;;QAA5B,UAAK,GAA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,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,QAAiE,CAAC,CAAC;QAC1H,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACI,GAAG,CACR,IAAU,EACV,QAEyB;QAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACxB;;eAEG;YACD,GAAG,CAAC,MAAM,CAAC,QAAiE,CAAC,CAAC;YAC9E,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEa,QAAQ,CACpB,KAAY;;YAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAO,QAAQ,EAAE,EAAE;oBACrC,IAAI,CAAC;wBACH,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC;oBACD,WAAM,CAAC;wBACL,WAAW;oBACb,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AAvYD,4BAuYC"}
|
package/lib/MicroAgentica.js
CHANGED
|
@@ -109,20 +109,23 @@ class MicroAgentica {
|
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
110
|
var _a, _b, _c, _d;
|
|
111
111
|
const histories = [];
|
|
112
|
-
const dispatch = (event) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if ("
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
const dispatch = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
try {
|
|
114
|
+
yield this.dispatch(event);
|
|
115
|
+
if ("toHistory" in event) {
|
|
116
|
+
if ("join" in event) {
|
|
117
|
+
histories.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
yield event.join();
|
|
119
|
+
return event.toHistory();
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
histories.push(() => __awaiter(this, void 0, void 0, function* () { return event.toHistory(); }));
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
|
|
127
|
+
catch (_a) { }
|
|
128
|
+
});
|
|
126
129
|
const prompt = (0, events_1.createUserMessageEvent)({
|
|
127
130
|
contents: Array.isArray(content)
|
|
128
131
|
? content
|
|
@@ -133,7 +136,7 @@ class MicroAgentica {
|
|
|
133
136
|
}]
|
|
134
137
|
: [content],
|
|
135
138
|
});
|
|
136
|
-
dispatch(prompt);
|
|
139
|
+
void dispatch(prompt).catch(() => { });
|
|
137
140
|
const ctx = this.getContext({
|
|
138
141
|
prompt,
|
|
139
142
|
dispatch,
|
|
@@ -216,7 +219,7 @@ class MicroAgentica {
|
|
|
216
219
|
} }),
|
|
217
220
|
options: this.props.vendor.options,
|
|
218
221
|
});
|
|
219
|
-
props.dispatch(event);
|
|
222
|
+
yield props.dispatch(event);
|
|
220
223
|
// completion
|
|
221
224
|
const backoffStrategy = (_b = (_a = this.props.config) === null || _a === void 0 ? void 0 : _a.backoffStrategy) !== null && _b !== void 0 ? _b : ((props) => {
|
|
222
225
|
throw props.error;
|
|
@@ -253,7 +256,7 @@ class MicroAgentica {
|
|
|
253
256
|
}
|
|
254
257
|
}))().catch(() => { });
|
|
255
258
|
const [streamForStream, streamForJoin] = streamForEvent.tee();
|
|
256
|
-
props.dispatch({
|
|
259
|
+
void props.dispatch({
|
|
257
260
|
id: (0, uuid_1.v4)(),
|
|
258
261
|
type: "response",
|
|
259
262
|
source,
|
|
@@ -265,7 +268,7 @@ class MicroAgentica {
|
|
|
265
268
|
return ChatGptCompletionMessageUtil_1.ChatGptCompletionMessageUtil.merge(chunks);
|
|
266
269
|
}),
|
|
267
270
|
created_at: new Date().toISOString(),
|
|
268
|
-
});
|
|
271
|
+
}).catch(() => { });
|
|
269
272
|
return streamForReturn;
|
|
270
273
|
});
|
|
271
274
|
return {
|
package/lib/MicroAgentica.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,+BAAiC;AACjC,+BAA0B;AAgB1B,qEAAkE;AAClE,4FAAyF;AACzF,kGAA+F;AAC/F,6CAA8E;AAC9E,+CAA+C;AAC/C,sEAAmE;AACnE,mDAAgD;AAChD,uFAAoF;AACpF,mDAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,aAAa;IAWxB;;kEAE8D;IAC9D;;;;OAIG;IACH,YAAoC,KAAiC;;QAAjC,UAAK,GAAL,KAAK,CAA4B;QACnE,IAAI,CAAC,WAAW,GAAG,qDAAyB,CAAC,OAAO,CAAC;YACnD,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CACpD,IAAA,mCAAgB,EAAC;YACf,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK;YAClC,OAAO,EAAE,KAAK;SACf,CAAC,CAC8B,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAA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,GAAG,CAAC,QAA+D,CAAC,CAAC;QACxH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACI,GAAG,CACR,IAAU,EACV,QAEyB;QAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB;;eAEG;YACH,GAAG,CAAC,MAAM,CAAC,QAA+D,CAAC,CAAC;YAC5E,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEa,QAAQ,CACpB,KAAY;;YAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAO,QAAQ,EAAE,EAAE;oBACrC,IAAI,CAAC;wBACH,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC;oBACD,WAAM,CAAC;wBACL,WAAW;oBACb,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AAxWD,sCAwWC"}
|
|
@@ -96,7 +96,7 @@ export interface AgenticaContext<Model extends ILlmSchema.Model> {
|
|
|
96
96
|
*
|
|
97
97
|
* @param event Event to deliver
|
|
98
98
|
*/
|
|
99
|
-
dispatch: (event: AgenticaEvent<Model>) => void
|
|
99
|
+
dispatch: (event: AgenticaEvent<Model>) => Promise<void>;
|
|
100
100
|
/**
|
|
101
101
|
* Request to the OpenAI server.
|
|
102
102
|
*
|
|
@@ -63,7 +63,7 @@ export interface MicroAgenticaContext<Model extends ILlmSchema.Model> {
|
|
|
63
63
|
*
|
|
64
64
|
* @param event Event to deliver
|
|
65
65
|
*/
|
|
66
|
-
dispatch: (event: MicroAgenticaEvent<Model>) => void
|
|
66
|
+
dispatch: (event: MicroAgenticaEvent<Model>) => Promise<void>;
|
|
67
67
|
/**
|
|
68
68
|
* Request to the OpenAI server.
|
|
69
69
|
*
|
package/lib/index.mjs
CHANGED
|
@@ -1131,13 +1131,15 @@ class MPSC {
|
|
|
1131
1131
|
constructor() {
|
|
1132
1132
|
this.queue = new AsyncQueue;
|
|
1133
1133
|
this.consumer = new ReadableStream({
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1134
|
+
start: async controller => {
|
|
1135
|
+
while (true) {
|
|
1136
|
+
const {value, done} = await this.queue.dequeue();
|
|
1137
|
+
if (done === true) {
|
|
1138
|
+
controller.close();
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
controller.enqueue(value);
|
|
1139
1142
|
}
|
|
1140
|
-
controller.enqueue(value);
|
|
1141
1143
|
}
|
|
1142
1144
|
});
|
|
1143
1145
|
}
|
|
@@ -1185,10 +1187,10 @@ async function reduce(stream, reducer, initial) {
|
|
|
1185
1187
|
return acc;
|
|
1186
1188
|
}
|
|
1187
1189
|
|
|
1188
|
-
function from(value) {
|
|
1190
|
+
function from(...value) {
|
|
1189
1191
|
const stream = new ReadableStream({
|
|
1190
1192
|
start: controller => {
|
|
1191
|
-
controller.enqueue(
|
|
1193
|
+
value.forEach((v => controller.enqueue(v)));
|
|
1192
1194
|
controller.close();
|
|
1193
1195
|
}
|
|
1194
1196
|
});
|
|
@@ -1247,37 +1249,35 @@ async function reduceStreamingWithDispatch(stream, eventProcessor) {
|
|
|
1247
1249
|
const acc = await accPromise;
|
|
1248
1250
|
const registerContext = choices => {
|
|
1249
1251
|
for (const choice of choices) {
|
|
1252
|
+
if (choice.delta.content != null && choice.delta.content !== "") {
|
|
1253
|
+
if (streamContext.has(choice.index)) {
|
|
1254
|
+
const context = streamContext.get(choice.index);
|
|
1255
|
+
context.content += choice.delta.content;
|
|
1256
|
+
context.mpsc.produce(choice.delta.content);
|
|
1257
|
+
} else {
|
|
1258
|
+
const mpsc = new MPSC;
|
|
1259
|
+
streamContext.set(choice.index, {
|
|
1260
|
+
content: choice.delta.content,
|
|
1261
|
+
mpsc
|
|
1262
|
+
});
|
|
1263
|
+
mpsc.produce(choice.delta.content);
|
|
1264
|
+
eventProcessor({
|
|
1265
|
+
stream: streamDefaultReaderToAsyncGenerator(mpsc.consumer.getReader()),
|
|
1266
|
+
done: () => mpsc.done(),
|
|
1267
|
+
get: () => streamContext.get(choice.index)?.content ?? "",
|
|
1268
|
+
join: async () => {
|
|
1269
|
+
await mpsc.waitClosed();
|
|
1270
|
+
return streamContext.get(choice.index).content;
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1250
1275
|
if (choice.finish_reason != null) {
|
|
1251
1276
|
const context = streamContext.get(choice.index);
|
|
1252
1277
|
if (context != null) {
|
|
1253
1278
|
context.mpsc.close();
|
|
1254
1279
|
}
|
|
1255
|
-
continue;
|
|
1256
1280
|
}
|
|
1257
|
-
if (choice.delta.content == null || choice.delta.content === "") {
|
|
1258
|
-
continue;
|
|
1259
|
-
}
|
|
1260
|
-
if (streamContext.has(choice.index)) {
|
|
1261
|
-
const context = streamContext.get(choice.index);
|
|
1262
|
-
context.content += choice.delta.content;
|
|
1263
|
-
context.mpsc.produce(choice.delta.content);
|
|
1264
|
-
continue;
|
|
1265
|
-
}
|
|
1266
|
-
const mpsc = new MPSC;
|
|
1267
|
-
streamContext.set(choice.index, {
|
|
1268
|
-
content: choice.delta.content,
|
|
1269
|
-
mpsc
|
|
1270
|
-
});
|
|
1271
|
-
mpsc.produce(choice.delta.content);
|
|
1272
|
-
eventProcessor({
|
|
1273
|
-
stream: streamDefaultReaderToAsyncGenerator(mpsc.consumer.getReader()),
|
|
1274
|
-
done: () => mpsc.done(),
|
|
1275
|
-
get: () => streamContext.get(choice.index)?.content ?? "",
|
|
1276
|
-
join: async () => {
|
|
1277
|
-
await mpsc.waitClosed();
|
|
1278
|
-
return streamContext.get(choice.index).content;
|
|
1279
|
-
}
|
|
1280
|
-
});
|
|
1281
1281
|
}
|
|
1282
1282
|
};
|
|
1283
1283
|
if (acc.object === "chat.completion.chunk") {
|
|
@@ -1290,6 +1290,20 @@ async function reduceStreamingWithDispatch(stream, eventProcessor) {
|
|
|
1290
1290
|
if (nullableCompletion == null) {
|
|
1291
1291
|
throw new Error("StreamUtil.reduce did not produce a ChatCompletion. Possible causes: the input stream was empty, invalid, or closed prematurely. " + "To debug: check that the stream is properly initialized and contains valid ChatCompletionChunk data. " + "You may also enable verbose logging upstream to inspect the stream contents. " + `Stream locked: ${stream.locked}.`);
|
|
1292
1292
|
}
|
|
1293
|
+
if (nullableCompletion.object === "chat.completion.chunk") {
|
|
1294
|
+
const completion = ChatGptCompletionMessageUtil.merge([ nullableCompletion ]);
|
|
1295
|
+
completion.choices.forEach((choice => {
|
|
1296
|
+
if (choice.message.content != null && choice.message.content !== "") {
|
|
1297
|
+
eventProcessor({
|
|
1298
|
+
stream: toAsyncGenerator(choice.message.content),
|
|
1299
|
+
done: () => true,
|
|
1300
|
+
get: () => choice.message.content,
|
|
1301
|
+
join: async () => choice.message.content
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
}));
|
|
1305
|
+
return completion;
|
|
1306
|
+
}
|
|
1293
1307
|
return nullableCompletion;
|
|
1294
1308
|
}
|
|
1295
1309
|
|
|
@@ -1361,7 +1375,7 @@ async function call(ctx, operations) {
|
|
|
1361
1375
|
});
|
|
1362
1376
|
const completion = await reduceStreamingWithDispatch(stream, (props => {
|
|
1363
1377
|
const event = createAssistantMessageEvent(props);
|
|
1364
|
-
ctx.dispatch(event);
|
|
1378
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
1365
1379
|
}));
|
|
1366
1380
|
const allAssistantMessagesEmpty = completion.choices.every((v => v.message.tool_calls == null && v.message.content === ""));
|
|
1367
1381
|
if (allAssistantMessagesEmpty) {
|
|
@@ -1380,7 +1394,7 @@ async function call(ctx, operations) {
|
|
|
1380
1394
|
get: () => "",
|
|
1381
1395
|
join: async () => ""
|
|
1382
1396
|
});
|
|
1383
|
-
ctx.dispatch(event);
|
|
1397
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
1384
1398
|
return [];
|
|
1385
1399
|
}
|
|
1386
1400
|
const executes = [];
|
|
@@ -1393,7 +1407,7 @@ async function call(ctx, operations) {
|
|
|
1393
1407
|
continue;
|
|
1394
1408
|
}
|
|
1395
1409
|
const event = await predicate(ctx, operation, tc, [], retry);
|
|
1396
|
-
ctx.dispatch(event);
|
|
1410
|
+
await ctx.dispatch(event);
|
|
1397
1411
|
executes.push(event);
|
|
1398
1412
|
if (isAgenticaContext(ctx)) {
|
|
1399
1413
|
cancelFunctionFromContext(ctx, {
|
|
@@ -1409,7 +1423,7 @@ async function call(ctx, operations) {
|
|
|
1409
1423
|
|
|
1410
1424
|
async function predicate(ctx, operation, toolCall, previousValidationErrors, life) {
|
|
1411
1425
|
const call = parseArguments(operation, toolCall);
|
|
1412
|
-
ctx.dispatch(call);
|
|
1426
|
+
await ctx.dispatch(call);
|
|
1413
1427
|
if (call.type === "jsonParseError") {
|
|
1414
1428
|
return correctJsonError(ctx, call, previousValidationErrors, life - 1);
|
|
1415
1429
|
}
|
|
@@ -1420,7 +1434,7 @@ async function predicate(ctx, operation, toolCall, previousValidationErrors, lif
|
|
|
1420
1434
|
operation,
|
|
1421
1435
|
result: check
|
|
1422
1436
|
});
|
|
1423
|
-
ctx.dispatch(event);
|
|
1437
|
+
await ctx.dispatch(event);
|
|
1424
1438
|
return correctTypeError(ctx, call, event, [ ...previousValidationErrors, event ], life - 1);
|
|
1425
1439
|
}
|
|
1426
1440
|
return executeFunction(call, operation);
|
|
@@ -1727,16 +1741,17 @@ async function cancel(ctx) {
|
|
|
1727
1741
|
await Promise.all(ctx.operations.divided.map((async (operations, i) => step$1({
|
|
1728
1742
|
...ctx,
|
|
1729
1743
|
stack: stacks[i],
|
|
1730
|
-
dispatch: e => {
|
|
1744
|
+
dispatch: async e => {
|
|
1731
1745
|
events.push(e);
|
|
1732
|
-
return e;
|
|
1733
1746
|
}
|
|
1734
1747
|
}, operations, 0))));
|
|
1735
1748
|
if ((ctx.config?.eliticism ?? AgenticaConstant.ELITICISM) === true && stacks.some((s => s.length !== 0))) {
|
|
1736
1749
|
return step$1(ctx, stacks.flat().map((s => ctx.operations.group.get(s.operation.controller.name).get(s.operation.function.name))), 0);
|
|
1737
1750
|
} else {
|
|
1738
1751
|
const cancelled = events.filter((e => e.type === "cancel"));
|
|
1739
|
-
(cancelled.length !== 0 ? cancelled : events).forEach(
|
|
1752
|
+
(cancelled.length !== 0 ? cancelled : events).forEach((e => {
|
|
1753
|
+
void ctx.dispatch(e).catch((() => {}));
|
|
1754
|
+
}));
|
|
1740
1755
|
}
|
|
1741
1756
|
}
|
|
1742
1757
|
|
|
@@ -2736,16 +2751,17 @@ async function select(ctx) {
|
|
|
2736
2751
|
await Promise.all(ctx.operations.divided.map((async (operations, i) => step({
|
|
2737
2752
|
...ctx,
|
|
2738
2753
|
stack: stacks[i],
|
|
2739
|
-
dispatch: e => {
|
|
2754
|
+
dispatch: async e => {
|
|
2740
2755
|
events.push(e);
|
|
2741
|
-
return e;
|
|
2742
2756
|
}
|
|
2743
2757
|
}, operations, 0))));
|
|
2744
2758
|
if ((ctx.config?.eliticism ?? AgenticaConstant.ELITICISM) === true && stacks.some((s => s.length !== 0))) {
|
|
2745
2759
|
return step(ctx, stacks.flat().map((s => ctx.operations.group.get(s.operation.controller.name).get(s.operation.function.name))), 0);
|
|
2746
2760
|
} else {
|
|
2747
2761
|
const selected = events.filter((e => e.type === "select"));
|
|
2748
|
-
(selected.length !== 0 ? selected : events).forEach(
|
|
2762
|
+
(selected.length !== 0 ? selected : events).forEach((e => {
|
|
2763
|
+
void ctx.dispatch(e).catch((() => {}));
|
|
2764
|
+
}));
|
|
2749
2765
|
}
|
|
2750
2766
|
}
|
|
2751
2767
|
|
|
@@ -2806,7 +2822,7 @@ async function step(ctx, operations, retry, failures) {
|
|
|
2806
2822
|
});
|
|
2807
2823
|
const completion = await reduceStreamingWithDispatch(stream, (props => {
|
|
2808
2824
|
const event = createAssistantMessageEvent(props);
|
|
2809
|
-
ctx.dispatch(event);
|
|
2825
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
2810
2826
|
}));
|
|
2811
2827
|
const allAssistantMessagesEmpty = completion.choices.every((v => v.message.tool_calls == null && v.message.content === ""));
|
|
2812
2828
|
if (allAssistantMessagesEmpty) {
|
|
@@ -2825,7 +2841,7 @@ async function step(ctx, operations, retry, failures) {
|
|
|
2825
2841
|
get: () => "",
|
|
2826
2842
|
join: async () => ""
|
|
2827
2843
|
});
|
|
2828
|
-
ctx.dispatch(event);
|
|
2844
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
2829
2845
|
return;
|
|
2830
2846
|
}
|
|
2831
2847
|
if (retry++ < (ctx.config?.retry ?? AgenticaConstant.RETRY)) {
|
|
@@ -3125,18 +3141,20 @@ class Agentica {
|
|
|
3125
3141
|
}
|
|
3126
3142
|
async conversate(content, options = {}) {
|
|
3127
3143
|
const historyGetters = [];
|
|
3128
|
-
const dispatch = event => {
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
if ("
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3144
|
+
const dispatch = async event => {
|
|
3145
|
+
try {
|
|
3146
|
+
await this.dispatch(event);
|
|
3147
|
+
if ("toHistory" in event) {
|
|
3148
|
+
if ("join" in event) {
|
|
3149
|
+
historyGetters.push((async () => {
|
|
3150
|
+
await event.join();
|
|
3151
|
+
return event.toHistory();
|
|
3152
|
+
}));
|
|
3153
|
+
} else {
|
|
3154
|
+
historyGetters.push((async () => event.toHistory()));
|
|
3155
|
+
}
|
|
3138
3156
|
}
|
|
3139
|
-
}
|
|
3157
|
+
} catch {}
|
|
3140
3158
|
};
|
|
3141
3159
|
const prompt = createUserMessageEvent({
|
|
3142
3160
|
contents: Array.isArray(content) ? content : typeof content === "string" ? [ {
|
|
@@ -3144,7 +3162,7 @@ class Agentica {
|
|
|
3144
3162
|
text: content
|
|
3145
3163
|
} ] : [ content ]
|
|
3146
3164
|
});
|
|
3147
|
-
dispatch(prompt);
|
|
3165
|
+
void dispatch(prompt).catch((() => {}));
|
|
3148
3166
|
await this.executor_(this.getContext({
|
|
3149
3167
|
dispatch,
|
|
3150
3168
|
prompt: prompt.toHistory(),
|
|
@@ -3190,7 +3208,7 @@ class Agentica {
|
|
|
3190
3208
|
signal: props.abortSignal
|
|
3191
3209
|
}
|
|
3192
3210
|
});
|
|
3193
|
-
props.dispatch(event);
|
|
3211
|
+
await props.dispatch(event);
|
|
3194
3212
|
const backoffStrategy = this.props.config?.backoffStrategy ?? (props => {
|
|
3195
3213
|
throw props.error;
|
|
3196
3214
|
});
|
|
@@ -3228,7 +3246,7 @@ class Agentica {
|
|
|
3228
3246
|
}
|
|
3229
3247
|
})().catch((() => {}));
|
|
3230
3248
|
const [streamForStream, streamForJoin] = streamForEvent.tee();
|
|
3231
|
-
props.dispatch({
|
|
3249
|
+
void props.dispatch({
|
|
3232
3250
|
id: v4(),
|
|
3233
3251
|
type: "response",
|
|
3234
3252
|
source,
|
|
@@ -3240,7 +3258,7 @@ class Agentica {
|
|
|
3240
3258
|
return ChatGptCompletionMessageUtil.merge(chunks);
|
|
3241
3259
|
},
|
|
3242
3260
|
created_at: (new Date).toISOString()
|
|
3243
|
-
});
|
|
3261
|
+
}).catch((() => {}));
|
|
3244
3262
|
return streamForReturn;
|
|
3245
3263
|
};
|
|
3246
3264
|
return {
|
|
@@ -3262,7 +3280,7 @@ class Agentica {
|
|
|
3262
3280
|
},
|
|
3263
3281
|
initialize: async () => {
|
|
3264
3282
|
this.ready_ = true;
|
|
3265
|
-
props.dispatch(createInitializeEvent());
|
|
3283
|
+
void props.dispatch(createInitializeEvent()).catch((() => {}));
|
|
3266
3284
|
}
|
|
3267
3285
|
};
|
|
3268
3286
|
}
|
|
@@ -42004,18 +42022,20 @@ class MicroAgentica {
|
|
|
42004
42022
|
}
|
|
42005
42023
|
async conversate(content) {
|
|
42006
42024
|
const histories = [];
|
|
42007
|
-
const dispatch = event => {
|
|
42008
|
-
|
|
42009
|
-
|
|
42010
|
-
if ("
|
|
42011
|
-
|
|
42012
|
-
|
|
42013
|
-
|
|
42014
|
-
|
|
42015
|
-
|
|
42016
|
-
|
|
42025
|
+
const dispatch = async event => {
|
|
42026
|
+
try {
|
|
42027
|
+
await this.dispatch(event);
|
|
42028
|
+
if ("toHistory" in event) {
|
|
42029
|
+
if ("join" in event) {
|
|
42030
|
+
histories.push((async () => {
|
|
42031
|
+
await event.join();
|
|
42032
|
+
return event.toHistory();
|
|
42033
|
+
}));
|
|
42034
|
+
} else {
|
|
42035
|
+
histories.push((async () => event.toHistory()));
|
|
42036
|
+
}
|
|
42017
42037
|
}
|
|
42018
|
-
}
|
|
42038
|
+
} catch {}
|
|
42019
42039
|
};
|
|
42020
42040
|
const prompt = createUserMessageEvent({
|
|
42021
42041
|
contents: Array.isArray(content) ? content : typeof content === "string" ? [ {
|
|
@@ -42023,7 +42043,7 @@ class MicroAgentica {
|
|
|
42023
42043
|
text: content
|
|
42024
42044
|
} ] : [ content ]
|
|
42025
42045
|
});
|
|
42026
|
-
dispatch(prompt);
|
|
42046
|
+
void dispatch(prompt).catch((() => {}));
|
|
42027
42047
|
const ctx = this.getContext({
|
|
42028
42048
|
prompt,
|
|
42029
42049
|
dispatch,
|
|
@@ -42069,7 +42089,7 @@ class MicroAgentica {
|
|
|
42069
42089
|
},
|
|
42070
42090
|
options: this.props.vendor.options
|
|
42071
42091
|
});
|
|
42072
|
-
props.dispatch(event);
|
|
42092
|
+
await props.dispatch(event);
|
|
42073
42093
|
const backoffStrategy = this.props.config?.backoffStrategy ?? (props => {
|
|
42074
42094
|
throw props.error;
|
|
42075
42095
|
});
|
|
@@ -42107,7 +42127,7 @@ class MicroAgentica {
|
|
|
42107
42127
|
}
|
|
42108
42128
|
})().catch((() => {}));
|
|
42109
42129
|
const [streamForStream, streamForJoin] = streamForEvent.tee();
|
|
42110
|
-
props.dispatch({
|
|
42130
|
+
void props.dispatch({
|
|
42111
42131
|
id: v4(),
|
|
42112
42132
|
type: "response",
|
|
42113
42133
|
source,
|
|
@@ -42119,7 +42139,7 @@ class MicroAgentica {
|
|
|
42119
42139
|
return ChatGptCompletionMessageUtil.merge(chunks);
|
|
42120
42140
|
},
|
|
42121
42141
|
created_at: (new Date).toISOString()
|
|
42122
|
-
});
|
|
42142
|
+
}).catch((() => {}));
|
|
42123
42143
|
return streamForReturn;
|
|
42124
42144
|
};
|
|
42125
42145
|
return {
|