@digipair/skill-dsp 0.88.3 → 0.88.6
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/index.cjs.js +340 -817
- package/index.esm.js +344 -821
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var engine = require('@digipair/engine');
|
|
6
|
-
var crypto$6 = require('crypto');
|
|
7
6
|
var web = require('stream/web');
|
|
8
7
|
var require$$2$3 = require('child_process');
|
|
9
8
|
var require$$0$4 = require('fs');
|
|
@@ -24,15 +23,21 @@ var require$$0$5 = require('node:events');
|
|
|
24
23
|
var require$$1$6 = require('node:process');
|
|
25
24
|
var require$$2$2 = require('node:util');
|
|
26
25
|
var require$$3 = require('path');
|
|
27
|
-
var require$$0$6 = require('
|
|
28
|
-
var require$$0$7 = require('
|
|
29
|
-
require('
|
|
30
|
-
require('
|
|
31
|
-
require('
|
|
26
|
+
var require$$0$6 = require('crypto');
|
|
27
|
+
var require$$0$7 = require('buffer');
|
|
28
|
+
var require$$0$8 = require('events');
|
|
29
|
+
var web$1 = require('node:stream/web');
|
|
30
|
+
require('node:fs');
|
|
31
|
+
require('node:crypto');
|
|
32
|
+
require('node:http');
|
|
33
|
+
require('node:https');
|
|
34
|
+
require('node:os');
|
|
35
|
+
require('node:vm');
|
|
36
|
+
require('node:child_process');
|
|
37
|
+
require('node:readline');
|
|
32
38
|
|
|
33
39
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
34
40
|
|
|
35
|
-
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto$6);
|
|
36
41
|
var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$3);
|
|
37
42
|
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
|
|
38
43
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
@@ -54,6 +59,7 @@ var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
|
|
|
54
59
|
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
55
60
|
var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
|
|
56
61
|
var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
|
|
62
|
+
var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
|
|
57
63
|
|
|
58
64
|
function _extends() {
|
|
59
65
|
_extends = Object.assign || function assign(target) {
|
|
@@ -92909,7 +92915,7 @@ Object.defineProperty(crypto$3, "__esModule", {
|
|
|
92909
92915
|
value: true
|
|
92910
92916
|
});
|
|
92911
92917
|
crypto$3.NodeCrypto = void 0;
|
|
92912
|
-
var crypto$2 =
|
|
92918
|
+
var crypto$2 = require$$0__default$5["default"];
|
|
92913
92919
|
var NodeCrypto = /*#__PURE__*/ function() {
|
|
92914
92920
|
function NodeCrypto() {
|
|
92915
92921
|
_class_call_check$r(this, NodeCrypto);
|
|
@@ -93408,7 +93414,7 @@ var safeBuffer = {
|
|
|
93408
93414
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
93409
93415
|
|
|
93410
93416
|
(function (module, exports) {
|
|
93411
|
-
/* eslint-disable node/no-deprecated-api */ var buffer = require$$0__default$
|
|
93417
|
+
/* eslint-disable node/no-deprecated-api */ var buffer = require$$0__default$6["default"];
|
|
93412
93418
|
var Buffer = buffer.Buffer;
|
|
93413
93419
|
// alternative to using Object.keys for old browsers
|
|
93414
93420
|
function copyProps(src, dst) {
|
|
@@ -93882,7 +93888,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
93882
93888
|
value: true
|
|
93883
93889
|
});
|
|
93884
93890
|
exports.AuthClient = exports.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS = exports.DEFAULT_UNIVERSE = void 0;
|
|
93885
|
-
var events_1 = require$$0__default$
|
|
93891
|
+
var events_1 = require$$0__default$7["default"];
|
|
93886
93892
|
var gaxios_1 = src$3;
|
|
93887
93893
|
var transporters_1 = transporters;
|
|
93888
93894
|
var util_1 = util$4;
|
|
@@ -96709,8 +96715,8 @@ DataStream$2.prototype.end = function end(data) {
|
|
|
96709
96715
|
var dataStream = DataStream$2;
|
|
96710
96716
|
|
|
96711
96717
|
/*jshint node:true */
|
|
96712
|
-
var Buffer$5 = require$$0__default$
|
|
96713
|
-
var SlowBuffer = require$$0__default$
|
|
96718
|
+
var Buffer$5 = require$$0__default$6["default"].Buffer; // browserify
|
|
96719
|
+
var SlowBuffer = require$$0__default$6["default"].SlowBuffer;
|
|
96714
96720
|
var bufferEqualConstantTime = bufferEq;
|
|
96715
96721
|
function bufferEq(a, b) {
|
|
96716
96722
|
// shortcutting on type is necessary for correctness
|
|
@@ -96743,7 +96749,7 @@ bufferEq.restore = function() {
|
|
|
96743
96749
|
|
|
96744
96750
|
var bufferEqual = bufferEqualConstantTime;
|
|
96745
96751
|
var Buffer$4 = safeBuffer.exports.Buffer;
|
|
96746
|
-
var crypto$1 =
|
|
96752
|
+
var crypto$1 = require$$0__default$5["default"];
|
|
96747
96753
|
var formatEcdsa = ecdsaSigFormatter;
|
|
96748
96754
|
var util$2 = require$$5__default["default"];
|
|
96749
96755
|
var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
|
|
@@ -96951,7 +96957,7 @@ var jwa$2 = function jwa(algorithm) {
|
|
|
96951
96957
|
|
|
96952
96958
|
/*global module*/
|
|
96953
96959
|
|
|
96954
|
-
var Buffer$3 = require$$0__default$
|
|
96960
|
+
var Buffer$3 = require$$0__default$6["default"].Buffer;
|
|
96955
96961
|
var tostring = function toString(obj) {
|
|
96956
96962
|
if (typeof obj === "string") return obj;
|
|
96957
96963
|
if (typeof obj === "number" || Buffer$3.isBuffer(obj)) return obj.toString();
|
|
@@ -115528,7 +115534,7 @@ var AxAIServiceError = (_Symbol_for = Symbol.for("nodejs.util.inspect.custom"),
|
|
|
115528
115534
|
_this.responseBody = responseBody;
|
|
115529
115535
|
_this.name = _this.constructor.name;
|
|
115530
115536
|
_this.timestamp = /* @__PURE__ */ new Date().toISOString();
|
|
115531
|
-
_this.errorId =
|
|
115537
|
+
_this.errorId = crypto.randomUUID();
|
|
115532
115538
|
_this.context = context3;
|
|
115533
115539
|
_this.stack = _this.toString();
|
|
115534
115540
|
return _this;
|
|
@@ -115626,7 +115632,7 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
|
115626
115632
|
function AxAIServiceTimeoutError(url, timeoutMs, requestBody, context3) {
|
|
115627
115633
|
_class_call_check(this, AxAIServiceTimeoutError);
|
|
115628
115634
|
var _this;
|
|
115629
|
-
_this = _super.call(this, "Request
|
|
115635
|
+
_this = _super.call(this, "Request timeout after ".concat(timeoutMs, "ms"), url, requestBody, void 0, _object_spread({
|
|
115630
115636
|
timeoutMs: timeoutMs
|
|
115631
115637
|
}, context3));
|
|
115632
115638
|
_this.name = _this.constructor.name;
|
|
@@ -115634,20 +115640,6 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
|
115634
115640
|
}
|
|
115635
115641
|
return AxAIServiceTimeoutError;
|
|
115636
115642
|
}(AxAIServiceError);
|
|
115637
|
-
var AxAIServiceAbortedError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
115638
|
-
_inherits(AxAIServiceAbortedError, AxAIServiceError);
|
|
115639
|
-
var _super = _create_super(AxAIServiceAbortedError);
|
|
115640
|
-
function AxAIServiceAbortedError(url, reason, requestBody, context3) {
|
|
115641
|
-
_class_call_check(this, AxAIServiceAbortedError);
|
|
115642
|
-
var _this;
|
|
115643
|
-
_this = _super.call(this, "Request aborted".concat(reason ? ": ".concat(reason) : ""), url, requestBody, void 0, _object_spread({
|
|
115644
|
-
abortReason: reason
|
|
115645
|
-
}, context3));
|
|
115646
|
-
_this.name = _this.constructor.name;
|
|
115647
|
-
return _this;
|
|
115648
|
-
}
|
|
115649
|
-
return AxAIServiceAbortedError;
|
|
115650
|
-
}(AxAIServiceError);
|
|
115651
115643
|
var AxAIServiceAuthenticationError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
115652
115644
|
_inherits(AxAIServiceAuthenticationError, AxAIServiceError);
|
|
115653
115645
|
var _super = _create_super(AxAIServiceAuthenticationError);
|
|
@@ -115686,31 +115678,13 @@ var apiCall = function() {
|
|
|
115686
115678
|
switch(_state.label){
|
|
115687
115679
|
case 0:
|
|
115688
115680
|
_loop = function() {
|
|
115689
|
-
var
|
|
115681
|
+
var controller, _api_fetch, res, _api_span, delay, _api_span1, resJson, isValid, lastChunk, chunkCount, trackingStream, closed, error, _api_span2, _api_span3, delay1;
|
|
115690
115682
|
return _ts_generator(this, function(_state) {
|
|
115691
115683
|
switch(_state.label){
|
|
115692
115684
|
case 0:
|
|
115693
|
-
|
|
115694
|
-
if (api.abortSignal) {
|
|
115695
|
-
if (api.abortSignal.aborted) {
|
|
115696
|
-
throw new AxAIServiceAbortedError(apiUrl.href, api.abortSignal.reason, json, {
|
|
115697
|
-
metrics: metrics
|
|
115698
|
-
});
|
|
115699
|
-
}
|
|
115700
|
-
userAbortHandler = function() {
|
|
115701
|
-
combinedAbortController.abort(api.abortSignal.reason || "User aborted request");
|
|
115702
|
-
};
|
|
115703
|
-
api.abortSignal.addEventListener("abort", userAbortHandler, {
|
|
115704
|
-
once: true
|
|
115705
|
-
});
|
|
115706
|
-
originalAbort = combinedAbortController.abort.bind(combinedAbortController);
|
|
115707
|
-
combinedAbortController.abort = function(reason) {
|
|
115708
|
-
api.abortSignal.removeEventListener("abort", userAbortHandler);
|
|
115709
|
-
originalAbort(reason);
|
|
115710
|
-
};
|
|
115711
|
-
}
|
|
115685
|
+
controller = new AbortController();
|
|
115712
115686
|
timeoutId = setTimeout(function() {
|
|
115713
|
-
|
|
115687
|
+
controller.abort("Request timeout");
|
|
115714
115688
|
}, timeoutMs);
|
|
115715
115689
|
_state.label = 1;
|
|
115716
115690
|
case 1:
|
|
@@ -115730,7 +115704,7 @@ var apiCall = function() {
|
|
|
115730
115704
|
"X-Retry-Count": attempt.toString()
|
|
115731
115705
|
}, api.headers),
|
|
115732
115706
|
body: JSON.stringify(json),
|
|
115733
|
-
signal:
|
|
115707
|
+
signal: controller.signal
|
|
115734
115708
|
})
|
|
115735
115709
|
];
|
|
115736
115710
|
case 2:
|
|
@@ -115820,13 +115794,13 @@ var apiCall = function() {
|
|
|
115820
115794
|
lastChunk = void 0;
|
|
115821
115795
|
chunkCount = 0;
|
|
115822
115796
|
trackingStream = new web.TransformStream({
|
|
115823
|
-
transform: function transform(chunk,
|
|
115797
|
+
transform: function transform(chunk, controller2) {
|
|
115824
115798
|
var _api_span;
|
|
115825
115799
|
lastChunk = chunk;
|
|
115826
115800
|
chunkCount++;
|
|
115827
115801
|
metrics.streamChunks = chunkCount;
|
|
115828
115802
|
metrics.lastChunkTime = Date.now();
|
|
115829
|
-
|
|
115803
|
+
controller2.enqueue(chunk);
|
|
115830
115804
|
(_api_span = api.span) === null || _api_span === void 0 ? void 0 : _api_span.addEvent("stream.chunk", {
|
|
115831
115805
|
"stream.chunks": chunkCount,
|
|
115832
115806
|
"stream.duration": Date.now() - metrics.startTime,
|
|
@@ -115839,7 +115813,7 @@ var apiCall = function() {
|
|
|
115839
115813
|
2,
|
|
115840
115814
|
{
|
|
115841
115815
|
v: new web.ReadableStream({
|
|
115842
|
-
start: function start(
|
|
115816
|
+
start: function start(controller2) {
|
|
115843
115817
|
var reader = res.body.pipeThrough(new textDecoderStream()).pipeThrough(new SSEParser()).pipeThrough(trackingStream).getReader();
|
|
115844
115818
|
function read() {
|
|
115845
115819
|
return _read.apply(this, arguments);
|
|
@@ -115867,7 +115841,7 @@ var apiCall = function() {
|
|
|
115867
115841
|
if (done) {
|
|
115868
115842
|
if (!closed) {
|
|
115869
115843
|
closed = true;
|
|
115870
|
-
|
|
115844
|
+
controller2.close();
|
|
115871
115845
|
}
|
|
115872
115846
|
return [
|
|
115873
115847
|
3,
|
|
@@ -115878,7 +115852,7 @@ var apiCall = function() {
|
|
|
115878
115852
|
3,
|
|
115879
115853
|
3
|
|
115880
115854
|
];
|
|
115881
|
-
|
|
115855
|
+
controller2.enqueue(value);
|
|
115882
115856
|
return [
|
|
115883
115857
|
3,
|
|
115884
115858
|
1
|
|
@@ -115895,16 +115869,16 @@ var apiCall = function() {
|
|
|
115895
115869
|
streamDuration: Date.now() - metrics.startTime
|
|
115896
115870
|
});
|
|
115897
115871
|
if (_$error.name === "AbortError" || ((_error_message = _$error.message) === null || _error_message === void 0 ? void 0 : _error_message.includes("aborted"))) {
|
|
115898
|
-
|
|
115872
|
+
controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
|
|
115899
115873
|
streamMetrics: streamMetrics
|
|
115900
115874
|
}));
|
|
115901
115875
|
} else if (_instanceof(_$error, TypeError) && _$error.message.includes("cancelled")) {
|
|
115902
|
-
|
|
115876
|
+
controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
|
|
115903
115877
|
streamMetrics: streamMetrics,
|
|
115904
115878
|
cancelReason: "Stream cancelled by client"
|
|
115905
115879
|
}));
|
|
115906
115880
|
} else {
|
|
115907
|
-
|
|
115881
|
+
controller2.error(new AxAIServiceNetworkError(_$error, apiUrl.href, json, res.body, {
|
|
115908
115882
|
streamMetrics: streamMetrics
|
|
115909
115883
|
}));
|
|
115910
115884
|
}
|
|
@@ -115936,15 +115910,9 @@ var apiCall = function() {
|
|
|
115936
115910
|
case 9:
|
|
115937
115911
|
error = _state.sent();
|
|
115938
115912
|
if (_instanceof(error, Error) && error.name === "AbortError") {
|
|
115939
|
-
|
|
115940
|
-
|
|
115941
|
-
|
|
115942
|
-
});
|
|
115943
|
-
} else {
|
|
115944
|
-
throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
|
|
115945
|
-
metrics: metrics
|
|
115946
|
-
});
|
|
115947
|
-
}
|
|
115913
|
+
throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
|
|
115914
|
+
metrics: metrics
|
|
115915
|
+
});
|
|
115948
115916
|
}
|
|
115949
115917
|
if ((_api_span2 = api.span) === null || _api_span2 === void 0 ? void 0 : _api_span2.isRecording()) {
|
|
115950
115918
|
api.span.recordException(error);
|
|
@@ -116008,7 +115976,7 @@ var apiCall = function() {
|
|
|
116008
115976
|
api.name
|
|
116009
115977
|
].filter(Boolean).join("/").replace(/\/+/g, "/")).concat(baseUrl.search);
|
|
116010
115978
|
apiUrl = new URL(apiPath, baseUrl);
|
|
116011
|
-
requestId =
|
|
115979
|
+
requestId = crypto.randomUUID();
|
|
116012
115980
|
if (!api.validateRequest) return [
|
|
116013
115981
|
3,
|
|
116014
115982
|
2
|
|
@@ -116182,66 +116150,31 @@ var ColorLog = /*#__PURE__*/ function() {
|
|
|
116182
116150
|
}();
|
|
116183
116151
|
// ai/debug.ts
|
|
116184
116152
|
var colorLog = new ColorLog();
|
|
116185
|
-
var defaultOutput = function(message) {
|
|
116186
|
-
process.stdout.write(message);
|
|
116187
|
-
};
|
|
116188
|
-
var createDefaultLogger = function() {
|
|
116189
|
-
var output = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultOutput;
|
|
116190
|
-
return function(message, options) {
|
|
116191
|
-
var _options_tags;
|
|
116192
|
-
var tags = (_options_tags = options === null || options === void 0 ? void 0 : options.tags) !== null && _options_tags !== void 0 ? _options_tags : [];
|
|
116193
|
-
var formattedMessage = message;
|
|
116194
|
-
if (tags.includes("error")) {
|
|
116195
|
-
formattedMessage = colorLog.red(formattedMessage);
|
|
116196
|
-
} else if (tags.includes("success") || tags.includes("responseContent")) {
|
|
116197
|
-
formattedMessage = colorLog.greenBright(formattedMessage);
|
|
116198
|
-
} else if (tags.includes("functionName")) {
|
|
116199
|
-
formattedMessage = colorLog.whiteBright(formattedMessage);
|
|
116200
|
-
} else if (tags.includes("functionArg") || tags.includes("systemContent") || tags.includes("assistantContent")) {
|
|
116201
|
-
formattedMessage = colorLog.blueBright(formattedMessage);
|
|
116202
|
-
} else if (tags.includes("warning") || tags.includes("discovery")) {
|
|
116203
|
-
formattedMessage = colorLog.yellow(formattedMessage);
|
|
116204
|
-
}
|
|
116205
|
-
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart")) {
|
|
116206
|
-
formattedMessage = "\n".concat(formattedMessage);
|
|
116207
|
-
} else if (tags.includes("responseEnd") || tags.includes("systemEnd") || tags.includes("userEnd")) {
|
|
116208
|
-
formattedMessage = "".concat(formattedMessage, "\n");
|
|
116209
|
-
} else if (tags.includes("assistantStart")) {
|
|
116210
|
-
formattedMessage = "\n".concat(formattedMessage, "\n");
|
|
116211
|
-
} else if (tags.includes("error")) {
|
|
116212
|
-
formattedMessage = "\n".concat(formattedMessage, "\n");
|
|
116213
|
-
} else if (tags.includes("functionEnd")) {
|
|
116214
|
-
formattedMessage = "".concat(formattedMessage, "\n");
|
|
116215
|
-
}
|
|
116216
|
-
output(formattedMessage);
|
|
116217
|
-
};
|
|
116218
|
-
};
|
|
116219
|
-
var defaultLogger = createDefaultLogger();
|
|
116220
116153
|
var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
|
|
116221
116154
|
switch(msg.role){
|
|
116222
116155
|
case "system":
|
|
116223
116156
|
if (hideSystemPrompt) {
|
|
116224
116157
|
return "";
|
|
116225
116158
|
}
|
|
116226
|
-
return "\
|
|
116159
|
+
return "\n".concat(colorLog.blueBright("System:"), "\n").concat(colorLog.whiteBright(msg.content));
|
|
116227
116160
|
case "function":
|
|
116228
|
-
return "\
|
|
116161
|
+
return "\n".concat(colorLog.blueBright("Function Result:"), "\n").concat(colorLog.whiteBright(msg.result));
|
|
116229
116162
|
case "user":
|
|
116230
116163
|
{
|
|
116231
116164
|
if (typeof msg.content === "string") {
|
|
116232
|
-
return "\
|
|
116165
|
+
return "\n".concat(colorLog.blueBright("User:"), "\n").concat(colorLog.whiteBright(msg.content));
|
|
116233
116166
|
}
|
|
116234
116167
|
var items = msg.content.map(function(v) {
|
|
116235
116168
|
switch(v.type){
|
|
116236
116169
|
case "text":
|
|
116237
|
-
return v.text;
|
|
116170
|
+
return "".concat(colorLog.whiteBright(v.text));
|
|
116238
116171
|
case "image":
|
|
116239
|
-
return "(Image, ".concat(v.mimeType, ") ").concat(v.image.substring(0, 10));
|
|
116172
|
+
return "(Image, ".concat(v.mimeType, ") ").concat(colorLog.whiteBright(v.image.substring(0, 10)));
|
|
116240
116173
|
default:
|
|
116241
116174
|
throw new Error("Invalid content type");
|
|
116242
116175
|
}
|
|
116243
116176
|
});
|
|
116244
|
-
return "\
|
|
116177
|
+
return "\n".concat(colorLog.blueBright("User:"), "\n").concat(items.join("\n"));
|
|
116245
116178
|
}
|
|
116246
116179
|
case "assistant":
|
|
116247
116180
|
{
|
|
@@ -116252,106 +116185,46 @@ var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
|
|
|
116252
116185
|
var args = typeof fn.params !== "string" ? JSON.stringify(fn.params, null, 2) : fn.params;
|
|
116253
116186
|
return "".concat(fn.name, "(").concat(args, ")");
|
|
116254
116187
|
});
|
|
116255
|
-
return "\nFunctions
|
|
116188
|
+
return "\n".concat(colorLog.blueBright("\nFunctions:"), "\n").concat(colorLog.whiteBright(fns.join("\n")));
|
|
116256
116189
|
}
|
|
116257
116190
|
var _msg_content;
|
|
116258
|
-
return "\nAssistant
|
|
116191
|
+
return "\n".concat(colorLog.blueBright("\nAssistant:"), "\n").concat(hideContent ? "" : colorLog.whiteBright((_msg_content = msg.content) !== null && _msg_content !== void 0 ? _msg_content : "<empty>"));
|
|
116259
116192
|
}
|
|
116260
116193
|
default:
|
|
116261
116194
|
throw new Error("Invalid role");
|
|
116262
116195
|
}
|
|
116263
116196
|
};
|
|
116264
116197
|
var logChatRequestMessage = function(msg, hideSystemPrompt) {
|
|
116265
|
-
|
|
116266
|
-
|
|
116267
|
-
if (formattedMessage) {
|
|
116268
|
-
var tags = msg.role === "system" ? [
|
|
116269
|
-
"systemStart",
|
|
116270
|
-
"systemContent"
|
|
116271
|
-
] : msg.role === "function" ? [
|
|
116272
|
-
"functionName"
|
|
116273
|
-
] : msg.role === "user" ? [
|
|
116274
|
-
"userStart",
|
|
116275
|
-
"userContent"
|
|
116276
|
-
] : [];
|
|
116277
|
-
logger(formattedMessage, {
|
|
116278
|
-
tags: tags
|
|
116279
|
-
});
|
|
116280
|
-
}
|
|
116281
|
-
logger("Assistant:", {
|
|
116282
|
-
tags: [
|
|
116283
|
-
"assistantStart"
|
|
116284
|
-
]
|
|
116285
|
-
});
|
|
116198
|
+
process.stdout.write("".concat(formatChatMessage(msg, hideSystemPrompt), "\n"));
|
|
116199
|
+
process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
|
|
116286
116200
|
};
|
|
116287
116201
|
var logChatRequest = function(chatPrompt, hideSystemPrompt) {
|
|
116288
|
-
var
|
|
116289
|
-
|
|
116290
|
-
try {
|
|
116291
|
-
for(var _iterator = (chatPrompt !== null && chatPrompt !== void 0 ? chatPrompt : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
116292
|
-
var msg = _step.value;
|
|
116293
|
-
var formattedMessage = formatChatMessage(msg, false, hideSystemPrompt);
|
|
116294
|
-
if (formattedMessage) {
|
|
116295
|
-
var tags = msg.role === "system" ? [
|
|
116296
|
-
"systemContent"
|
|
116297
|
-
] : msg.role === "function" ? [
|
|
116298
|
-
"functionName"
|
|
116299
|
-
] : msg.role === "user" ? [
|
|
116300
|
-
"userContent"
|
|
116301
|
-
] : [];
|
|
116302
|
-
logger(formattedMessage, {
|
|
116303
|
-
tags: tags
|
|
116304
|
-
});
|
|
116305
|
-
}
|
|
116306
|
-
}
|
|
116307
|
-
} catch (err) {
|
|
116308
|
-
_didIteratorError = true;
|
|
116309
|
-
_iteratorError = err;
|
|
116310
|
-
} finally{
|
|
116311
|
-
try {
|
|
116312
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
116313
|
-
_iterator.return();
|
|
116314
|
-
}
|
|
116315
|
-
} finally{
|
|
116316
|
-
if (_didIteratorError) {
|
|
116317
|
-
throw _iteratorError;
|
|
116318
|
-
}
|
|
116319
|
-
}
|
|
116320
|
-
}
|
|
116321
|
-
logger("Assistant:", {
|
|
116322
|
-
tags: [
|
|
116323
|
-
"assistantStart"
|
|
116324
|
-
]
|
|
116202
|
+
var items = chatPrompt === null || chatPrompt === void 0 ? void 0 : chatPrompt.map(function(msg) {
|
|
116203
|
+
return formatChatMessage(msg, hideSystemPrompt);
|
|
116325
116204
|
});
|
|
116205
|
+
if (items) {
|
|
116206
|
+
process.stdout.write(items.join("\n"));
|
|
116207
|
+
process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
|
|
116208
|
+
}
|
|
116326
116209
|
};
|
|
116327
116210
|
var logResponseResult = function(r) {
|
|
116328
|
-
var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
|
|
116329
116211
|
if (r.content) {
|
|
116330
|
-
|
|
116331
|
-
tags: [
|
|
116332
|
-
"responseContent"
|
|
116333
|
-
]
|
|
116334
|
-
});
|
|
116212
|
+
process.stdout.write(colorLog.greenBright(r.content));
|
|
116335
116213
|
}
|
|
116336
|
-
if (r.functionCalls
|
|
116214
|
+
if (r.functionCalls) {
|
|
116337
116215
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
116338
116216
|
try {
|
|
116339
116217
|
for(var _iterator = r.functionCalls.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
116340
116218
|
var _step_value = _sliced_to_array(_step.value, 2), i = _step_value[0], f = _step_value[1];
|
|
116341
116219
|
if (f.function.name) {
|
|
116342
|
-
|
|
116343
|
-
|
|
116344
|
-
|
|
116345
|
-
|
|
116346
|
-
});
|
|
116220
|
+
if (i > 0) {
|
|
116221
|
+
process.stdout.write("\n");
|
|
116222
|
+
}
|
|
116223
|
+
process.stdout.write("Function ".concat(i + 1, " -> ").concat(colorLog.greenBright(f.function.name)));
|
|
116347
116224
|
}
|
|
116348
116225
|
if (f.function.params) {
|
|
116349
116226
|
var params = typeof f.function.params === "string" ? f.function.params : JSON.stringify(f.function.params, null, 2);
|
|
116350
|
-
|
|
116351
|
-
tags: [
|
|
116352
|
-
"functionArg"
|
|
116353
|
-
]
|
|
116354
|
-
});
|
|
116227
|
+
process.stdout.write("".concat(colorLog.greenBright(params)));
|
|
116355
116228
|
}
|
|
116356
116229
|
}
|
|
116357
116230
|
} catch (err) {
|
|
@@ -116368,15 +116241,9 @@ var logResponseResult = function(r) {
|
|
|
116368
116241
|
}
|
|
116369
116242
|
}
|
|
116370
116243
|
}
|
|
116371
|
-
logger("", {
|
|
116372
|
-
tags: [
|
|
116373
|
-
"functionEnd"
|
|
116374
|
-
]
|
|
116375
|
-
});
|
|
116376
116244
|
}
|
|
116377
116245
|
};
|
|
116378
116246
|
var logResponse = function(resp) {
|
|
116379
|
-
var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
|
|
116380
116247
|
if (!resp.results) {
|
|
116381
116248
|
return;
|
|
116382
116249
|
}
|
|
@@ -116384,7 +116251,7 @@ var logResponse = function(resp) {
|
|
|
116384
116251
|
try {
|
|
116385
116252
|
for(var _iterator = resp.results[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
116386
116253
|
var r = _step.value;
|
|
116387
|
-
logResponseResult(r
|
|
116254
|
+
logResponseResult(r);
|
|
116388
116255
|
}
|
|
116389
116256
|
} catch (err) {
|
|
116390
116257
|
_didIteratorError = true;
|
|
@@ -116402,24 +116269,17 @@ var logResponse = function(resp) {
|
|
|
116402
116269
|
}
|
|
116403
116270
|
};
|
|
116404
116271
|
var logResponseDelta = function(delta) {
|
|
116405
|
-
|
|
116406
|
-
logger(delta, {
|
|
116407
|
-
tags: [
|
|
116408
|
-
"responseContent"
|
|
116409
|
-
]
|
|
116410
|
-
});
|
|
116272
|
+
process.stdout.write(colorLog.greenBright(delta));
|
|
116411
116273
|
};
|
|
116412
116274
|
// ai/base.ts
|
|
116413
116275
|
var axBaseAIDefaultConfig = function() {
|
|
116414
116276
|
return structuredClone({
|
|
116277
|
+
maxTokens: 2e3,
|
|
116415
116278
|
temperature: 0,
|
|
116416
116279
|
topK: 40,
|
|
116417
116280
|
topP: 0.9
|
|
116418
116281
|
});
|
|
116419
116282
|
};
|
|
116420
|
-
var defaultLogger2 = function(message, _options) {
|
|
116421
|
-
process.stdout.write(message);
|
|
116422
|
-
};
|
|
116423
116283
|
var AxBaseAI = /*#__PURE__*/ function() {
|
|
116424
116284
|
function AxBaseAI(aiImpl, param) {
|
|
116425
116285
|
var name = param.name, apiURL = param.apiURL, headers = param.headers, modelInfo = param.modelInfo, defaults = param.defaults, _param_options = param.options, options = _param_options === void 0 ? {} : _param_options, supportFor = param.supportFor, models = param.models;
|
|
@@ -116431,8 +116291,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116431
116291
|
_define_property(this, "timeout", void 0);
|
|
116432
116292
|
_define_property(this, "excludeContentFromTrace", void 0);
|
|
116433
116293
|
_define_property(this, "models", void 0);
|
|
116434
|
-
_define_property(this, "abortSignal", void 0);
|
|
116435
|
-
_define_property(this, "logger", defaultLogger2);
|
|
116436
116294
|
_define_property(this, "modelInfo", void 0);
|
|
116437
116295
|
_define_property(this, "modelUsage", void 0);
|
|
116438
116296
|
_define_property(this, "embedModelUsage", void 0);
|
|
@@ -116482,7 +116340,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116482
116340
|
this.tracer = options.tracer;
|
|
116483
116341
|
this.modelInfo = modelInfo;
|
|
116484
116342
|
this.models = models;
|
|
116485
|
-
this.id =
|
|
116343
|
+
this.id = crypto.randomUUID();
|
|
116486
116344
|
var _this_getModel;
|
|
116487
116345
|
var model = (_this_getModel = this.getModel(defaults.model)) !== null && _this_getModel !== void 0 ? _this_getModel : defaults.model;
|
|
116488
116346
|
var _this_getEmbedModel;
|
|
@@ -116534,9 +116392,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116534
116392
|
this.timeout = options.timeout;
|
|
116535
116393
|
this.tracer = options.tracer;
|
|
116536
116394
|
this.excludeContentFromTrace = options.excludeContentFromTrace;
|
|
116537
|
-
this.abortSignal = options.abortSignal;
|
|
116538
|
-
var _options_logger;
|
|
116539
|
-
this.logger = (_options_logger = options.logger) !== null && _options_logger !== void 0 ? _options_logger : defaultLogger2;
|
|
116540
116395
|
}
|
|
116541
116396
|
},
|
|
116542
116397
|
{
|
|
@@ -116548,18 +116403,10 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116548
116403
|
fetch: this.fetch,
|
|
116549
116404
|
tracer: this.tracer,
|
|
116550
116405
|
timeout: this.timeout,
|
|
116551
|
-
excludeContentFromTrace: this.excludeContentFromTrace
|
|
116552
|
-
abortSignal: this.abortSignal,
|
|
116553
|
-
logger: this.logger
|
|
116406
|
+
excludeContentFromTrace: this.excludeContentFromTrace
|
|
116554
116407
|
};
|
|
116555
116408
|
}
|
|
116556
116409
|
},
|
|
116557
|
-
{
|
|
116558
|
-
key: "getLogger",
|
|
116559
|
-
value: function getLogger() {
|
|
116560
|
-
return this.logger;
|
|
116561
|
-
}
|
|
116562
|
-
},
|
|
116563
116410
|
{
|
|
116564
116411
|
key: "getModelList",
|
|
116565
116412
|
value: function getModelList() {
|
|
@@ -116736,7 +116583,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116736
116583
|
value: function _chat1(req, options) {
|
|
116737
116584
|
var _this = this;
|
|
116738
116585
|
return _async_to_generator(function() {
|
|
116739
|
-
var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences,
|
|
116586
|
+
var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences, _options_traceContext, _obj;
|
|
116740
116587
|
return _ts_generator(this, function(_state) {
|
|
116741
116588
|
switch(_state.label){
|
|
116742
116589
|
case 0:
|
|
@@ -116745,9 +116592,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116745
116592
|
if ((options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) && !_this.getFeatures(model).hasThinkingBudget) {
|
|
116746
116593
|
throw new Error("Model ".concat(model, " does not support thinkingTokenBudget."));
|
|
116747
116594
|
}
|
|
116748
|
-
if ((options === null || options === void 0 ? void 0 : options.showThoughts) && !_this.getFeatures(model).hasShowThoughts) {
|
|
116749
|
-
throw new Error("Model ".concat(model, " does not support showThoughts."));
|
|
116750
|
-
}
|
|
116751
116595
|
modelConfig.stream = (_ref1 = (options === null || options === void 0 ? void 0 : options.stream) !== void 0 ? options.stream : modelConfig.stream) !== null && _ref1 !== void 0 ? _ref1 : true;
|
|
116752
116596
|
canStream = _this.getFeatures(model).streaming;
|
|
116753
116597
|
if (!canStream) {
|
|
@@ -116761,7 +116605,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116761
116605
|
4,
|
|
116762
116606
|
_this.tracer.startActiveSpan("AI Chat Request", {
|
|
116763
116607
|
kind: SpanKind.SERVER,
|
|
116764
|
-
attributes: (_obj = {}, _define_property(_obj, axSpanAttributes.LLM_SYSTEM, _this.name), _define_property(_obj, axSpanAttributes.LLM_OPERATION_NAME, "chat"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MODEL, model), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MAX_TOKENS,
|
|
116608
|
+
attributes: (_obj = {}, _define_property(_obj, axSpanAttributes.LLM_SYSTEM, _this.name), _define_property(_obj, axSpanAttributes.LLM_OPERATION_NAME, "chat"), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MODEL, model), _define_property(_obj, axSpanAttributes.LLM_REQUEST_MAX_TOKENS, modelConfig.maxTokens), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TEMPERATURE, modelConfig.temperature), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_P, modelConfig.topP), _define_property(_obj, axSpanAttributes.LLM_REQUEST_TOP_K, modelConfig.topK), _define_property(_obj, axSpanAttributes.LLM_REQUEST_FREQUENCY_PENALTY, modelConfig.frequencyPenalty), _define_property(_obj, axSpanAttributes.LLM_REQUEST_PRESENCE_PENALTY, modelConfig.presencePenalty), _define_property(_obj, axSpanAttributes.LLM_REQUEST_STOP_SEQUENCES, (_modelConfig_stopSequences = modelConfig.stopSequences) === null || _modelConfig_stopSequences === void 0 ? void 0 : _modelConfig_stopSequences.join(", ")), _define_property(_obj, axSpanAttributes.LLM_REQUEST_LLM_IS_STREAMING, modelConfig.stream), _obj)
|
|
116765
116609
|
}, (_options_traceContext = options === null || options === void 0 ? void 0 : options.traceContext) !== null && _options_traceContext !== void 0 ? _options_traceContext : context.active(), function() {
|
|
116766
116610
|
var _ref = _async_to_generator(function(span) {
|
|
116767
116611
|
return _ts_generator(this, function(_state) {
|
|
@@ -116830,7 +116674,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116830
116674
|
value: function _chat2(model, modelConfig, chatReq, options, span) {
|
|
116831
116675
|
var _this = this;
|
|
116832
116676
|
return _async_to_generator(function() {
|
|
116833
|
-
var _options_debug, debug, functions, req, fn,
|
|
116677
|
+
var _options_debug, debug, functions, req, fn, _options_rateLimiter, rt, rv, _tmp, respFn, wrappedRespFn, doneCb, st, res, tokenUsage;
|
|
116834
116678
|
return _ts_generator(this, function(_state) {
|
|
116835
116679
|
switch(_state.label){
|
|
116836
116680
|
case 0:
|
|
@@ -116852,7 +116696,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116852
116696
|
_this.lastUsedModelConfig = modelConfig;
|
|
116853
116697
|
fn = function() {
|
|
116854
116698
|
var _ref = _async_to_generator(function() {
|
|
116855
|
-
var _this_aiImpl_createChatReq, apiConfig, reqValue,
|
|
116699
|
+
var _this_aiImpl_createChatReq, apiConfig, reqValue, res2, _tmp;
|
|
116856
116700
|
return _ts_generator(this, function(_state) {
|
|
116857
116701
|
switch(_state.label){
|
|
116858
116702
|
case 0:
|
|
@@ -116872,7 +116716,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116872
116716
|
return [
|
|
116873
116717
|
4,
|
|
116874
116718
|
apiCall.apply(void 0, [
|
|
116875
|
-
(_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp
|
|
116719
|
+
(_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp),
|
|
116876
116720
|
reqValue
|
|
116877
116721
|
])
|
|
116878
116722
|
];
|
|
@@ -116890,7 +116734,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116890
116734
|
};
|
|
116891
116735
|
}();
|
|
116892
116736
|
if (debug) {
|
|
116893
|
-
logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt
|
|
116737
|
+
logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt);
|
|
116894
116738
|
}
|
|
116895
116739
|
rt = (_options_rateLimiter = options === null || options === void 0 ? void 0 : options.rateLimiter) !== null && _options_rateLimiter !== void 0 ? _options_rateLimiter : _this.rt;
|
|
116896
116740
|
if (!rt) return [
|
|
@@ -116928,6 +116772,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116928
116772
|
return function(resp) {
|
|
116929
116773
|
var res2 = respFn(resp, state);
|
|
116930
116774
|
res2.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
|
|
116775
|
+
if (options === null || options === void 0 ? void 0 : options.hideThought) {
|
|
116776
|
+
res2.results.forEach(function(result) {
|
|
116777
|
+
if (result.thought) {
|
|
116778
|
+
result.thought = void 0;
|
|
116779
|
+
}
|
|
116780
|
+
});
|
|
116781
|
+
}
|
|
116931
116782
|
if (!res2.modelUsage) {
|
|
116932
116783
|
res2.modelUsage = {
|
|
116933
116784
|
ai: _this.name,
|
|
@@ -116940,23 +116791,16 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116940
116791
|
setChatResponseEvents(res2, span, _this.excludeContentFromTrace);
|
|
116941
116792
|
}
|
|
116942
116793
|
if (debug) {
|
|
116943
|
-
|
|
116944
|
-
logResponse(res2, (_options_logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger);
|
|
116794
|
+
logResponse(res2);
|
|
116945
116795
|
}
|
|
116946
116796
|
return res2;
|
|
116947
116797
|
};
|
|
116948
116798
|
};
|
|
116949
116799
|
doneCb = function() {
|
|
116950
116800
|
var _ref = _async_to_generator(function(_values) {
|
|
116951
|
-
var _options_logger, logger;
|
|
116952
116801
|
return _ts_generator(this, function(_state) {
|
|
116953
116802
|
if (debug) {
|
|
116954
|
-
|
|
116955
|
-
logger("", {
|
|
116956
|
-
tags: [
|
|
116957
|
-
"responseEnd"
|
|
116958
|
-
]
|
|
116959
|
-
});
|
|
116803
|
+
process.stdout.write("\n");
|
|
116960
116804
|
}
|
|
116961
116805
|
if (span === null || span === void 0 ? void 0 : span.isRecording()) {
|
|
116962
116806
|
span.end();
|
|
@@ -116981,6 +116825,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116981
116825
|
}
|
|
116982
116826
|
res = _this.aiImpl.createChatResp(rv);
|
|
116983
116827
|
res.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
|
|
116828
|
+
if (options === null || options === void 0 ? void 0 : options.hideThought) {
|
|
116829
|
+
res.results.forEach(function(result) {
|
|
116830
|
+
if (result.thought) {
|
|
116831
|
+
result.thought = void 0;
|
|
116832
|
+
}
|
|
116833
|
+
});
|
|
116834
|
+
}
|
|
116984
116835
|
if (!res.modelUsage) {
|
|
116985
116836
|
tokenUsage = _this.aiImpl.getTokenUsage();
|
|
116986
116837
|
if (tokenUsage) {
|
|
@@ -116999,14 +116850,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
116999
116850
|
span.end();
|
|
117000
116851
|
}
|
|
117001
116852
|
if (debug) {
|
|
117002
|
-
logResponse(res
|
|
117003
|
-
}
|
|
117004
|
-
if (debug) {
|
|
117005
|
-
_this.logger("", {
|
|
117006
|
-
tags: [
|
|
117007
|
-
"responseEnd"
|
|
117008
|
-
]
|
|
117009
|
-
});
|
|
116853
|
+
logResponse(res);
|
|
117010
116854
|
}
|
|
117011
116855
|
return [
|
|
117012
116856
|
2,
|
|
@@ -117140,7 +116984,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
117140
116984
|
_this.lastUsedEmbedModel = embedModel;
|
|
117141
116985
|
fn = function() {
|
|
117142
116986
|
var _ref = _async_to_generator(function() {
|
|
117143
|
-
var _this_aiImpl_createEmbedReq, apiConfig, reqValue,
|
|
116987
|
+
var _this_aiImpl_createEmbedReq, apiConfig, reqValue, res2, _tmp;
|
|
117144
116988
|
return _ts_generator(this, function(_state) {
|
|
117145
116989
|
switch(_state.label){
|
|
117146
116990
|
case 0:
|
|
@@ -117157,7 +117001,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
117157
117001
|
return [
|
|
117158
117002
|
4,
|
|
117159
117003
|
apiCall.apply(void 0, [
|
|
117160
|
-
(_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp
|
|
117004
|
+
(_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp),
|
|
117161
117005
|
reqValue
|
|
117162
117006
|
])
|
|
117163
117007
|
];
|
|
@@ -117397,40 +117241,50 @@ function setChatResponseEvents(res, span, excludeContentFromTrace) {
|
|
|
117397
117241
|
if (!res.results) {
|
|
117398
117242
|
return;
|
|
117399
117243
|
}
|
|
117400
|
-
|
|
117401
|
-
|
|
117402
|
-
var
|
|
117403
|
-
|
|
117404
|
-
|
|
117405
|
-
|
|
117406
|
-
|
|
117407
|
-
|
|
117244
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
117245
|
+
try {
|
|
117246
|
+
for(var _iterator = res.results.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
117247
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], result = _step_value[1];
|
|
117248
|
+
var _result_functionCalls;
|
|
117249
|
+
var toolCalls = (_result_functionCalls = result.functionCalls) === null || _result_functionCalls === void 0 ? void 0 : _result_functionCalls.map(function(call) {
|
|
117250
|
+
return {
|
|
117251
|
+
id: call.id,
|
|
117252
|
+
type: call.type,
|
|
117253
|
+
function: call.function.name,
|
|
117254
|
+
arguments: call.function.params
|
|
117255
|
+
};
|
|
117256
|
+
});
|
|
117257
|
+
var message = {};
|
|
117258
|
+
if (toolCalls && toolCalls.length > 0) {
|
|
117259
|
+
if (!excludeContentFromTrace) {
|
|
117260
|
+
message.content = result.content;
|
|
117261
|
+
}
|
|
117262
|
+
message.tool_calls = toolCalls;
|
|
117263
|
+
} else {
|
|
117264
|
+
if (!excludeContentFromTrace) {
|
|
117265
|
+
var _result_content;
|
|
117266
|
+
message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
|
|
117267
|
+
}
|
|
117268
|
+
}
|
|
117269
|
+
span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
|
|
117270
|
+
finish_reason: result.finishReason,
|
|
117271
|
+
index: index,
|
|
117272
|
+
message: JSON.stringify(message, null, 2)
|
|
117273
|
+
});
|
|
117408
117274
|
}
|
|
117409
|
-
|
|
117410
|
-
|
|
117411
|
-
|
|
117412
|
-
|
|
117413
|
-
|
|
117414
|
-
|
|
117415
|
-
|
|
117416
|
-
});
|
|
117417
|
-
var message = {};
|
|
117418
|
-
if (toolCalls && toolCalls.length > 0) {
|
|
117419
|
-
if (!excludeContentFromTrace) {
|
|
117420
|
-
message.content = result.content;
|
|
117275
|
+
} catch (err) {
|
|
117276
|
+
_didIteratorError = true;
|
|
117277
|
+
_iteratorError = err;
|
|
117278
|
+
} finally{
|
|
117279
|
+
try {
|
|
117280
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
117281
|
+
_iterator.return();
|
|
117421
117282
|
}
|
|
117422
|
-
|
|
117423
|
-
|
|
117424
|
-
|
|
117425
|
-
var _result_content;
|
|
117426
|
-
message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
|
|
117283
|
+
} finally{
|
|
117284
|
+
if (_didIteratorError) {
|
|
117285
|
+
throw _iteratorError;
|
|
117427
117286
|
}
|
|
117428
117287
|
}
|
|
117429
|
-
span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
|
|
117430
|
-
finish_reason: result.finishReason,
|
|
117431
|
-
index: index,
|
|
117432
|
-
message: JSON.stringify(message, null, 2)
|
|
117433
|
-
});
|
|
117434
117288
|
}
|
|
117435
117289
|
}
|
|
117436
117290
|
function validateModels(models) {
|
|
@@ -117539,80 +117393,50 @@ var GoogleVertexAuth = /*#__PURE__*/ function() {
|
|
|
117539
117393
|
}();
|
|
117540
117394
|
// ai/anthropic/info.ts
|
|
117541
117395
|
var axModelInfoAnthropic = [
|
|
117542
|
-
//
|
|
117543
|
-
{
|
|
117544
|
-
name: "claude-opus-4-20250514" /* Claude4Opus */ ,
|
|
117545
|
-
currency: "usd",
|
|
117546
|
-
promptTokenCostPer1M: 15,
|
|
117547
|
-
completionTokenCostPer1M: 75,
|
|
117548
|
-
maxTokens: 32e3
|
|
117549
|
-
},
|
|
117550
|
-
{
|
|
117551
|
-
name: "claude-sonnet-4-20250514" /* Claude4Sonnet */ ,
|
|
117552
|
-
currency: "usd",
|
|
117553
|
-
promptTokenCostPer1M: 3,
|
|
117554
|
-
completionTokenCostPer1M: 15,
|
|
117555
|
-
maxTokens: 64e3
|
|
117556
|
-
},
|
|
117557
|
-
// 3.7
|
|
117558
|
-
{
|
|
117559
|
-
name: "claude-3-7-sonnet-latest" /* Claude37Sonnet */ ,
|
|
117560
|
-
currency: "usd",
|
|
117561
|
-
promptTokenCostPer1M: 3,
|
|
117562
|
-
completionTokenCostPer1M: 15,
|
|
117563
|
-
maxTokens: 64e3
|
|
117564
|
-
},
|
|
117565
|
-
// 3.5
|
|
117396
|
+
// 35
|
|
117566
117397
|
{
|
|
117567
117398
|
name: "claude-3-5-sonnet-latest" /* Claude35Sonnet */ ,
|
|
117568
117399
|
currency: "usd",
|
|
117569
117400
|
promptTokenCostPer1M: 3,
|
|
117570
|
-
completionTokenCostPer1M: 15
|
|
117571
|
-
maxTokens: 8192
|
|
117401
|
+
completionTokenCostPer1M: 15
|
|
117572
117402
|
},
|
|
117573
117403
|
{
|
|
117574
117404
|
name: "claude-3-5-haiku-latest" /* Claude35Haiku */ ,
|
|
117575
117405
|
currency: "usd",
|
|
117576
117406
|
promptTokenCostPer1M: 0.8,
|
|
117577
|
-
completionTokenCostPer1M: 4
|
|
117578
|
-
maxTokens: 8192
|
|
117407
|
+
completionTokenCostPer1M: 4
|
|
117579
117408
|
},
|
|
117580
117409
|
// 3
|
|
117581
117410
|
{
|
|
117582
117411
|
name: "claude-3-opus-latest" /* Claude3Opus */ ,
|
|
117583
117412
|
currency: "usd",
|
|
117584
117413
|
promptTokenCostPer1M: 15,
|
|
117585
|
-
completionTokenCostPer1M: 75
|
|
117586
|
-
maxTokens: 4096
|
|
117414
|
+
completionTokenCostPer1M: 75
|
|
117587
117415
|
},
|
|
117588
117416
|
{
|
|
117589
117417
|
name: "claude-3-sonnet-20240229" /* Claude3Sonnet */ ,
|
|
117590
117418
|
currency: "usd",
|
|
117591
117419
|
promptTokenCostPer1M: 3,
|
|
117592
|
-
completionTokenCostPer1M: 15
|
|
117593
|
-
maxTokens: 4096
|
|
117420
|
+
completionTokenCostPer1M: 15
|
|
117594
117421
|
},
|
|
117595
117422
|
{
|
|
117596
117423
|
name: "claude-3-haiku-20240307" /* Claude3Haiku */ ,
|
|
117597
117424
|
currency: "usd",
|
|
117598
117425
|
promptTokenCostPer1M: 0.25,
|
|
117599
|
-
completionTokenCostPer1M: 1.25
|
|
117600
|
-
maxTokens: 4096
|
|
117426
|
+
completionTokenCostPer1M: 1.25
|
|
117601
117427
|
},
|
|
117602
|
-
//
|
|
117428
|
+
// 21
|
|
117603
117429
|
{
|
|
117604
117430
|
name: "claude-2.1" /* Claude21 */ ,
|
|
117605
117431
|
currency: "usd",
|
|
117606
117432
|
promptTokenCostPer1M: 8,
|
|
117607
|
-
completionTokenCostPer1M: 25
|
|
117608
|
-
maxTokens: 4096
|
|
117433
|
+
completionTokenCostPer1M: 25
|
|
117609
117434
|
},
|
|
117610
117435
|
{
|
|
117611
117436
|
name: "claude-instant-1.2" /* ClaudeInstant12 */ ,
|
|
117612
117437
|
currency: "usd",
|
|
117613
117438
|
promptTokenCostPer1M: 0.8,
|
|
117614
|
-
completionTokenCostPer1M: 2.24
|
|
117615
|
-
maxTokens: 4096
|
|
117439
|
+
completionTokenCostPer1M: 2.24
|
|
117616
117440
|
}
|
|
117617
117441
|
];
|
|
117618
117442
|
// ai/anthropic/api.ts
|
|
@@ -117696,31 +117520,18 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
|
|
|
117696
117520
|
input_schema: v.parameters
|
|
117697
117521
|
};
|
|
117698
117522
|
});
|
|
117699
|
-
var _req_modelConfig_maxTokens;
|
|
117700
|
-
var
|
|
117701
|
-
var _req_modelConfig_stopSequences;
|
|
117702
|
-
var stopSequences = (_req_modelConfig_stopSequences = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences;
|
|
117703
|
-
var _req_modelConfig_temperature;
|
|
117704
|
-
var temperature = (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature;
|
|
117705
|
-
var _req_modelConfig_topP;
|
|
117706
|
-
var topP = (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP;
|
|
117707
|
-
var _req_modelConfig_topK;
|
|
117708
|
-
var topK = (_req_modelConfig_topK = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topK) !== null && _req_modelConfig_topK !== void 0 ? _req_modelConfig_topK : _this.config.topK;
|
|
117709
|
-
var reqValue = _object_spread_props(_object_spread({}, _this.isVertex ? {
|
|
117523
|
+
var _req_modelConfig_maxTokens, _req_modelConfig_stopSequences, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK;
|
|
117524
|
+
var reqValue = _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, _this.isVertex ? {
|
|
117710
117525
|
anthropic_version: "vertex-2023-10-16"
|
|
117711
117526
|
} : {
|
|
117712
117527
|
model: model
|
|
117713
|
-
},
|
|
117714
|
-
max_tokens: maxTokens
|
|
117715
|
-
|
|
117716
|
-
|
|
117717
|
-
|
|
117718
|
-
|
|
117719
|
-
}
|
|
117720
|
-
top_p: topP
|
|
117721
|
-
} : {}, topK ? {
|
|
117722
|
-
top_k: topK
|
|
117723
|
-
} : {}, toolsChoice, tools && tools.length > 0 ? {
|
|
117528
|
+
}), {
|
|
117529
|
+
max_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
|
|
117530
|
+
stop_sequences: (_req_modelConfig_stopSequences = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences,
|
|
117531
|
+
temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature,
|
|
117532
|
+
top_p: (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP,
|
|
117533
|
+
top_k: (_req_modelConfig_topK = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topK) !== null && _req_modelConfig_topK !== void 0 ? _req_modelConfig_topK : _this.config.topK
|
|
117534
|
+
}), toolsChoice, tools && tools.length > 0 ? {
|
|
117724
117535
|
tools: tools
|
|
117725
117536
|
} : {}, stream ? {
|
|
117726
117537
|
stream: true
|
|
@@ -117911,9 +117722,8 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
|
|
|
117911
117722
|
key: "getModelConfig",
|
|
117912
117723
|
value: function getModelConfig() {
|
|
117913
117724
|
var config = this.config;
|
|
117914
|
-
var _config_maxTokens;
|
|
117915
117725
|
return {
|
|
117916
|
-
maxTokens:
|
|
117726
|
+
maxTokens: config.maxTokens,
|
|
117917
117727
|
temperature: config.temperature,
|
|
117918
117728
|
topP: config.topP,
|
|
117919
117729
|
topK: config.topK,
|
|
@@ -118346,7 +118156,7 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
118346
118156
|
var _req_modelConfig_stream;
|
|
118347
118157
|
var stream = (_req_modelConfig_stream = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.stream) !== null && _req_modelConfig_stream !== void 0 ? _req_modelConfig_stream : this.config.stream;
|
|
118348
118158
|
var store = this.config.store;
|
|
118349
|
-
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP,
|
|
118159
|
+
var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_topP, _ref1, _req_modelConfig_n, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
|
|
118350
118160
|
var reqValue = _object_spread({
|
|
118351
118161
|
model: model,
|
|
118352
118162
|
messages: messages,
|
|
@@ -118355,9 +118165,9 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
118355
118165
|
} : void 0,
|
|
118356
118166
|
tools: tools,
|
|
118357
118167
|
tool_choice: toolsChoice,
|
|
118358
|
-
max_completion_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : this.config.maxTokens,
|
|
118168
|
+
max_completion_tokens: (_ref = (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : this.config.maxTokens) !== null && _ref !== void 0 ? _ref : 500,
|
|
118359
118169
|
temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : this.config.temperature,
|
|
118360
|
-
top_p: (
|
|
118170
|
+
top_p: (_ref1 = (_req_modelConfig_topP = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : this.config.topP) !== null && _ref1 !== void 0 ? _ref1 : 1,
|
|
118361
118171
|
n: (_req_modelConfig_n = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.n) !== null && _req_modelConfig_n !== void 0 ? _req_modelConfig_n : this.config.n,
|
|
118362
118172
|
stop: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : this.config.stop,
|
|
118363
118173
|
presence_penalty: (_req_modelConfig_presencePenalty = (_req_modelConfig7 = req.modelConfig) === null || _req_modelConfig7 === void 0 ? void 0 : _req_modelConfig7.presencePenalty) !== null && _req_modelConfig_presencePenalty !== void 0 ? _req_modelConfig_presencePenalty : this.config.presencePenalty,
|
|
@@ -118400,9 +118210,6 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
118400
118210
|
}
|
|
118401
118211
|
if (config.thinkingTokenBudget) {
|
|
118402
118212
|
switch(config.thinkingTokenBudget){
|
|
118403
|
-
case "none":
|
|
118404
|
-
reqValue.reasoning_effort = void 0;
|
|
118405
|
-
break;
|
|
118406
118213
|
case "minimal":
|
|
118407
118214
|
reqValue.reasoning_effort = "low";
|
|
118408
118215
|
break;
|
|
@@ -119550,9 +119357,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
119550
119357
|
}
|
|
119551
119358
|
if (config.thinkingTokenBudget) {
|
|
119552
119359
|
switch(config.thinkingTokenBudget){
|
|
119553
|
-
case "none":
|
|
119554
|
-
thinkingConfig.thinkingBudget = 0;
|
|
119555
|
-
break;
|
|
119556
119360
|
case "minimal":
|
|
119557
119361
|
thinkingConfig.thinkingBudget = 200;
|
|
119558
119362
|
break;
|
|
@@ -119570,9 +119374,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
119570
119374
|
break;
|
|
119571
119375
|
}
|
|
119572
119376
|
}
|
|
119573
|
-
if (config.showThoughts !== void 0) {
|
|
119574
|
-
thinkingConfig.includeThoughts = config.showThoughts;
|
|
119575
|
-
}
|
|
119576
119377
|
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK, _req_modelConfig_frequencyPenalty, _req_modelConfig_stopSequences;
|
|
119577
119378
|
var generationConfig = _object_spread({
|
|
119578
119379
|
maxOutputTokens: (_req_modelConfig_maxTokens = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
|
|
@@ -119583,7 +119384,7 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
119583
119384
|
candidateCount: 1,
|
|
119584
119385
|
stopSequences: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stopSequences,
|
|
119585
119386
|
responseMimeType: "text/plain"
|
|
119586
|
-
},
|
|
119387
|
+
}, thinkingConfig ? {
|
|
119587
119388
|
thinkingConfig: thinkingConfig
|
|
119588
119389
|
} : {});
|
|
119589
119390
|
var safetySettings2 = _this.config.safetySettings;
|
|
@@ -120304,6 +120105,7 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
|
|
|
120304
120105
|
function AxAIMistral(param) {
|
|
120305
120106
|
var apiKey = param.apiKey, config = param.config, options = param.options, models = param.models, modelInfo = param.modelInfo;
|
|
120306
120107
|
_class_call_check(this, AxAIMistral);
|
|
120108
|
+
var _this;
|
|
120307
120109
|
if (!apiKey || apiKey === "") {
|
|
120308
120110
|
throw new Error("Mistral API key not set");
|
|
120309
120111
|
}
|
|
@@ -120316,15 +120118,17 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
|
|
|
120316
120118
|
hasShowThoughts: false
|
|
120317
120119
|
};
|
|
120318
120120
|
var chatReqUpdater = function(req) {
|
|
120319
|
-
var max_completion_tokens = req.max_completion_tokens; req.stream_options; var result = _object_without_properties(req, [
|
|
120121
|
+
var max_completion_tokens = req.max_completion_tokens; req.stream_options; var messages = req.messages, result = _object_without_properties(req, [
|
|
120320
120122
|
"max_completion_tokens",
|
|
120321
|
-
"stream_options"
|
|
120123
|
+
"stream_options",
|
|
120124
|
+
"messages"
|
|
120322
120125
|
]);
|
|
120323
120126
|
return _object_spread_props(_object_spread({}, result), {
|
|
120127
|
+
messages: _this.updateMessages(messages),
|
|
120324
120128
|
max_tokens: max_completion_tokens
|
|
120325
120129
|
});
|
|
120326
120130
|
};
|
|
120327
|
-
|
|
120131
|
+
_this = _super.call(this, {
|
|
120328
120132
|
apiKey: apiKey,
|
|
120329
120133
|
config: _config,
|
|
120330
120134
|
options: options,
|
|
@@ -120332,11 +120136,60 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
|
|
|
120332
120136
|
modelInfo: modelInfo,
|
|
120333
120137
|
models: models,
|
|
120334
120138
|
supportFor: supportFor,
|
|
120139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120335
120140
|
chatReqUpdater: chatReqUpdater
|
|
120336
120141
|
});
|
|
120337
120142
|
_get((_assert_this_initialized(_this), _get_prototype_of(AxAIMistral.prototype)), "setName", _this).call(_this, "Mistral");
|
|
120338
120143
|
return _this;
|
|
120339
120144
|
}
|
|
120145
|
+
_create_class(AxAIMistral, [
|
|
120146
|
+
{
|
|
120147
|
+
key: "updateMessages",
|
|
120148
|
+
value: function updateMessages(messages) {
|
|
120149
|
+
var messagesUpdated = [];
|
|
120150
|
+
if (!Array.isArray(messages)) {
|
|
120151
|
+
return messages;
|
|
120152
|
+
}
|
|
120153
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
120154
|
+
try {
|
|
120155
|
+
for(var _iterator = messages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
120156
|
+
var message = _step.value;
|
|
120157
|
+
if (message.role === "user" && Array.isArray(message.content)) {
|
|
120158
|
+
var contentUpdated = message.content.map(function(item) {
|
|
120159
|
+
if (typeof item === "object" && item !== null && item.type === "image_url") {
|
|
120160
|
+
var _item_image_url;
|
|
120161
|
+
return {
|
|
120162
|
+
type: "image_url",
|
|
120163
|
+
image_url: (_item_image_url = item.image_url) === null || _item_image_url === void 0 ? void 0 : _item_image_url.url
|
|
120164
|
+
};
|
|
120165
|
+
}
|
|
120166
|
+
return item;
|
|
120167
|
+
});
|
|
120168
|
+
messagesUpdated.push(_object_spread_props(_object_spread({}, message), {
|
|
120169
|
+
content: contentUpdated
|
|
120170
|
+
}));
|
|
120171
|
+
} else {
|
|
120172
|
+
messagesUpdated.push(message);
|
|
120173
|
+
}
|
|
120174
|
+
}
|
|
120175
|
+
} catch (err) {
|
|
120176
|
+
_didIteratorError = true;
|
|
120177
|
+
_iteratorError = err;
|
|
120178
|
+
} finally{
|
|
120179
|
+
try {
|
|
120180
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
120181
|
+
_iterator.return();
|
|
120182
|
+
}
|
|
120183
|
+
} finally{
|
|
120184
|
+
if (_didIteratorError) {
|
|
120185
|
+
throw _iteratorError;
|
|
120186
|
+
}
|
|
120187
|
+
}
|
|
120188
|
+
}
|
|
120189
|
+
return messagesUpdated;
|
|
120190
|
+
}
|
|
120191
|
+
}
|
|
120192
|
+
]);
|
|
120340
120193
|
return AxAIMistral;
|
|
120341
120194
|
}(AxAIOpenAIBase);
|
|
120342
120195
|
// ai/ollama/api.ts
|
|
@@ -120559,7 +120412,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120559
120412
|
},
|
|
120560
120413
|
{
|
|
120561
120414
|
key: "createChatReq",
|
|
120562
|
-
value: function createChatReq(req,
|
|
120415
|
+
value: function createChatReq(req, _config) {
|
|
120563
120416
|
var _req_functions, _req_modelConfig, _req_modelConfig1, _req_modelConfig2, _req_modelConfig3, _req_chatPrompt_, _req_chatPrompt_1;
|
|
120564
120417
|
var model = req.model;
|
|
120565
120418
|
var apiConfig = {
|
|
@@ -120604,10 +120457,6 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120604
120457
|
parameters: (_v_parameters = v.parameters) !== null && _v_parameters !== void 0 ? _v_parameters : {}
|
|
120605
120458
|
};
|
|
120606
120459
|
});
|
|
120607
|
-
var includeFields = [];
|
|
120608
|
-
if (config.showThoughts) {
|
|
120609
|
-
includeFields.push("reasoning.encrypted_content");
|
|
120610
|
-
}
|
|
120611
120460
|
var _req_modelConfig_maxTokens, _ref1, _req_modelConfig_temperature, _ref2, _req_modelConfig_topP, _ref3, _req_modelConfig_stream, _ref4;
|
|
120612
120461
|
var mutableReq = {
|
|
120613
120462
|
model: model,
|
|
@@ -120626,7 +120475,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120626
120475
|
// Sourced from modelConfig or global config
|
|
120627
120476
|
// Optional fields from AxAIOpenAIResponsesRequest that need to be in Mutable for initialization
|
|
120628
120477
|
background: void 0,
|
|
120629
|
-
include:
|
|
120478
|
+
include: void 0,
|
|
120630
120479
|
metadata: void 0,
|
|
120631
120480
|
parallel_tool_calls: this.config.parallelToolCalls,
|
|
120632
120481
|
previous_response_id: void 0,
|
|
@@ -120701,13 +120550,9 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120701
120550
|
break;
|
|
120702
120551
|
case "reasoning":
|
|
120703
120552
|
currentResult.id = item.id;
|
|
120704
|
-
|
|
120705
|
-
|
|
120706
|
-
}
|
|
120707
|
-
currentResult.thought = item.summary.map(function(s) {
|
|
120708
|
-
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
120709
|
-
}).join("\n");
|
|
120710
|
-
}
|
|
120553
|
+
currentResult.thought = item.summary.map(function(s) {
|
|
120554
|
+
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
120555
|
+
}).join("\n");
|
|
120711
120556
|
break;
|
|
120712
120557
|
case "file_search_call":
|
|
120713
120558
|
currentResult.id = item.id;
|
|
@@ -121047,9 +120892,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
121047
120892
|
{
|
|
121048
120893
|
var reasoningItem = event.item;
|
|
121049
120894
|
baseResult.id = event.item.id;
|
|
121050
|
-
if (reasoningItem.
|
|
121051
|
-
baseResult.thought = reasoningItem.encrypted_content;
|
|
121052
|
-
} else if (reasoningItem.summary) {
|
|
120895
|
+
if (reasoningItem.summary) {
|
|
121053
120896
|
baseResult.thought = reasoningItem.summary.map(function(s) {
|
|
121054
120897
|
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
121055
120898
|
}).join("\n");
|
|
@@ -121277,6 +121120,7 @@ var axAIOpenAIResponsesDefaultConfig = function() {
|
|
|
121277
121120
|
model: "gpt-4o" /* GPT4O */ ,
|
|
121278
121121
|
embedModel: "text-embedding-ada-002" /* TextEmbeddingAda002 */ ,
|
|
121279
121122
|
temperature: 0.7,
|
|
121123
|
+
maxTokens: 2048,
|
|
121280
121124
|
topP: 1,
|
|
121281
121125
|
stream: true
|
|
121282
121126
|
};
|
|
@@ -121402,14 +121246,14 @@ var AxAIRekaImpl = /*#__PURE__*/ function() {
|
|
|
121402
121246
|
var frequencyPenalty = (_req_modelConfig_frequencyPenalty = (_req_modelConfig = req.modelConfig) === null || _req_modelConfig === void 0 ? void 0 : _req_modelConfig.frequencyPenalty) !== null && _req_modelConfig_frequencyPenalty !== void 0 ? _req_modelConfig_frequencyPenalty : _this.config.frequencyPenalty;
|
|
121403
121247
|
var _req_modelConfig_stream;
|
|
121404
121248
|
var stream = (_req_modelConfig_stream = (_req_modelConfig1 = req.modelConfig) === null || _req_modelConfig1 === void 0 ? void 0 : _req_modelConfig1.stream) !== null && _req_modelConfig_stream !== void 0 ? _req_modelConfig_stream : _this.config.stream;
|
|
121405
|
-
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP,
|
|
121249
|
+
var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP, _ref1, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
|
|
121406
121250
|
var reqValue = _object_spread({
|
|
121407
121251
|
model: model,
|
|
121408
121252
|
messages: messages,
|
|
121409
|
-
max_tokens: (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens,
|
|
121253
|
+
max_tokens: (_ref = (_req_modelConfig_maxTokens = (_req_modelConfig2 = req.modelConfig) === null || _req_modelConfig2 === void 0 ? void 0 : _req_modelConfig2.maxTokens) !== null && _req_modelConfig_maxTokens !== void 0 ? _req_modelConfig_maxTokens : _this.config.maxTokens) !== null && _ref !== void 0 ? _ref : 500,
|
|
121410
121254
|
temperature: (_req_modelConfig_temperature = (_req_modelConfig3 = req.modelConfig) === null || _req_modelConfig3 === void 0 ? void 0 : _req_modelConfig3.temperature) !== null && _req_modelConfig_temperature !== void 0 ? _req_modelConfig_temperature : _this.config.temperature,
|
|
121411
121255
|
top_k: (_req_modelConfig_n = (_req_modelConfig4 = req.modelConfig) === null || _req_modelConfig4 === void 0 ? void 0 : _req_modelConfig4.n) !== null && _req_modelConfig_n !== void 0 ? _req_modelConfig_n : _this.config.n,
|
|
121412
|
-
top_p: (
|
|
121256
|
+
top_p: (_ref1 = (_req_modelConfig_topP = (_req_modelConfig5 = req.modelConfig) === null || _req_modelConfig5 === void 0 ? void 0 : _req_modelConfig5.topP) !== null && _req_modelConfig_topP !== void 0 ? _req_modelConfig_topP : _this.config.topP) !== null && _ref1 !== void 0 ? _ref1 : 1,
|
|
121413
121257
|
stop: (_req_modelConfig_stopSequences = (_req_modelConfig6 = req.modelConfig) === null || _req_modelConfig6 === void 0 ? void 0 : _req_modelConfig6.stopSequences) !== null && _req_modelConfig_stopSequences !== void 0 ? _req_modelConfig_stopSequences : _this.config.stop,
|
|
121414
121258
|
presence_penalty: (_req_modelConfig_presencePenalty = (_req_modelConfig7 = req.modelConfig) === null || _req_modelConfig7 === void 0 ? void 0 : _req_modelConfig7.presencePenalty) !== null && _req_modelConfig_presencePenalty !== void 0 ? _req_modelConfig_presencePenalty : _this.config.presencePenalty
|
|
121415
121259
|
}, frequencyPenalty ? {
|
|
@@ -121808,12 +121652,6 @@ var AxAI = /*#__PURE__*/ function() {
|
|
|
121808
121652
|
value: function getOptions() {
|
|
121809
121653
|
return this.ai.getOptions();
|
|
121810
121654
|
}
|
|
121811
|
-
},
|
|
121812
|
-
{
|
|
121813
|
-
key: "getLogger",
|
|
121814
|
-
value: function getLogger() {
|
|
121815
|
-
return this.ai.getLogger();
|
|
121816
|
-
}
|
|
121817
121655
|
}
|
|
121818
121656
|
]);
|
|
121819
121657
|
return AxAI;
|
|
@@ -121963,7 +121801,7 @@ var MemoryImpl = /*#__PURE__*/ function() {
|
|
|
121963
121801
|
if ((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.debug) {
|
|
121964
121802
|
if (delta && typeof delta === "string") {
|
|
121965
121803
|
debugResponseDelta(delta);
|
|
121966
|
-
} else if (
|
|
121804
|
+
} else if (lastItem) {
|
|
121967
121805
|
debugResponse({
|
|
121968
121806
|
content: content,
|
|
121969
121807
|
name: name,
|
|
@@ -122382,8 +122220,6 @@ var validateValue = function(field, value) {
|
|
|
122382
122220
|
};
|
|
122383
122221
|
var validateSingleValue = function(expectedType, val) {
|
|
122384
122222
|
switch(expectedType){
|
|
122385
|
-
case "class":
|
|
122386
|
-
return typeof val === "string";
|
|
122387
122223
|
case "code":
|
|
122388
122224
|
return typeof val === "string";
|
|
122389
122225
|
case "string":
|
|
@@ -122438,7 +122274,7 @@ var validateValue = function(field, value) {
|
|
|
122438
122274
|
msg = "object ({ mimeType: string; data: string })";
|
|
122439
122275
|
}
|
|
122440
122276
|
if (msg) {
|
|
122441
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
122277
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg, " instead got '").concat(value, "'"));
|
|
122442
122278
|
}
|
|
122443
122279
|
return;
|
|
122444
122280
|
}
|
|
@@ -122478,7 +122314,7 @@ var validateValue = function(field, value) {
|
|
|
122478
122314
|
msg1 = "object ({ data: string; format?: string })";
|
|
122479
122315
|
}
|
|
122480
122316
|
if (msg1) {
|
|
122481
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
122317
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg1, " instead got '").concat(value, "'"));
|
|
122482
122318
|
}
|
|
122483
122319
|
return;
|
|
122484
122320
|
}
|
|
@@ -122516,8 +122352,7 @@ var validateValue = function(field, value) {
|
|
|
122516
122352
|
}
|
|
122517
122353
|
if (!isValid) {
|
|
122518
122354
|
var _field_type3;
|
|
122519
|
-
|
|
122520
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(((_field_type3 = field.type) === null || _field_type3 === void 0 ? void 0 : _field_type3.isArray) ? "an array of " : "").concat(ft.name, " instead got '").concat(gotType, "' (").concat(JSON.stringify(value), ")"));
|
|
122355
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(((_field_type3 = field.type) === null || _field_type3 === void 0 ? void 0 : _field_type3.isArray) ? "an array of " : "").concat(ft.name, " instead got '").concat(typeof value === "undefined" ? "undefined" : _type_of(value), "' (").concat(value, ")"));
|
|
122521
122356
|
}
|
|
122522
122357
|
};
|
|
122523
122358
|
function mergeProgramUsage(usages) {
|
|
@@ -122718,15 +122553,13 @@ function matchesContent(content, prefix) {
|
|
|
122718
122553
|
// dsp/prompt.ts
|
|
122719
122554
|
var functionCallInstructions = "\n## Function Call Instructions\n- Complete the task, using the functions defined earlier in this prompt. \n- Call functions step-by-step, using the output of one function as input to the next.\n- Use the function results to generate the output fields.";
|
|
122720
122555
|
var formattingRules = "\n## Strict Output Formatting Rules\n- Output must strictly follow the defined plain-text `field name: value` field format.\n- Output field, values must strictly adhere to the specified output field formatting rules.\n- Do not add any text before or after the output fields, just the field name and value.\n- Do not use code blocks.";
|
|
122721
|
-
var AxPromptTemplate = function AxPromptTemplate(sig,
|
|
122556
|
+
var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates) {
|
|
122722
122557
|
var _this = this;
|
|
122723
122558
|
_class_call_check(this, AxPromptTemplate);
|
|
122724
|
-
var
|
|
122559
|
+
var _functions_map;
|
|
122725
122560
|
_define_property(this, "sig", void 0);
|
|
122726
122561
|
_define_property(this, "fieldTemplates", void 0);
|
|
122727
122562
|
_define_property(this, "task", void 0);
|
|
122728
|
-
_define_property(this, "thoughtFieldName", void 0);
|
|
122729
|
-
_define_property(this, "functions", void 0);
|
|
122730
122563
|
_define_property(this, "render", function(values, param) {
|
|
122731
122564
|
var examples = param.examples, demos = param.demos;
|
|
122732
122565
|
var renderedExamples = examples ? [
|
|
@@ -122736,6 +122569,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122736
122569
|
}
|
|
122737
122570
|
].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
|
|
122738
122571
|
var renderedDemos = demos ? _this.renderDemos(demos) : [];
|
|
122572
|
+
var completion = _this.renderInputFields(values);
|
|
122739
122573
|
var allTextExamples = renderedExamples.every(function(v) {
|
|
122740
122574
|
return v.type === "text";
|
|
122741
122575
|
});
|
|
@@ -122760,92 +122594,23 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122760
122594
|
role: "system",
|
|
122761
122595
|
content: systemContent
|
|
122762
122596
|
};
|
|
122763
|
-
var
|
|
122764
|
-
|
|
122765
|
-
|
|
122766
|
-
|
|
122767
|
-
|
|
122768
|
-
|
|
122769
|
-
|
|
122770
|
-
|
|
122771
|
-
|
|
122772
|
-
|
|
122773
|
-
|
|
122774
|
-
|
|
122775
|
-
|
|
122776
|
-
}).join("").trim();
|
|
122777
|
-
} else if (message.role === "assistant") {
|
|
122778
|
-
var assistantMsgParts = _this.renderInputFields(message.values);
|
|
122779
|
-
messageContent = assistantMsgParts.map(function(part) {
|
|
122780
|
-
return part.type === "text" ? part.text : "";
|
|
122781
|
-
}).join("").trim();
|
|
122782
|
-
}
|
|
122783
|
-
if (messageContent) {
|
|
122784
|
-
if (lastRole === message.role && userMessages.length > 0) {
|
|
122785
|
-
var lastMessage = userMessages[userMessages.length - 1];
|
|
122786
|
-
if (lastMessage) {
|
|
122787
|
-
lastMessage.content += "\n" + messageContent;
|
|
122788
|
-
}
|
|
122789
|
-
} else {
|
|
122790
|
-
if (message.role === "user") {
|
|
122791
|
-
userMessages.push({
|
|
122792
|
-
role: "user",
|
|
122793
|
-
content: messageContent
|
|
122794
|
-
});
|
|
122795
|
-
} else if (message.role === "assistant") {
|
|
122796
|
-
userMessages.push({
|
|
122797
|
-
role: "assistant",
|
|
122798
|
-
content: messageContent
|
|
122799
|
-
});
|
|
122800
|
-
}
|
|
122801
|
-
}
|
|
122802
|
-
lastRole = message.role;
|
|
122803
|
-
}
|
|
122804
|
-
}
|
|
122805
|
-
} catch (err) {
|
|
122806
|
-
_didIteratorError = true;
|
|
122807
|
-
_iteratorError = err;
|
|
122808
|
-
} finally{
|
|
122809
|
-
try {
|
|
122810
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
122811
|
-
_iterator.return();
|
|
122812
|
-
}
|
|
122813
|
-
} finally{
|
|
122814
|
-
if (_didIteratorError) {
|
|
122815
|
-
throw _iteratorError;
|
|
122816
|
-
}
|
|
122817
|
-
}
|
|
122818
|
-
}
|
|
122819
|
-
} else {
|
|
122820
|
-
var currentValues = values;
|
|
122821
|
-
var completion = _this.renderInputFields(currentValues);
|
|
122822
|
-
var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
|
|
122823
|
-
var promptFilter = promptList.filter(function(v) {
|
|
122824
|
-
return v !== void 0;
|
|
122825
|
-
});
|
|
122826
|
-
var userContent;
|
|
122827
|
-
if (promptFilter.every(function(v) {
|
|
122828
|
-
return v.type === "text";
|
|
122829
|
-
})) {
|
|
122830
|
-
userContent = promptFilter.map(function(v) {
|
|
122831
|
-
return v.text;
|
|
122832
|
-
}).join("\n");
|
|
122833
|
-
} else {
|
|
122834
|
-
userContent = promptFilter.map(function(part) {
|
|
122835
|
-
if (part.type === "text") return part.text;
|
|
122836
|
-
if (part.type === "image") return "[IMAGE]";
|
|
122837
|
-
if (part.type === "audio") return "[AUDIO]";
|
|
122838
|
-
return "";
|
|
122839
|
-
}).join("\n").trim();
|
|
122840
|
-
}
|
|
122841
|
-
userMessages.push({
|
|
122842
|
-
role: "user",
|
|
122843
|
-
content: userContent
|
|
122844
|
-
});
|
|
122845
|
-
}
|
|
122597
|
+
var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
|
|
122598
|
+
var prompt = promptList.filter(function(v) {
|
|
122599
|
+
return v !== void 0;
|
|
122600
|
+
});
|
|
122601
|
+
var userContent = prompt.every(function(v) {
|
|
122602
|
+
return v.type === "text";
|
|
122603
|
+
}) ? prompt.map(function(v) {
|
|
122604
|
+
return v.text;
|
|
122605
|
+
}).join("\n") : prompt.reduce(combineConsecutiveStrings("\n"), []);
|
|
122606
|
+
var userPrompt = {
|
|
122607
|
+
role: "user",
|
|
122608
|
+
content: userContent
|
|
122609
|
+
};
|
|
122846
122610
|
return [
|
|
122847
|
-
systemPrompt
|
|
122848
|
-
|
|
122611
|
+
systemPrompt,
|
|
122612
|
+
userPrompt
|
|
122613
|
+
];
|
|
122849
122614
|
});
|
|
122850
122615
|
_define_property(this, "renderExtraFields", function(extraFields) {
|
|
122851
122616
|
var prompt = [];
|
|
@@ -122891,28 +122656,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122891
122656
|
});
|
|
122892
122657
|
_define_property(this, "renderExamples", function(data) {
|
|
122893
122658
|
var list = [];
|
|
122894
|
-
var exampleContext = {
|
|
122895
|
-
isExample: true
|
|
122896
|
-
};
|
|
122897
122659
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122898
122660
|
try {
|
|
122899
122661
|
var _loop = function() {
|
|
122900
122662
|
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
|
|
122901
122663
|
var _renderedItem_;
|
|
122902
122664
|
var renderedInputItem = _this.sig.getInputFields().map(function(field) {
|
|
122903
|
-
return _this.renderInField(field, item,
|
|
122904
|
-
isInputField: true
|
|
122905
|
-
}));
|
|
122665
|
+
return _this.renderInField(field, item, true);
|
|
122906
122666
|
}).filter(function(v) {
|
|
122907
122667
|
return v !== void 0;
|
|
122908
122668
|
}).flat();
|
|
122909
122669
|
var renderedOutputItem = _this.sig.getOutputFields().map(function(field) {
|
|
122910
|
-
return _this.renderInField(field, item,
|
|
122911
|
-
isInputField: false
|
|
122912
|
-
}));
|
|
122670
|
+
return _this.renderInField(field, item, true);
|
|
122913
122671
|
}).filter(function(v) {
|
|
122914
122672
|
return v !== void 0;
|
|
122915
122673
|
}).flat();
|
|
122674
|
+
if (renderedOutputItem.length === 0) {
|
|
122675
|
+
throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
|
|
122676
|
+
}
|
|
122916
122677
|
var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
|
|
122917
122678
|
if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
|
|
122918
122679
|
list.push({
|
|
@@ -122949,30 +122710,16 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122949
122710
|
});
|
|
122950
122711
|
_define_property(this, "renderDemos", function(data) {
|
|
122951
122712
|
var list = [];
|
|
122952
|
-
var
|
|
122953
|
-
var outputFields = _this.sig.getOutputFields();
|
|
122954
|
-
var demoContext = {
|
|
122955
|
-
isExample: true
|
|
122956
|
-
};
|
|
122713
|
+
var fields = _to_consumable_array(_this.sig.getInputFields()).concat(_to_consumable_array(_this.sig.getOutputFields()));
|
|
122957
122714
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122958
122715
|
try {
|
|
122959
122716
|
var _loop = function() {
|
|
122960
122717
|
var item = _step.value;
|
|
122961
|
-
var
|
|
122962
|
-
return _this.renderInField(field, item,
|
|
122963
|
-
isInputField: true
|
|
122964
|
-
}));
|
|
122965
|
-
}).filter(function(v) {
|
|
122966
|
-
return v !== void 0;
|
|
122967
|
-
}).flat();
|
|
122968
|
-
var outputRenderedItems = outputFields.map(function(field) {
|
|
122969
|
-
return _this.renderInField(field, item, _object_spread_props(_object_spread({}, demoContext), {
|
|
122970
|
-
isInputField: false
|
|
122971
|
-
}));
|
|
122718
|
+
var renderedItem = fields.map(function(field) {
|
|
122719
|
+
return _this.renderInField(field, item, true);
|
|
122972
122720
|
}).filter(function(v) {
|
|
122973
122721
|
return v !== void 0;
|
|
122974
122722
|
}).flat();
|
|
122975
|
-
var renderedItem = _to_consumable_array(inputRenderedItems).concat(_to_consumable_array(outputRenderedItems));
|
|
122976
122723
|
renderedItem.slice(0, -1).forEach(function(v) {
|
|
122977
122724
|
if ("text" in v) {
|
|
122978
122725
|
v.text = v.text + "\n";
|
|
@@ -123002,7 +122749,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123002
122749
|
});
|
|
123003
122750
|
_define_property(this, "renderInputFields", function(values) {
|
|
123004
122751
|
var renderedItems = _this.sig.getInputFields().map(function(field) {
|
|
123005
|
-
return _this.renderInField(field, values
|
|
122752
|
+
return _this.renderInField(field, values);
|
|
123006
122753
|
}).filter(function(v) {
|
|
123007
122754
|
return v !== void 0;
|
|
123008
122755
|
}).flat();
|
|
@@ -123013,10 +122760,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123013
122760
|
});
|
|
123014
122761
|
return renderedItems;
|
|
123015
122762
|
});
|
|
123016
|
-
_define_property(this, "renderInField", function(field, values,
|
|
122763
|
+
_define_property(this, "renderInField", function(field, values, skipMissing) {
|
|
123017
122764
|
var _this_fieldTemplates;
|
|
123018
122765
|
var value = values[field.name];
|
|
123019
|
-
if (
|
|
122766
|
+
if (skipMissing && !value) {
|
|
122767
|
+
return;
|
|
122768
|
+
}
|
|
122769
|
+
if (isEmptyValue(field, value)) {
|
|
123020
122770
|
return;
|
|
123021
122771
|
}
|
|
123022
122772
|
if (field.type) {
|
|
@@ -123056,19 +122806,19 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123056
122806
|
throw new Error("Image field value must be an array.");
|
|
123057
122807
|
}
|
|
123058
122808
|
result = result.concat(value.map(function(v) {
|
|
123059
|
-
|
|
122809
|
+
v = validateImage(v);
|
|
123060
122810
|
return {
|
|
123061
122811
|
type: "image",
|
|
123062
|
-
mimeType:
|
|
123063
|
-
image:
|
|
122812
|
+
mimeType: v.mimeType,
|
|
122813
|
+
image: v.data
|
|
123064
122814
|
};
|
|
123065
122815
|
}));
|
|
123066
122816
|
} else {
|
|
123067
|
-
var
|
|
122817
|
+
var v = validateImage(value);
|
|
123068
122818
|
result.push({
|
|
123069
122819
|
type: "image",
|
|
123070
|
-
mimeType:
|
|
123071
|
-
image:
|
|
122820
|
+
mimeType: v.mimeType,
|
|
122821
|
+
image: v.data
|
|
123072
122822
|
});
|
|
123073
122823
|
}
|
|
123074
122824
|
return result;
|
|
@@ -123094,24 +122844,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123094
122844
|
];
|
|
123095
122845
|
if (field.type.isArray) {
|
|
123096
122846
|
if (!Array.isArray(value)) {
|
|
123097
|
-
throw new Error("
|
|
122847
|
+
throw new Error("Image field value must be an array.");
|
|
123098
122848
|
}
|
|
123099
122849
|
result1 = result1.concat(value.map(function(v) {
|
|
123100
|
-
|
|
123101
|
-
var
|
|
122850
|
+
v = validateAudio(v);
|
|
122851
|
+
var _v_format;
|
|
123102
122852
|
return {
|
|
123103
122853
|
type: "audio",
|
|
123104
|
-
format: (
|
|
123105
|
-
data:
|
|
122854
|
+
format: (_v_format = v.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
122855
|
+
data: v.data
|
|
123106
122856
|
};
|
|
123107
122857
|
}));
|
|
123108
122858
|
} else {
|
|
123109
|
-
var
|
|
123110
|
-
var
|
|
122859
|
+
var v1 = validateAudio(value);
|
|
122860
|
+
var _v_format;
|
|
123111
122861
|
result1.push({
|
|
123112
122862
|
type: "audio",
|
|
123113
|
-
format: (
|
|
123114
|
-
data:
|
|
122863
|
+
format: (_v_format = v1.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
122864
|
+
data: v1.data
|
|
123115
122865
|
});
|
|
123116
122866
|
}
|
|
123117
122867
|
return result1;
|
|
@@ -123137,16 +122887,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123137
122887
|
});
|
|
123138
122888
|
this.sig = sig;
|
|
123139
122889
|
this.fieldTemplates = fieldTemplates;
|
|
123140
|
-
var _options_thoughtFieldName;
|
|
123141
|
-
this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
|
|
123142
|
-
this.functions = options === null || options === void 0 ? void 0 : options.functions;
|
|
123143
122890
|
var task = [];
|
|
123144
122891
|
var inArgs = renderDescFields(this.sig.getInputFields());
|
|
123145
122892
|
var outArgs = renderDescFields(this.sig.getOutputFields());
|
|
123146
122893
|
task.push("You will be provided with the following fields: ".concat(inArgs, ". Your task is to generate new fields: ").concat(outArgs, "."));
|
|
123147
|
-
var funcs =
|
|
122894
|
+
var funcs = functions === null || functions === void 0 ? void 0 : (_functions_map = functions.map(function(f) {
|
|
123148
122895
|
return "toFunction" in f ? f.toFunction() : f;
|
|
123149
|
-
})) === null ||
|
|
122896
|
+
})) === null || _functions_map === void 0 ? void 0 : _functions_map.flat();
|
|
123150
122897
|
var funcList = funcs === null || funcs === void 0 ? void 0 : funcs.map(function(fn) {
|
|
123151
122898
|
return "- `".concat(fn.name, "`: ").concat(formatDescription(fn.description));
|
|
123152
122899
|
}).join("\n");
|
|
@@ -123259,19 +123006,15 @@ function combineConsecutiveStrings(separator) {
|
|
|
123259
123006
|
return acc;
|
|
123260
123007
|
};
|
|
123261
123008
|
}
|
|
123262
|
-
var isEmptyValue = function(field, value
|
|
123009
|
+
var isEmptyValue = function(field, value) {
|
|
123263
123010
|
if (typeof value === "boolean") {
|
|
123264
123011
|
return false;
|
|
123265
123012
|
}
|
|
123266
123013
|
if (!value || (Array.isArray(value) || typeof value === "string") && value.length === 0) {
|
|
123267
|
-
if (
|
|
123268
|
-
return true;
|
|
123269
|
-
}
|
|
123270
|
-
if (field.isOptional || field.isInternal) {
|
|
123014
|
+
if (field.isOptional) {
|
|
123271
123015
|
return true;
|
|
123272
123016
|
}
|
|
123273
|
-
|
|
123274
|
-
throw new Error("Value for ".concat(fieldType, " field '").concat(field.name, "' is required."));
|
|
123017
|
+
throw new Error("Value for input field '".concat(field.name, "' is required."));
|
|
123275
123018
|
}
|
|
123276
123019
|
return false;
|
|
123277
123020
|
};
|
|
@@ -123280,6 +123023,7 @@ function formatDescription(str) {
|
|
|
123280
123023
|
return value.length > 0 ? "".concat(value.charAt(0).toUpperCase()).concat(value.slice(1)).concat(value.endsWith(".") ? "" : ".") : "";
|
|
123281
123024
|
}
|
|
123282
123025
|
// dsp/validate.ts
|
|
123026
|
+
var colorLog4 = new ColorLog();
|
|
123283
123027
|
var ValidationError = (_Symbol_for2 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
123284
123028
|
_inherits(_class, Error1);
|
|
123285
123029
|
var _super = _create_super(_class);
|
|
@@ -123332,12 +123076,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
|
|
|
123332
123076
|
var errors = errorFields.map(function(field) {
|
|
123333
123077
|
return "- ".concat(field.title, ": ").concat(field.description);
|
|
123334
123078
|
}).join("\n");
|
|
123335
|
-
|
|
123336
|
-
logger("❌ Error Correction:\n".concat(errors), {
|
|
123337
|
-
tags: [
|
|
123338
|
-
"error"
|
|
123339
|
-
]
|
|
123340
|
-
});
|
|
123079
|
+
process.stdout.write(colorLog4.red("\n❌ Error Correction:\n".concat(errors, "\n")));
|
|
123341
123080
|
}
|
|
123342
123081
|
}
|
|
123343
123082
|
// dsp/datetime.ts
|
|
@@ -124149,9 +123888,6 @@ var validateJSONSchema = function(schema) {
|
|
|
124149
123888
|
var errors = [];
|
|
124150
123889
|
var validateSchemaObject = function(schema2) {
|
|
124151
123890
|
var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
124152
|
-
if (!schema2 || typeof schema2 !== "object") {
|
|
124153
|
-
return;
|
|
124154
|
-
}
|
|
124155
123891
|
var validTypes = [
|
|
124156
123892
|
"array",
|
|
124157
123893
|
"integer",
|
|
@@ -124161,174 +123897,42 @@ var validateJSONSchema = function(schema) {
|
|
|
124161
123897
|
"null",
|
|
124162
123898
|
"object"
|
|
124163
123899
|
];
|
|
124164
|
-
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
124165
|
-
if (schema2.anyOf.length === 0) {
|
|
124166
|
-
errors.push({
|
|
124167
|
-
path: path || "root",
|
|
124168
|
-
issue: "anyOf array is empty",
|
|
124169
|
-
fix: "Add at least one schema to the anyOf array",
|
|
124170
|
-
example: 'anyOf: [{ type: "string" }, { type: "null" }]'
|
|
124171
|
-
});
|
|
124172
|
-
}
|
|
124173
|
-
schema2.anyOf.forEach(function(subSchema, index) {
|
|
124174
|
-
validateSchemaObject(subSchema, "".concat(path, "anyOf[").concat(index, "]."));
|
|
124175
|
-
});
|
|
124176
|
-
return;
|
|
124177
|
-
}
|
|
124178
|
-
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
124179
|
-
if (schema2.oneOf.length === 0) {
|
|
124180
|
-
errors.push({
|
|
124181
|
-
path: path || "root",
|
|
124182
|
-
issue: "oneOf array is empty",
|
|
124183
|
-
fix: "Add at least one schema to the oneOf array",
|
|
124184
|
-
example: 'oneOf: [{ type: "string" }, { type: "number" }]'
|
|
124185
|
-
});
|
|
124186
|
-
}
|
|
124187
|
-
schema2.oneOf.forEach(function(subSchema, index) {
|
|
124188
|
-
validateSchemaObject(subSchema, "".concat(path, "oneOf[").concat(index, "]."));
|
|
124189
|
-
});
|
|
124190
|
-
return;
|
|
124191
|
-
}
|
|
124192
|
-
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
124193
|
-
if (schema2.allOf.length === 0) {
|
|
124194
|
-
errors.push({
|
|
124195
|
-
path: path || "root",
|
|
124196
|
-
issue: "allOf array is empty",
|
|
124197
|
-
fix: "Add at least one schema to the allOf array",
|
|
124198
|
-
example: 'allOf: [{ type: "object" }, { properties: { name: { type: "string" } } }]'
|
|
124199
|
-
});
|
|
124200
|
-
}
|
|
124201
|
-
schema2.allOf.forEach(function(subSchema, index) {
|
|
124202
|
-
validateSchemaObject(subSchema, "".concat(path, "allOf[").concat(index, "]."));
|
|
124203
|
-
});
|
|
124204
|
-
return;
|
|
124205
|
-
}
|
|
124206
|
-
if (!schema2.type) {
|
|
124207
|
-
return;
|
|
124208
|
-
}
|
|
124209
123900
|
if (!validTypes.includes(schema2.type)) {
|
|
124210
|
-
errors.push(
|
|
124211
|
-
path: path || "root",
|
|
124212
|
-
issue: "Invalid type '".concat(schema2.type, "'"),
|
|
124213
|
-
fix: "Change type to one of: ".concat(validTypes.join(", ")),
|
|
124214
|
-
example: '{ type: "string" } or { type: "object" }'
|
|
124215
|
-
});
|
|
123901
|
+
errors.push("Invalid type '".concat(schema2.type, "' at ").concat(path || "root"));
|
|
124216
123902
|
return;
|
|
124217
123903
|
}
|
|
124218
|
-
if (schema2.type === "object") {
|
|
124219
|
-
if (schema2.properties) {
|
|
124220
|
-
|
|
124221
|
-
|
|
124222
|
-
|
|
124223
|
-
|
|
124224
|
-
|
|
124225
|
-
|
|
124226
|
-
|
|
124227
|
-
} else {
|
|
124228
|
-
for(var key in schema2.properties){
|
|
124229
|
-
var value = schema2.properties[key];
|
|
124230
|
-
if (value === void 0 || value === null) {
|
|
124231
|
-
continue;
|
|
124232
|
-
}
|
|
124233
|
-
if (typeof value !== "object") {
|
|
124234
|
-
errors.push({
|
|
124235
|
-
path: "".concat(path).concat(key),
|
|
124236
|
-
issue: "Property schema must be an object, got ".concat(typeof value === "undefined" ? "undefined" : _type_of(value)),
|
|
124237
|
-
fix: "Define the property as a proper schema object",
|
|
124238
|
-
example: "".concat(key, ': { type: "string", description: "..." }')
|
|
124239
|
-
});
|
|
124240
|
-
continue;
|
|
124241
|
-
}
|
|
124242
|
-
validateSchemaObject(value, "".concat(path).concat(key, "."));
|
|
123904
|
+
if (schema2.type === "object" && schema2.properties) {
|
|
123905
|
+
if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
|
|
123906
|
+
errors.push("Invalid properties object at ".concat(path || "root"));
|
|
123907
|
+
} else {
|
|
123908
|
+
for(var key in schema2.properties){
|
|
123909
|
+
var value = schema2.properties[key];
|
|
123910
|
+
if (typeof value !== "object") {
|
|
123911
|
+
errors.push("Invalid schema object at ".concat(path).concat(key));
|
|
123912
|
+
continue;
|
|
124243
123913
|
}
|
|
123914
|
+
validateSchemaObject(value, "".concat(path).concat(key, "."));
|
|
124244
123915
|
}
|
|
124245
123916
|
}
|
|
124246
|
-
if (schema2.required) {
|
|
124247
|
-
|
|
124248
|
-
errors.push({
|
|
124249
|
-
path: path || "root",
|
|
124250
|
-
issue: "'required' must be an array, got ".concat(_type_of(schema2.required)),
|
|
124251
|
-
fix: "Change required to be an array of property names",
|
|
124252
|
-
example: 'required: ["name", "email"] instead of required: "name,email"'
|
|
124253
|
-
});
|
|
124254
|
-
} else if (schema2.required.length === 0) ; else {
|
|
124255
|
-
if (schema2.properties) {
|
|
124256
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
124257
|
-
try {
|
|
124258
|
-
for(var _iterator = schema2.required[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
124259
|
-
var requiredProp = _step.value;
|
|
124260
|
-
if (typeof requiredProp !== "string") {
|
|
124261
|
-
errors.push({
|
|
124262
|
-
path: "".concat(path, "required"),
|
|
124263
|
-
issue: "Required property names must be strings, got ".concat(typeof requiredProp === "undefined" ? "undefined" : _type_of(requiredProp)),
|
|
124264
|
-
fix: "Ensure all items in required array are strings",
|
|
124265
|
-
example: 'required: ["name", "email"] not required: [123, "email"]'
|
|
124266
|
-
});
|
|
124267
|
-
} else if (!(requiredProp in schema2.properties)) {
|
|
124268
|
-
errors.push({
|
|
124269
|
-
path: "".concat(path, "required"),
|
|
124270
|
-
issue: "Required property '".concat(requiredProp, "' is not defined in properties"),
|
|
124271
|
-
fix: "Either add '".concat(requiredProp, "' to properties or remove it from required"),
|
|
124272
|
-
example: "properties: { ".concat(requiredProp, ': { type: "string" } }')
|
|
124273
|
-
});
|
|
124274
|
-
}
|
|
124275
|
-
}
|
|
124276
|
-
} catch (err) {
|
|
124277
|
-
_didIteratorError = true;
|
|
124278
|
-
_iteratorError = err;
|
|
124279
|
-
} finally{
|
|
124280
|
-
try {
|
|
124281
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
124282
|
-
_iterator.return();
|
|
124283
|
-
}
|
|
124284
|
-
} finally{
|
|
124285
|
-
if (_didIteratorError) {
|
|
124286
|
-
throw _iteratorError;
|
|
124287
|
-
}
|
|
124288
|
-
}
|
|
124289
|
-
}
|
|
124290
|
-
}
|
|
124291
|
-
}
|
|
123917
|
+
if (schema2.required && !Array.isArray(schema2.required)) {
|
|
123918
|
+
errors.push("'required' should be an array at ".concat(path || "root"));
|
|
124292
123919
|
}
|
|
124293
123920
|
}
|
|
124294
|
-
if (schema2.type === "array") {
|
|
124295
|
-
if (schema2.items) {
|
|
124296
|
-
|
|
124297
|
-
|
|
124298
|
-
|
|
124299
|
-
issue: "Array items schema must be an object, got ".concat(_type_of(schema2.items)),
|
|
124300
|
-
fix: "Define items as a proper schema object",
|
|
124301
|
-
example: 'items: { type: "string" } or items: { type: "object", properties: {...} }'
|
|
124302
|
-
});
|
|
124303
|
-
} else {
|
|
124304
|
-
validateSchemaObject(schema2.items, "".concat(path, "items."));
|
|
124305
|
-
}
|
|
123921
|
+
if (schema2.type === "array" && schema2.items) {
|
|
123922
|
+
if (typeof schema2.items !== "object") {
|
|
123923
|
+
errors.push("Invalid items schema at ".concat(path || "root"));
|
|
123924
|
+
} else {
|
|
123925
|
+
validateSchemaObject(schema2.items, "".concat(path, "items."));
|
|
124306
123926
|
}
|
|
124307
123927
|
}
|
|
124308
123928
|
};
|
|
124309
123929
|
validateSchemaObject(schema);
|
|
124310
123930
|
if (errors.length > 0) {
|
|
124311
|
-
|
|
124312
|
-
"JSON Schema validation failed:",
|
|
124313
|
-
""
|
|
124314
|
-
].concat(_to_consumable_array(errors.map(function(error, index) {
|
|
124315
|
-
var parts = [
|
|
124316
|
-
"".concat(index + 1, ". Path: ").concat(error.path),
|
|
124317
|
-
" Issue: ".concat(error.issue),
|
|
124318
|
-
" Fix: ".concat(error.fix)
|
|
124319
|
-
];
|
|
124320
|
-
if (error.example) {
|
|
124321
|
-
parts.push(" Example: ".concat(error.example));
|
|
124322
|
-
}
|
|
124323
|
-
return parts.join("\n");
|
|
124324
|
-
})), [
|
|
124325
|
-
"",
|
|
124326
|
-
"Please fix these issues and try again."
|
|
124327
|
-
]).join("\n");
|
|
124328
|
-
throw new Error(errorMessage);
|
|
123931
|
+
throw new Error(errors.join("; "));
|
|
124329
123932
|
}
|
|
124330
123933
|
};
|
|
124331
123934
|
// dsp/functions.ts
|
|
123935
|
+
var colorLog5 = new ColorLog();
|
|
124332
123936
|
var AxFunctionError = (_Symbol_for3 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
124333
123937
|
_inherits(_class, Error1);
|
|
124334
123938
|
var _super = _create_super(_class);
|
|
@@ -124654,12 +124258,7 @@ var processFunctions = function() {
|
|
|
124654
124258
|
}, sessionId);
|
|
124655
124259
|
mem.addTag("error");
|
|
124656
124260
|
if (ai.getOptions().debug) {
|
|
124657
|
-
|
|
124658
|
-
logger("❌ Function Error Correction:\n".concat(result), {
|
|
124659
|
-
tags: [
|
|
124660
|
-
"error"
|
|
124661
|
-
]
|
|
124662
|
-
});
|
|
124261
|
+
process.stdout.write(colorLog5.red("\n❌ Function Error Correction:\n".concat(result, "\n")));
|
|
124663
124262
|
}
|
|
124664
124263
|
} else {
|
|
124665
124264
|
throw e;
|
|
@@ -125288,7 +124887,7 @@ var AxSignature = function _AxSignature(signature) {
|
|
|
125288
124887
|
}
|
|
125289
124888
|
});
|
|
125290
124889
|
var _this_description;
|
|
125291
|
-
_this.sigHash =
|
|
124890
|
+
_this.sigHash = require$$0$6.createHash("sha256").update((_this_description = _this.description) !== null && _this_description !== void 0 ? _this_description : "").update(JSON.stringify(_this.inputFields)).update(JSON.stringify(_this.outputFields)).digest("hex");
|
|
125292
124891
|
_this.sigString = renderSignature(_this.description, _this.inputFields, _this.outputFields);
|
|
125293
124892
|
return [
|
|
125294
124893
|
_this.sigHash,
|
|
@@ -125402,7 +125001,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125402
125001
|
_define_property(this, "signature", void 0);
|
|
125403
125002
|
_define_property(this, "sigHash", void 0);
|
|
125404
125003
|
_define_property(this, "examples", void 0);
|
|
125405
|
-
_define_property(this, "examplesOptions", void 0);
|
|
125406
125004
|
_define_property(this, "demos", void 0);
|
|
125407
125005
|
_define_property(this, "trace", void 0);
|
|
125408
125006
|
_define_property(this, "usage", []);
|
|
@@ -125497,8 +125095,8 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125497
125095
|
},
|
|
125498
125096
|
{
|
|
125499
125097
|
key: "setExamples",
|
|
125500
|
-
value: function setExamples(examples
|
|
125501
|
-
this._setExamples(examples
|
|
125098
|
+
value: function setExamples(examples) {
|
|
125099
|
+
this._setExamples(examples);
|
|
125502
125100
|
if (!("programId" in examples)) {
|
|
125503
125101
|
return;
|
|
125504
125102
|
}
|
|
@@ -125506,7 +125104,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125506
125104
|
try {
|
|
125507
125105
|
for(var _iterator = this.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
125508
125106
|
var child = _step.value;
|
|
125509
|
-
child.setExamples(examples
|
|
125107
|
+
child.setExamples(examples);
|
|
125510
125108
|
}
|
|
125511
125109
|
} catch (err) {
|
|
125512
125110
|
_didIteratorError = true;
|
|
@@ -125526,7 +125124,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125526
125124
|
},
|
|
125527
125125
|
{
|
|
125528
125126
|
key: "_setExamples",
|
|
125529
|
-
value: function _setExamples(examples
|
|
125127
|
+
value: function _setExamples(examples) {
|
|
125530
125128
|
var traces = [];
|
|
125531
125129
|
if ("programId" in examples && examples.programId === this.key.id) {
|
|
125532
125130
|
traces = examples.traces;
|
|
@@ -125535,7 +125133,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125535
125133
|
traces = examples;
|
|
125536
125134
|
}
|
|
125537
125135
|
if (traces) {
|
|
125538
|
-
this.examplesOptions = options;
|
|
125539
125136
|
var sig = this.signature;
|
|
125540
125137
|
var fields = _to_consumable_array(sig.getInputFields()).concat(_to_consumable_array(sig.getOutputFields()));
|
|
125541
125138
|
this.examples = traces.map(function(e) {
|
|
@@ -125545,7 +125142,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125545
125142
|
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
125546
125143
|
var f = _step.value;
|
|
125547
125144
|
var value = e[f.name];
|
|
125548
|
-
if (value
|
|
125145
|
+
if (value) {
|
|
125549
125146
|
validateValue(f, value);
|
|
125550
125147
|
res[f.name] = value;
|
|
125551
125148
|
}
|
|
@@ -125713,8 +125310,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125713
125310
|
_define_property(_assert_this_initialized(_this), "streamingFieldProcessors", []);
|
|
125714
125311
|
_define_property(_assert_this_initialized(_this), "values", {});
|
|
125715
125312
|
_define_property(_assert_this_initialized(_this), "excludeContentFromTrace", false);
|
|
125716
|
-
_define_property(_assert_this_initialized(_this), "thoughtFieldName", void 0);
|
|
125717
|
-
_define_property(_assert_this_initialized(_this), "logger", void 0);
|
|
125718
125313
|
_define_property(_assert_this_initialized(_this), "addAssert", function(fn, message) {
|
|
125719
125314
|
_this.asserts.push({
|
|
125720
125315
|
fn: fn,
|
|
@@ -125761,15 +125356,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125761
125356
|
_this.addFieldProcessorInternal(fieldName, fn, false);
|
|
125762
125357
|
});
|
|
125763
125358
|
_this.options = options;
|
|
125764
|
-
_this.logger = options === null || options === void 0 ? void 0 : options.logger;
|
|
125765
|
-
var _options_thoughtFieldName;
|
|
125766
|
-
_this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
|
|
125767
|
-
var promptTemplateOptions = {
|
|
125768
|
-
functions: options === null || options === void 0 ? void 0 : options.functions,
|
|
125769
|
-
thoughtFieldName: _this.thoughtFieldName
|
|
125770
|
-
};
|
|
125771
125359
|
var _options_promptTemplate;
|
|
125772
|
-
_this.promptTemplate = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature,
|
|
125360
|
+
_this.promptTemplate = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature, options === null || options === void 0 ? void 0 : options.functions);
|
|
125773
125361
|
var _this_options_asserts;
|
|
125774
125362
|
_this.asserts = (_this_options_asserts = (_this_options = _this.options) === null || _this_options === void 0 ? void 0 : _this_options.asserts) !== null && _this_options_asserts !== void 0 ? _this_options_asserts : [];
|
|
125775
125363
|
var _this_options_streamingAsserts;
|
|
@@ -125789,11 +125377,11 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125789
125377
|
var ai = param.ai, mem = param.mem, options = param.options, traceContext = param.traceContext, firstStep = param.firstStep;
|
|
125790
125378
|
var _this = this;
|
|
125791
125379
|
return _async_to_generator(function() {
|
|
125792
|
-
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget,
|
|
125380
|
+
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget, _mem_history, chatPrompt, functions, functionCall, res;
|
|
125793
125381
|
return _ts_generator(this, function(_state) {
|
|
125794
125382
|
switch(_state.label){
|
|
125795
125383
|
case 0:
|
|
125796
|
-
_ref = options !== null && options !== void 0 ? options : {}, sessionId = _ref.sessionId, traceId = _ref.traceId, modelConfig = _ref.modelConfig, model = _ref.model, rateLimiter = _ref.rateLimiter, stream = _ref.stream, _functions = _ref.functions, _functionCall = _ref.functionCall, thinkingTokenBudget = _ref.thinkingTokenBudget
|
|
125384
|
+
_ref = options !== null && options !== void 0 ? options : {}, sessionId = _ref.sessionId, traceId = _ref.traceId, modelConfig = _ref.modelConfig, model = _ref.model, rateLimiter = _ref.rateLimiter, stream = _ref.stream, _functions = _ref.functions, _functionCall = _ref.functionCall, thinkingTokenBudget = _ref.thinkingTokenBudget;
|
|
125797
125385
|
chatPrompt = (_mem_history = mem === null || mem === void 0 ? void 0 : mem.history(sessionId)) !== null && _mem_history !== void 0 ? _mem_history : [];
|
|
125798
125386
|
if (chatPrompt.length === 0) {
|
|
125799
125387
|
throw new Error("No chat prompt found");
|
|
@@ -125820,9 +125408,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125820
125408
|
stream: stream,
|
|
125821
125409
|
debug: false,
|
|
125822
125410
|
thinkingTokenBudget: thinkingTokenBudget,
|
|
125823
|
-
|
|
125824
|
-
traceContext: traceContext,
|
|
125825
|
-
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal
|
|
125411
|
+
traceContext: traceContext
|
|
125826
125412
|
})
|
|
125827
125413
|
];
|
|
125828
125414
|
case 1:
|
|
@@ -125864,7 +125450,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125864
125450
|
];
|
|
125865
125451
|
case 1:
|
|
125866
125452
|
res = _state.sent();
|
|
125867
|
-
if (!_instanceof(res, web.ReadableStream)) return [
|
|
125453
|
+
if (!_instanceof(res, web$1.ReadableStream)) return [
|
|
125868
125454
|
3,
|
|
125869
125455
|
3
|
|
125870
125456
|
];
|
|
@@ -125925,7 +125511,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125925
125511
|
var ai = param.ai, model = param.model, res = param.res, mem = param.mem, sessionId = param.sessionId, traceId = param.traceId, functions = param.functions, fastFail = param.fastFail, span = param.span;
|
|
125926
125512
|
var _this = this;
|
|
125927
125513
|
return _wrap_async_generator(function() {
|
|
125928
|
-
var streamingValidation, functionCalls, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, result, _result_functionCalls__function, _result_functionCalls_, _result_functionCalls, skip,
|
|
125514
|
+
var streamingValidation, functionCalls, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, result, _result_functionCalls__function, _result_functionCalls_, _result_functionCalls, skip, _this_values_thought, err, funcs, fx;
|
|
125929
125515
|
return _ts_generator(this, function(_state) {
|
|
125930
125516
|
switch(_state.label){
|
|
125931
125517
|
case 0:
|
|
@@ -125997,7 +125583,9 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125997
125583
|
];
|
|
125998
125584
|
return [
|
|
125999
125585
|
4,
|
|
126000
|
-
|
|
125586
|
+
{
|
|
125587
|
+
thought: result.thought
|
|
125588
|
+
}
|
|
126001
125589
|
];
|
|
126002
125590
|
case 5:
|
|
126003
125591
|
_state.sent();
|
|
@@ -126061,10 +125649,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126061
125649
|
3,
|
|
126062
125650
|
15
|
|
126063
125651
|
];
|
|
126064
|
-
_this.values
|
|
125652
|
+
_this.values.thought = (_this_values_thought = _this.values.thought) !== null && _this_values_thought !== void 0 ? _this_values_thought : "" + result.thought;
|
|
126065
125653
|
return [
|
|
126066
125654
|
4,
|
|
126067
|
-
|
|
125655
|
+
{
|
|
125656
|
+
thought: result.thought
|
|
125657
|
+
}
|
|
126068
125658
|
];
|
|
126069
125659
|
case 14:
|
|
126070
125660
|
_state.sent();
|
|
@@ -126193,14 +125783,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126193
125783
|
_state.sent();
|
|
126194
125784
|
_state.label = 34;
|
|
126195
125785
|
case 34:
|
|
126196
|
-
if (ai.getOptions().debug) {
|
|
126197
|
-
logger = ai.getLogger();
|
|
126198
|
-
logger("", {
|
|
126199
|
-
tags: [
|
|
126200
|
-
"responseEnd"
|
|
126201
|
-
]
|
|
126202
|
-
});
|
|
126203
|
-
}
|
|
126204
125786
|
return [
|
|
126205
125787
|
2
|
|
126206
125788
|
];
|
|
@@ -126278,7 +125860,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126278
125860
|
8
|
|
126279
125861
|
];
|
|
126280
125862
|
if (result.thought && result.thought.length > 0) {
|
|
126281
|
-
_this.values
|
|
125863
|
+
_this.values.thought = result.thought;
|
|
126282
125864
|
}
|
|
126283
125865
|
extractValues(_this.signature, _this.values, result.content);
|
|
126284
125866
|
return [
|
|
@@ -126372,7 +125954,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126372
125954
|
value: function _forward2(ai, values, options, span, traceContext) {
|
|
126373
125955
|
var _this = this;
|
|
126374
125956
|
return _wrap_async_generator(function() {
|
|
126375
|
-
var _loop, _this1, _this_options, _this_options1, _this_options2, _this_options3, _options_stopFunction, stopFunction, _options_maxRetries, _ref, maxRetries, _options_maxSteps, _ref1, maxSteps, _options_debug, debug, debugHideSystemPrompt, memOptions, _options_mem, _ref2, mem, _$err, _this_options4, _this_options_promptTemplate,
|
|
125957
|
+
var _loop, _this1, _this_options, _this_options1, _this_options2, _this_options3, _options_stopFunction, stopFunction, _options_maxRetries, _ref, maxRetries, _options_maxSteps, _ref1, maxSteps, _options_debug, debug, debugHideSystemPrompt, memOptions, _options_mem, _ref2, mem, _$err, _this_options4, _this_options_promptTemplate, promptTemplate, prompt, n, _ret;
|
|
126376
125958
|
return _ts_generator(this, function(_state) {
|
|
126377
125959
|
switch(_state.label){
|
|
126378
125960
|
case 0:
|
|
@@ -126382,7 +125964,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126382
125964
|
switch(_state.label){
|
|
126383
125965
|
case 0:
|
|
126384
125966
|
_loop = function(errCount) {
|
|
126385
|
-
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue,
|
|
125967
|
+
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue, e, errorFields, _errorFields_map_join, e1, _errorFields_map_join1;
|
|
126386
125968
|
return _ts_generator(this, function(_state) {
|
|
126387
125969
|
switch(_state.label){
|
|
126388
125970
|
case 0:
|
|
@@ -126500,12 +126082,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126500
126082
|
];
|
|
126501
126083
|
}
|
|
126502
126084
|
if (debug) {
|
|
126503
|
-
|
|
126504
|
-
logger("", {
|
|
126505
|
-
tags: [
|
|
126506
|
-
"responseEnd"
|
|
126507
|
-
]
|
|
126508
|
-
});
|
|
126085
|
+
process.stdout.write("\n");
|
|
126509
126086
|
}
|
|
126510
126087
|
return [
|
|
126511
126088
|
2,
|
|
@@ -126607,25 +126184,13 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126607
126184
|
};
|
|
126608
126185
|
mem = (_ref2 = (_options_mem = options.mem) !== null && _options_mem !== void 0 ? _options_mem : (_this_options3 = _this.options) === null || _this_options3 === void 0 ? void 0 : _this_options3.mem) !== null && _ref2 !== void 0 ? _ref2 : new AxMemory(1e4, memOptions);
|
|
126609
126186
|
if ((options === null || options === void 0 ? void 0 : options.functions) && options.functions.length > 0) {
|
|
126610
|
-
|
|
126611
|
-
|
|
126612
|
-
functions: options.functions,
|
|
126613
|
-
thoughtFieldName: _this.thoughtFieldName
|
|
126614
|
-
};
|
|
126615
|
-
_this.promptTemplate = new promptTemplateClass(_this.signature, currentPromptTemplateOptions);
|
|
126616
|
-
}
|
|
126617
|
-
if (Array.isArray(values)) {
|
|
126618
|
-
prompt = _this.promptTemplate.render(values, {
|
|
126619
|
-
examples: _this.examples,
|
|
126620
|
-
demos: _this.demos
|
|
126621
|
-
});
|
|
126622
|
-
} else {
|
|
126623
|
-
prompt = _this.promptTemplate.render(values, {
|
|
126624
|
-
// Cast if necessary
|
|
126625
|
-
examples: _this.examples,
|
|
126626
|
-
demos: _this.demos
|
|
126627
|
-
});
|
|
126187
|
+
promptTemplate = (_this_options_promptTemplate = (_this_options4 = _this.options) === null || _this_options4 === void 0 ? void 0 : _this_options4.promptTemplate) !== null && _this_options_promptTemplate !== void 0 ? _this_options_promptTemplate : AxPromptTemplate;
|
|
126188
|
+
_this.promptTemplate = new promptTemplate(_this.signature, options.functions);
|
|
126628
126189
|
}
|
|
126190
|
+
prompt = _this.promptTemplate.render(values, {
|
|
126191
|
+
examples: _this.examples,
|
|
126192
|
+
demos: _this.demos
|
|
126193
|
+
});
|
|
126629
126194
|
mem.add(prompt, options === null || options === void 0 ? void 0 : options.sessionId);
|
|
126630
126195
|
n = 0;
|
|
126631
126196
|
_state.label = 1;
|
|
@@ -126726,8 +126291,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126726
126291
|
model: options.model
|
|
126727
126292
|
} : {}, (options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) ? {
|
|
126728
126293
|
thinking_token_budget: options.thinkingTokenBudget
|
|
126729
|
-
} : {}, (options === null || options === void 0 ? void 0 : options.showThoughts) ? {
|
|
126730
|
-
show_thoughts: options.showThoughts
|
|
126731
126294
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxSteps) ? {
|
|
126732
126295
|
max_steps: options.maxSteps
|
|
126733
126296
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxRetries) ? {
|
|
@@ -126915,12 +126478,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126915
126478
|
});
|
|
126916
126479
|
})();
|
|
126917
126480
|
}
|
|
126918
|
-
},
|
|
126919
|
-
{
|
|
126920
|
-
key: "setExamples",
|
|
126921
|
-
value: function setExamples(examples, options) {
|
|
126922
|
-
_get(_get_prototype_of(AxGen.prototype), "setExamples", this).call(this, examples, options);
|
|
126923
|
-
}
|
|
126924
126481
|
}
|
|
126925
126482
|
]);
|
|
126926
126483
|
return AxGen;
|
|
@@ -126976,32 +126533,13 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
|
|
|
126976
126533
|
var originalFunc = processedFunction.func;
|
|
126977
126534
|
processedFunction.func = function() {
|
|
126978
126535
|
var _ref = _async_to_generator(function(childArgs, funcOptions) {
|
|
126979
|
-
var
|
|
126536
|
+
var updatedChildArgs;
|
|
126980
126537
|
return _ts_generator(this, function(_state) {
|
|
126981
126538
|
switch(_state.label){
|
|
126982
126539
|
case 0:
|
|
126983
|
-
|
|
126984
|
-
if (Array.isArray(parentValues)) {
|
|
126985
|
-
lastUserMessage = parentValues.filter(function(msg) {
|
|
126986
|
-
return msg.role === "user";
|
|
126987
|
-
}).pop();
|
|
126988
|
-
if (lastUserMessage) {
|
|
126989
|
-
valuesToInject = pick(lastUserMessage.values, injectionKeys);
|
|
126990
|
-
}
|
|
126991
|
-
} else {
|
|
126992
|
-
valuesToInject = pick(parentValues, injectionKeys);
|
|
126993
|
-
}
|
|
126994
|
-
updatedChildArgs = _object_spread({}, childArgs, valuesToInject);
|
|
126540
|
+
updatedChildArgs = _object_spread({}, childArgs, pick(parentValues, injectionKeys));
|
|
126995
126541
|
if (options.debug && injectionKeys.length > 0) {
|
|
126996
|
-
|
|
126997
|
-
if (ai) {
|
|
126998
|
-
logger = ai.getLogger();
|
|
126999
|
-
logger("Function Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)), {
|
|
127000
|
-
tags: [
|
|
127001
|
-
"functionArg"
|
|
127002
|
-
]
|
|
127003
|
-
});
|
|
127004
|
-
}
|
|
126542
|
+
process.stdout.write("\nFunction Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)));
|
|
127005
126543
|
}
|
|
127006
126544
|
return [
|
|
127007
126545
|
4,
|
|
@@ -127100,8 +126638,8 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127100
126638
|
_create_class(AxAgent, [
|
|
127101
126639
|
{
|
|
127102
126640
|
key: "setExamples",
|
|
127103
|
-
value: function setExamples(examples
|
|
127104
|
-
this.program.setExamples(examples
|
|
126641
|
+
value: function setExamples(examples) {
|
|
126642
|
+
this.program.setExamples(examples);
|
|
127105
126643
|
}
|
|
127106
126644
|
},
|
|
127107
126645
|
{
|
|
@@ -127147,7 +126685,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127147
126685
|
var _this = this;
|
|
127148
126686
|
var wrappedFunc = function() {
|
|
127149
126687
|
var _ref = _async_to_generator(function(valuesAndModel, options) {
|
|
127150
|
-
var model, values, _this_ai, ai, debug,
|
|
126688
|
+
var model, values, _this_ai, ai, debug, ret, sig, outFields, result;
|
|
127151
126689
|
return _ts_generator(this, function(_state) {
|
|
127152
126690
|
switch(_state.label){
|
|
127153
126691
|
case 0:
|
|
@@ -127160,12 +126698,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127160
126698
|
}
|
|
127161
126699
|
debug = _this.getDebug(ai, options);
|
|
127162
126700
|
if (debug) {
|
|
127163
|
-
|
|
127164
|
-
logger("\uD83E\uDD16 Agent ".concat(_this.name, " starting..."), {
|
|
127165
|
-
tags: [
|
|
127166
|
-
"assistantStart"
|
|
127167
|
-
]
|
|
127168
|
-
});
|
|
126701
|
+
process.stdout.write("\n--- Agent Engaged: ".concat(_this.name, " ---\n"));
|
|
127169
126702
|
}
|
|
127170
126703
|
return [
|
|
127171
126704
|
4,
|
|
@@ -127176,12 +126709,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127176
126709
|
case 1:
|
|
127177
126710
|
ret = _state.sent();
|
|
127178
126711
|
if (debug) {
|
|
127179
|
-
|
|
127180
|
-
logger1("\uD83E\uDD16 Agent ".concat(_this.name, " completed."), {
|
|
127181
|
-
tags: [
|
|
127182
|
-
"assistantEnd"
|
|
127183
|
-
]
|
|
127184
|
-
});
|
|
126712
|
+
process.stdout.write("\n--- Agent Done: ".concat(_this.name, " ---\n"));
|
|
127185
126713
|
}
|
|
127186
126714
|
sig = _this.program.getSignature();
|
|
127187
126715
|
outFields = sig.getOutputFields();
|
|
@@ -127747,12 +127275,6 @@ function pick(obj, keys) {
|
|
|
127747
127275
|
value: function getOptions() {
|
|
127748
127276
|
return this.currentService.getOptions();
|
|
127749
127277
|
}
|
|
127750
|
-
},
|
|
127751
|
-
{
|
|
127752
|
-
key: "getLogger",
|
|
127753
|
-
value: function getLogger() {
|
|
127754
|
-
return this.currentService.getLogger();
|
|
127755
|
-
}
|
|
127756
127278
|
}
|
|
127757
127279
|
]);
|
|
127758
127280
|
return _AxBalancer;
|
|
@@ -127866,8 +127388,7 @@ var AxChainOfThought = /*#__PURE__*/ function(AxGen) {
|
|
|
127866
127388
|
sig.setOutputFields([
|
|
127867
127389
|
{
|
|
127868
127390
|
name: "reason",
|
|
127869
|
-
description: description
|
|
127870
|
-
isInternal: (options === null || options === void 0 ? void 0 : options.setVisibleReasoning) !== true
|
|
127391
|
+
description: description
|
|
127871
127392
|
}
|
|
127872
127393
|
].concat(_to_consumable_array(sig.getOutputFields())));
|
|
127873
127394
|
return _super.call(this, sig, options);
|
|
@@ -127882,8 +127403,10 @@ for(var i = 0; i < 256; ++i){
|
|
|
127882
127403
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
127883
127404
|
}
|
|
127884
127405
|
({
|
|
127885
|
-
randomUUID:
|
|
127406
|
+
randomUUID: require$$0__default$5["default"].randomUUID
|
|
127886
127407
|
});
|
|
127408
|
+
// mcp/client.ts
|
|
127409
|
+
new ColorLog();
|
|
127887
127410
|
|
|
127888
127411
|
let DspService = class DspService {
|
|
127889
127412
|
async prepareFunctions(functions, context) {
|