@digipair/skill-dsp 0.88.3-2 → 0.88.5
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 +286 -814
- package/index.esm.js +290 -818
- 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;
|
|
@@ -120332,6 +120133,7 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
|
|
|
120332
120133
|
modelInfo: modelInfo,
|
|
120333
120134
|
models: models,
|
|
120334
120135
|
supportFor: supportFor,
|
|
120136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120335
120137
|
chatReqUpdater: chatReqUpdater
|
|
120336
120138
|
});
|
|
120337
120139
|
_get((_assert_this_initialized(_this), _get_prototype_of(AxAIMistral.prototype)), "setName", _this).call(_this, "Mistral");
|
|
@@ -120559,7 +120361,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120559
120361
|
},
|
|
120560
120362
|
{
|
|
120561
120363
|
key: "createChatReq",
|
|
120562
|
-
value: function createChatReq(req,
|
|
120364
|
+
value: function createChatReq(req, _config) {
|
|
120563
120365
|
var _req_functions, _req_modelConfig, _req_modelConfig1, _req_modelConfig2, _req_modelConfig3, _req_chatPrompt_, _req_chatPrompt_1;
|
|
120564
120366
|
var model = req.model;
|
|
120565
120367
|
var apiConfig = {
|
|
@@ -120604,10 +120406,6 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120604
120406
|
parameters: (_v_parameters = v.parameters) !== null && _v_parameters !== void 0 ? _v_parameters : {}
|
|
120605
120407
|
};
|
|
120606
120408
|
});
|
|
120607
|
-
var includeFields = [];
|
|
120608
|
-
if (config.showThoughts) {
|
|
120609
|
-
includeFields.push("reasoning.encrypted_content");
|
|
120610
|
-
}
|
|
120611
120409
|
var _req_modelConfig_maxTokens, _ref1, _req_modelConfig_temperature, _ref2, _req_modelConfig_topP, _ref3, _req_modelConfig_stream, _ref4;
|
|
120612
120410
|
var mutableReq = {
|
|
120613
120411
|
model: model,
|
|
@@ -120626,7 +120424,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120626
120424
|
// Sourced from modelConfig or global config
|
|
120627
120425
|
// Optional fields from AxAIOpenAIResponsesRequest that need to be in Mutable for initialization
|
|
120628
120426
|
background: void 0,
|
|
120629
|
-
include:
|
|
120427
|
+
include: void 0,
|
|
120630
120428
|
metadata: void 0,
|
|
120631
120429
|
parallel_tool_calls: this.config.parallelToolCalls,
|
|
120632
120430
|
previous_response_id: void 0,
|
|
@@ -120701,13 +120499,9 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
120701
120499
|
break;
|
|
120702
120500
|
case "reasoning":
|
|
120703
120501
|
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
|
-
}
|
|
120502
|
+
currentResult.thought = item.summary.map(function(s) {
|
|
120503
|
+
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
120504
|
+
}).join("\n");
|
|
120711
120505
|
break;
|
|
120712
120506
|
case "file_search_call":
|
|
120713
120507
|
currentResult.id = item.id;
|
|
@@ -121047,9 +120841,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
121047
120841
|
{
|
|
121048
120842
|
var reasoningItem = event.item;
|
|
121049
120843
|
baseResult.id = event.item.id;
|
|
121050
|
-
if (reasoningItem.
|
|
121051
|
-
baseResult.thought = reasoningItem.encrypted_content;
|
|
121052
|
-
} else if (reasoningItem.summary) {
|
|
120844
|
+
if (reasoningItem.summary) {
|
|
121053
120845
|
baseResult.thought = reasoningItem.summary.map(function(s) {
|
|
121054
120846
|
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
121055
120847
|
}).join("\n");
|
|
@@ -121277,6 +121069,7 @@ var axAIOpenAIResponsesDefaultConfig = function() {
|
|
|
121277
121069
|
model: "gpt-4o" /* GPT4O */ ,
|
|
121278
121070
|
embedModel: "text-embedding-ada-002" /* TextEmbeddingAda002 */ ,
|
|
121279
121071
|
temperature: 0.7,
|
|
121072
|
+
maxTokens: 2048,
|
|
121280
121073
|
topP: 1,
|
|
121281
121074
|
stream: true
|
|
121282
121075
|
};
|
|
@@ -121402,14 +121195,14 @@ var AxAIRekaImpl = /*#__PURE__*/ function() {
|
|
|
121402
121195
|
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
121196
|
var _req_modelConfig_stream;
|
|
121404
121197
|
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,
|
|
121198
|
+
var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP, _ref1, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
|
|
121406
121199
|
var reqValue = _object_spread({
|
|
121407
121200
|
model: model,
|
|
121408
121201
|
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,
|
|
121202
|
+
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
121203
|
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
121204
|
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: (
|
|
121205
|
+
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
121206
|
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
121207
|
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
121208
|
}, frequencyPenalty ? {
|
|
@@ -121808,12 +121601,6 @@ var AxAI = /*#__PURE__*/ function() {
|
|
|
121808
121601
|
value: function getOptions() {
|
|
121809
121602
|
return this.ai.getOptions();
|
|
121810
121603
|
}
|
|
121811
|
-
},
|
|
121812
|
-
{
|
|
121813
|
-
key: "getLogger",
|
|
121814
|
-
value: function getLogger() {
|
|
121815
|
-
return this.ai.getLogger();
|
|
121816
|
-
}
|
|
121817
121604
|
}
|
|
121818
121605
|
]);
|
|
121819
121606
|
return AxAI;
|
|
@@ -121963,7 +121750,7 @@ var MemoryImpl = /*#__PURE__*/ function() {
|
|
|
121963
121750
|
if ((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.debug) {
|
|
121964
121751
|
if (delta && typeof delta === "string") {
|
|
121965
121752
|
debugResponseDelta(delta);
|
|
121966
|
-
} else if (
|
|
121753
|
+
} else if (lastItem) {
|
|
121967
121754
|
debugResponse({
|
|
121968
121755
|
content: content,
|
|
121969
121756
|
name: name,
|
|
@@ -122382,8 +122169,6 @@ var validateValue = function(field, value) {
|
|
|
122382
122169
|
};
|
|
122383
122170
|
var validateSingleValue = function(expectedType, val) {
|
|
122384
122171
|
switch(expectedType){
|
|
122385
|
-
case "class":
|
|
122386
|
-
return typeof val === "string";
|
|
122387
122172
|
case "code":
|
|
122388
122173
|
return typeof val === "string";
|
|
122389
122174
|
case "string":
|
|
@@ -122438,7 +122223,7 @@ var validateValue = function(field, value) {
|
|
|
122438
122223
|
msg = "object ({ mimeType: string; data: string })";
|
|
122439
122224
|
}
|
|
122440
122225
|
if (msg) {
|
|
122441
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
122226
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg, " instead got '").concat(value, "'"));
|
|
122442
122227
|
}
|
|
122443
122228
|
return;
|
|
122444
122229
|
}
|
|
@@ -122478,7 +122263,7 @@ var validateValue = function(field, value) {
|
|
|
122478
122263
|
msg1 = "object ({ data: string; format?: string })";
|
|
122479
122264
|
}
|
|
122480
122265
|
if (msg1) {
|
|
122481
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
122266
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg1, " instead got '").concat(value, "'"));
|
|
122482
122267
|
}
|
|
122483
122268
|
return;
|
|
122484
122269
|
}
|
|
@@ -122516,8 +122301,7 @@ var validateValue = function(field, value) {
|
|
|
122516
122301
|
}
|
|
122517
122302
|
if (!isValid) {
|
|
122518
122303
|
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), ")"));
|
|
122304
|
+
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
122305
|
}
|
|
122522
122306
|
};
|
|
122523
122307
|
function mergeProgramUsage(usages) {
|
|
@@ -122718,15 +122502,13 @@ function matchesContent(content, prefix) {
|
|
|
122718
122502
|
// dsp/prompt.ts
|
|
122719
122503
|
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
122504
|
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,
|
|
122505
|
+
var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates) {
|
|
122722
122506
|
var _this = this;
|
|
122723
122507
|
_class_call_check(this, AxPromptTemplate);
|
|
122724
|
-
var
|
|
122508
|
+
var _functions_map;
|
|
122725
122509
|
_define_property(this, "sig", void 0);
|
|
122726
122510
|
_define_property(this, "fieldTemplates", void 0);
|
|
122727
122511
|
_define_property(this, "task", void 0);
|
|
122728
|
-
_define_property(this, "thoughtFieldName", void 0);
|
|
122729
|
-
_define_property(this, "functions", void 0);
|
|
122730
122512
|
_define_property(this, "render", function(values, param) {
|
|
122731
122513
|
var examples = param.examples, demos = param.demos;
|
|
122732
122514
|
var renderedExamples = examples ? [
|
|
@@ -122736,6 +122518,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122736
122518
|
}
|
|
122737
122519
|
].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
|
|
122738
122520
|
var renderedDemos = demos ? _this.renderDemos(demos) : [];
|
|
122521
|
+
var completion = _this.renderInputFields(values);
|
|
122739
122522
|
var allTextExamples = renderedExamples.every(function(v) {
|
|
122740
122523
|
return v.type === "text";
|
|
122741
122524
|
});
|
|
@@ -122760,92 +122543,23 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122760
122543
|
role: "system",
|
|
122761
122544
|
content: systemContent
|
|
122762
122545
|
};
|
|
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
|
-
}
|
|
122546
|
+
var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
|
|
122547
|
+
var prompt = promptList.filter(function(v) {
|
|
122548
|
+
return v !== void 0;
|
|
122549
|
+
});
|
|
122550
|
+
var userContent = prompt.every(function(v) {
|
|
122551
|
+
return v.type === "text";
|
|
122552
|
+
}) ? prompt.map(function(v) {
|
|
122553
|
+
return v.text;
|
|
122554
|
+
}).join("\n") : prompt.reduce(combineConsecutiveStrings("\n"), []);
|
|
122555
|
+
var userPrompt = {
|
|
122556
|
+
role: "user",
|
|
122557
|
+
content: userContent
|
|
122558
|
+
};
|
|
122846
122559
|
return [
|
|
122847
|
-
systemPrompt
|
|
122848
|
-
|
|
122560
|
+
systemPrompt,
|
|
122561
|
+
userPrompt
|
|
122562
|
+
];
|
|
122849
122563
|
});
|
|
122850
122564
|
_define_property(this, "renderExtraFields", function(extraFields) {
|
|
122851
122565
|
var prompt = [];
|
|
@@ -122891,28 +122605,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122891
122605
|
});
|
|
122892
122606
|
_define_property(this, "renderExamples", function(data) {
|
|
122893
122607
|
var list = [];
|
|
122894
|
-
var exampleContext = {
|
|
122895
|
-
isExample: true
|
|
122896
|
-
};
|
|
122897
122608
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122898
122609
|
try {
|
|
122899
122610
|
var _loop = function() {
|
|
122900
122611
|
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
|
|
122901
122612
|
var _renderedItem_;
|
|
122902
122613
|
var renderedInputItem = _this.sig.getInputFields().map(function(field) {
|
|
122903
|
-
return _this.renderInField(field, item,
|
|
122904
|
-
isInputField: true
|
|
122905
|
-
}));
|
|
122614
|
+
return _this.renderInField(field, item, true);
|
|
122906
122615
|
}).filter(function(v) {
|
|
122907
122616
|
return v !== void 0;
|
|
122908
122617
|
}).flat();
|
|
122909
122618
|
var renderedOutputItem = _this.sig.getOutputFields().map(function(field) {
|
|
122910
|
-
return _this.renderInField(field, item,
|
|
122911
|
-
isInputField: false
|
|
122912
|
-
}));
|
|
122619
|
+
return _this.renderInField(field, item, true);
|
|
122913
122620
|
}).filter(function(v) {
|
|
122914
122621
|
return v !== void 0;
|
|
122915
122622
|
}).flat();
|
|
122623
|
+
if (renderedOutputItem.length === 0) {
|
|
122624
|
+
throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
|
|
122625
|
+
}
|
|
122916
122626
|
var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
|
|
122917
122627
|
if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
|
|
122918
122628
|
list.push({
|
|
@@ -122949,30 +122659,16 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
122949
122659
|
});
|
|
122950
122660
|
_define_property(this, "renderDemos", function(data) {
|
|
122951
122661
|
var list = [];
|
|
122952
|
-
var
|
|
122953
|
-
var outputFields = _this.sig.getOutputFields();
|
|
122954
|
-
var demoContext = {
|
|
122955
|
-
isExample: true
|
|
122956
|
-
};
|
|
122662
|
+
var fields = _to_consumable_array(_this.sig.getInputFields()).concat(_to_consumable_array(_this.sig.getOutputFields()));
|
|
122957
122663
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
122958
122664
|
try {
|
|
122959
122665
|
var _loop = function() {
|
|
122960
122666
|
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
|
-
}));
|
|
122667
|
+
var renderedItem = fields.map(function(field) {
|
|
122668
|
+
return _this.renderInField(field, item, true);
|
|
122972
122669
|
}).filter(function(v) {
|
|
122973
122670
|
return v !== void 0;
|
|
122974
122671
|
}).flat();
|
|
122975
|
-
var renderedItem = _to_consumable_array(inputRenderedItems).concat(_to_consumable_array(outputRenderedItems));
|
|
122976
122672
|
renderedItem.slice(0, -1).forEach(function(v) {
|
|
122977
122673
|
if ("text" in v) {
|
|
122978
122674
|
v.text = v.text + "\n";
|
|
@@ -123002,7 +122698,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123002
122698
|
});
|
|
123003
122699
|
_define_property(this, "renderInputFields", function(values) {
|
|
123004
122700
|
var renderedItems = _this.sig.getInputFields().map(function(field) {
|
|
123005
|
-
return _this.renderInField(field, values
|
|
122701
|
+
return _this.renderInField(field, values);
|
|
123006
122702
|
}).filter(function(v) {
|
|
123007
122703
|
return v !== void 0;
|
|
123008
122704
|
}).flat();
|
|
@@ -123013,10 +122709,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123013
122709
|
});
|
|
123014
122710
|
return renderedItems;
|
|
123015
122711
|
});
|
|
123016
|
-
_define_property(this, "renderInField", function(field, values,
|
|
122712
|
+
_define_property(this, "renderInField", function(field, values, skipMissing) {
|
|
123017
122713
|
var _this_fieldTemplates;
|
|
123018
122714
|
var value = values[field.name];
|
|
123019
|
-
if (
|
|
122715
|
+
if (skipMissing && !value) {
|
|
122716
|
+
return;
|
|
122717
|
+
}
|
|
122718
|
+
if (isEmptyValue(field, value)) {
|
|
123020
122719
|
return;
|
|
123021
122720
|
}
|
|
123022
122721
|
if (field.type) {
|
|
@@ -123056,19 +122755,19 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123056
122755
|
throw new Error("Image field value must be an array.");
|
|
123057
122756
|
}
|
|
123058
122757
|
result = result.concat(value.map(function(v) {
|
|
123059
|
-
|
|
122758
|
+
v = validateImage(v);
|
|
123060
122759
|
return {
|
|
123061
122760
|
type: "image",
|
|
123062
|
-
mimeType:
|
|
123063
|
-
image:
|
|
122761
|
+
mimeType: v.mimeType,
|
|
122762
|
+
image: v.data
|
|
123064
122763
|
};
|
|
123065
122764
|
}));
|
|
123066
122765
|
} else {
|
|
123067
|
-
var
|
|
122766
|
+
var v = validateImage(value);
|
|
123068
122767
|
result.push({
|
|
123069
122768
|
type: "image",
|
|
123070
|
-
mimeType:
|
|
123071
|
-
image:
|
|
122769
|
+
mimeType: v.mimeType,
|
|
122770
|
+
image: v.data
|
|
123072
122771
|
});
|
|
123073
122772
|
}
|
|
123074
122773
|
return result;
|
|
@@ -123094,24 +122793,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123094
122793
|
];
|
|
123095
122794
|
if (field.type.isArray) {
|
|
123096
122795
|
if (!Array.isArray(value)) {
|
|
123097
|
-
throw new Error("
|
|
122796
|
+
throw new Error("Image field value must be an array.");
|
|
123098
122797
|
}
|
|
123099
122798
|
result1 = result1.concat(value.map(function(v) {
|
|
123100
|
-
|
|
123101
|
-
var
|
|
122799
|
+
v = validateAudio(v);
|
|
122800
|
+
var _v_format;
|
|
123102
122801
|
return {
|
|
123103
122802
|
type: "audio",
|
|
123104
|
-
format: (
|
|
123105
|
-
data:
|
|
122803
|
+
format: (_v_format = v.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
122804
|
+
data: v.data
|
|
123106
122805
|
};
|
|
123107
122806
|
}));
|
|
123108
122807
|
} else {
|
|
123109
|
-
var
|
|
123110
|
-
var
|
|
122808
|
+
var v1 = validateAudio(value);
|
|
122809
|
+
var _v_format;
|
|
123111
122810
|
result1.push({
|
|
123112
122811
|
type: "audio",
|
|
123113
|
-
format: (
|
|
123114
|
-
data:
|
|
122812
|
+
format: (_v_format = v1.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
122813
|
+
data: v1.data
|
|
123115
122814
|
});
|
|
123116
122815
|
}
|
|
123117
122816
|
return result1;
|
|
@@ -123137,16 +122836,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
123137
122836
|
});
|
|
123138
122837
|
this.sig = sig;
|
|
123139
122838
|
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
122839
|
var task = [];
|
|
123144
122840
|
var inArgs = renderDescFields(this.sig.getInputFields());
|
|
123145
122841
|
var outArgs = renderDescFields(this.sig.getOutputFields());
|
|
123146
122842
|
task.push("You will be provided with the following fields: ".concat(inArgs, ". Your task is to generate new fields: ").concat(outArgs, "."));
|
|
123147
|
-
var funcs =
|
|
122843
|
+
var funcs = functions === null || functions === void 0 ? void 0 : (_functions_map = functions.map(function(f) {
|
|
123148
122844
|
return "toFunction" in f ? f.toFunction() : f;
|
|
123149
|
-
})) === null ||
|
|
122845
|
+
})) === null || _functions_map === void 0 ? void 0 : _functions_map.flat();
|
|
123150
122846
|
var funcList = funcs === null || funcs === void 0 ? void 0 : funcs.map(function(fn) {
|
|
123151
122847
|
return "- `".concat(fn.name, "`: ").concat(formatDescription(fn.description));
|
|
123152
122848
|
}).join("\n");
|
|
@@ -123259,19 +122955,15 @@ function combineConsecutiveStrings(separator) {
|
|
|
123259
122955
|
return acc;
|
|
123260
122956
|
};
|
|
123261
122957
|
}
|
|
123262
|
-
var isEmptyValue = function(field, value
|
|
122958
|
+
var isEmptyValue = function(field, value) {
|
|
123263
122959
|
if (typeof value === "boolean") {
|
|
123264
122960
|
return false;
|
|
123265
122961
|
}
|
|
123266
122962
|
if (!value || (Array.isArray(value) || typeof value === "string") && value.length === 0) {
|
|
123267
|
-
if (
|
|
123268
|
-
return true;
|
|
123269
|
-
}
|
|
123270
|
-
if (field.isOptional || field.isInternal) {
|
|
122963
|
+
if (field.isOptional) {
|
|
123271
122964
|
return true;
|
|
123272
122965
|
}
|
|
123273
|
-
|
|
123274
|
-
throw new Error("Value for ".concat(fieldType, " field '").concat(field.name, "' is required."));
|
|
122966
|
+
throw new Error("Value for input field '".concat(field.name, "' is required."));
|
|
123275
122967
|
}
|
|
123276
122968
|
return false;
|
|
123277
122969
|
};
|
|
@@ -123280,6 +122972,7 @@ function formatDescription(str) {
|
|
|
123280
122972
|
return value.length > 0 ? "".concat(value.charAt(0).toUpperCase()).concat(value.slice(1)).concat(value.endsWith(".") ? "" : ".") : "";
|
|
123281
122973
|
}
|
|
123282
122974
|
// dsp/validate.ts
|
|
122975
|
+
var colorLog4 = new ColorLog();
|
|
123283
122976
|
var ValidationError = (_Symbol_for2 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
123284
122977
|
_inherits(_class, Error1);
|
|
123285
122978
|
var _super = _create_super(_class);
|
|
@@ -123332,12 +123025,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
|
|
|
123332
123025
|
var errors = errorFields.map(function(field) {
|
|
123333
123026
|
return "- ".concat(field.title, ": ").concat(field.description);
|
|
123334
123027
|
}).join("\n");
|
|
123335
|
-
|
|
123336
|
-
logger("❌ Error Correction:\n".concat(errors), {
|
|
123337
|
-
tags: [
|
|
123338
|
-
"error"
|
|
123339
|
-
]
|
|
123340
|
-
});
|
|
123028
|
+
process.stdout.write(colorLog4.red("\n❌ Error Correction:\n".concat(errors, "\n")));
|
|
123341
123029
|
}
|
|
123342
123030
|
}
|
|
123343
123031
|
// dsp/datetime.ts
|
|
@@ -124149,9 +123837,6 @@ var validateJSONSchema = function(schema) {
|
|
|
124149
123837
|
var errors = [];
|
|
124150
123838
|
var validateSchemaObject = function(schema2) {
|
|
124151
123839
|
var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
124152
|
-
if (!schema2 || typeof schema2 !== "object") {
|
|
124153
|
-
return;
|
|
124154
|
-
}
|
|
124155
123840
|
var validTypes = [
|
|
124156
123841
|
"array",
|
|
124157
123842
|
"integer",
|
|
@@ -124161,174 +123846,42 @@ var validateJSONSchema = function(schema) {
|
|
|
124161
123846
|
"null",
|
|
124162
123847
|
"object"
|
|
124163
123848
|
];
|
|
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
123849
|
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
|
-
});
|
|
123850
|
+
errors.push("Invalid type '".concat(schema2.type, "' at ").concat(path || "root"));
|
|
124216
123851
|
return;
|
|
124217
123852
|
}
|
|
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, "."));
|
|
123853
|
+
if (schema2.type === "object" && schema2.properties) {
|
|
123854
|
+
if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
|
|
123855
|
+
errors.push("Invalid properties object at ".concat(path || "root"));
|
|
123856
|
+
} else {
|
|
123857
|
+
for(var key in schema2.properties){
|
|
123858
|
+
var value = schema2.properties[key];
|
|
123859
|
+
if (typeof value !== "object") {
|
|
123860
|
+
errors.push("Invalid schema object at ".concat(path).concat(key));
|
|
123861
|
+
continue;
|
|
124243
123862
|
}
|
|
123863
|
+
validateSchemaObject(value, "".concat(path).concat(key, "."));
|
|
124244
123864
|
}
|
|
124245
123865
|
}
|
|
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
|
-
}
|
|
123866
|
+
if (schema2.required && !Array.isArray(schema2.required)) {
|
|
123867
|
+
errors.push("'required' should be an array at ".concat(path || "root"));
|
|
124292
123868
|
}
|
|
124293
123869
|
}
|
|
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
|
-
}
|
|
123870
|
+
if (schema2.type === "array" && schema2.items) {
|
|
123871
|
+
if (typeof schema2.items !== "object") {
|
|
123872
|
+
errors.push("Invalid items schema at ".concat(path || "root"));
|
|
123873
|
+
} else {
|
|
123874
|
+
validateSchemaObject(schema2.items, "".concat(path, "items."));
|
|
124306
123875
|
}
|
|
124307
123876
|
}
|
|
124308
123877
|
};
|
|
124309
123878
|
validateSchemaObject(schema);
|
|
124310
123879
|
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);
|
|
123880
|
+
throw new Error(errors.join("; "));
|
|
124329
123881
|
}
|
|
124330
123882
|
};
|
|
124331
123883
|
// dsp/functions.ts
|
|
123884
|
+
var colorLog5 = new ColorLog();
|
|
124332
123885
|
var AxFunctionError = (_Symbol_for3 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
124333
123886
|
_inherits(_class, Error1);
|
|
124334
123887
|
var _super = _create_super(_class);
|
|
@@ -124654,12 +124207,7 @@ var processFunctions = function() {
|
|
|
124654
124207
|
}, sessionId);
|
|
124655
124208
|
mem.addTag("error");
|
|
124656
124209
|
if (ai.getOptions().debug) {
|
|
124657
|
-
|
|
124658
|
-
logger("❌ Function Error Correction:\n".concat(result), {
|
|
124659
|
-
tags: [
|
|
124660
|
-
"error"
|
|
124661
|
-
]
|
|
124662
|
-
});
|
|
124210
|
+
process.stdout.write(colorLog5.red("\n❌ Function Error Correction:\n".concat(result, "\n")));
|
|
124663
124211
|
}
|
|
124664
124212
|
} else {
|
|
124665
124213
|
throw e;
|
|
@@ -125288,7 +124836,7 @@ var AxSignature = function _AxSignature(signature) {
|
|
|
125288
124836
|
}
|
|
125289
124837
|
});
|
|
125290
124838
|
var _this_description;
|
|
125291
|
-
_this.sigHash =
|
|
124839
|
+
_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
124840
|
_this.sigString = renderSignature(_this.description, _this.inputFields, _this.outputFields);
|
|
125293
124841
|
return [
|
|
125294
124842
|
_this.sigHash,
|
|
@@ -125402,7 +124950,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125402
124950
|
_define_property(this, "signature", void 0);
|
|
125403
124951
|
_define_property(this, "sigHash", void 0);
|
|
125404
124952
|
_define_property(this, "examples", void 0);
|
|
125405
|
-
_define_property(this, "examplesOptions", void 0);
|
|
125406
124953
|
_define_property(this, "demos", void 0);
|
|
125407
124954
|
_define_property(this, "trace", void 0);
|
|
125408
124955
|
_define_property(this, "usage", []);
|
|
@@ -125497,8 +125044,8 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125497
125044
|
},
|
|
125498
125045
|
{
|
|
125499
125046
|
key: "setExamples",
|
|
125500
|
-
value: function setExamples(examples
|
|
125501
|
-
this._setExamples(examples
|
|
125047
|
+
value: function setExamples(examples) {
|
|
125048
|
+
this._setExamples(examples);
|
|
125502
125049
|
if (!("programId" in examples)) {
|
|
125503
125050
|
return;
|
|
125504
125051
|
}
|
|
@@ -125506,7 +125053,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125506
125053
|
try {
|
|
125507
125054
|
for(var _iterator = this.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
125508
125055
|
var child = _step.value;
|
|
125509
|
-
child.setExamples(examples
|
|
125056
|
+
child.setExamples(examples);
|
|
125510
125057
|
}
|
|
125511
125058
|
} catch (err) {
|
|
125512
125059
|
_didIteratorError = true;
|
|
@@ -125526,7 +125073,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125526
125073
|
},
|
|
125527
125074
|
{
|
|
125528
125075
|
key: "_setExamples",
|
|
125529
|
-
value: function _setExamples(examples
|
|
125076
|
+
value: function _setExamples(examples) {
|
|
125530
125077
|
var traces = [];
|
|
125531
125078
|
if ("programId" in examples && examples.programId === this.key.id) {
|
|
125532
125079
|
traces = examples.traces;
|
|
@@ -125535,7 +125082,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125535
125082
|
traces = examples;
|
|
125536
125083
|
}
|
|
125537
125084
|
if (traces) {
|
|
125538
|
-
this.examplesOptions = options;
|
|
125539
125085
|
var sig = this.signature;
|
|
125540
125086
|
var fields = _to_consumable_array(sig.getInputFields()).concat(_to_consumable_array(sig.getOutputFields()));
|
|
125541
125087
|
this.examples = traces.map(function(e) {
|
|
@@ -125545,7 +125091,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
125545
125091
|
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
125546
125092
|
var f = _step.value;
|
|
125547
125093
|
var value = e[f.name];
|
|
125548
|
-
if (value
|
|
125094
|
+
if (value) {
|
|
125549
125095
|
validateValue(f, value);
|
|
125550
125096
|
res[f.name] = value;
|
|
125551
125097
|
}
|
|
@@ -125713,8 +125259,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125713
125259
|
_define_property(_assert_this_initialized(_this), "streamingFieldProcessors", []);
|
|
125714
125260
|
_define_property(_assert_this_initialized(_this), "values", {});
|
|
125715
125261
|
_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
125262
|
_define_property(_assert_this_initialized(_this), "addAssert", function(fn, message) {
|
|
125719
125263
|
_this.asserts.push({
|
|
125720
125264
|
fn: fn,
|
|
@@ -125761,15 +125305,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125761
125305
|
_this.addFieldProcessorInternal(fieldName, fn, false);
|
|
125762
125306
|
});
|
|
125763
125307
|
_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
125308
|
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,
|
|
125309
|
+
_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
125310
|
var _this_options_asserts;
|
|
125774
125311
|
_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
125312
|
var _this_options_streamingAsserts;
|
|
@@ -125789,11 +125326,11 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125789
125326
|
var ai = param.ai, mem = param.mem, options = param.options, traceContext = param.traceContext, firstStep = param.firstStep;
|
|
125790
125327
|
var _this = this;
|
|
125791
125328
|
return _async_to_generator(function() {
|
|
125792
|
-
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget,
|
|
125329
|
+
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget, _mem_history, chatPrompt, functions, functionCall, res;
|
|
125793
125330
|
return _ts_generator(this, function(_state) {
|
|
125794
125331
|
switch(_state.label){
|
|
125795
125332
|
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
|
|
125333
|
+
_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
125334
|
chatPrompt = (_mem_history = mem === null || mem === void 0 ? void 0 : mem.history(sessionId)) !== null && _mem_history !== void 0 ? _mem_history : [];
|
|
125798
125335
|
if (chatPrompt.length === 0) {
|
|
125799
125336
|
throw new Error("No chat prompt found");
|
|
@@ -125820,9 +125357,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125820
125357
|
stream: stream,
|
|
125821
125358
|
debug: false,
|
|
125822
125359
|
thinkingTokenBudget: thinkingTokenBudget,
|
|
125823
|
-
|
|
125824
|
-
traceContext: traceContext,
|
|
125825
|
-
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal
|
|
125360
|
+
traceContext: traceContext
|
|
125826
125361
|
})
|
|
125827
125362
|
];
|
|
125828
125363
|
case 1:
|
|
@@ -125864,7 +125399,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125864
125399
|
];
|
|
125865
125400
|
case 1:
|
|
125866
125401
|
res = _state.sent();
|
|
125867
|
-
if (!_instanceof(res, web.ReadableStream)) return [
|
|
125402
|
+
if (!_instanceof(res, web$1.ReadableStream)) return [
|
|
125868
125403
|
3,
|
|
125869
125404
|
3
|
|
125870
125405
|
];
|
|
@@ -125925,7 +125460,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125925
125460
|
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
125461
|
var _this = this;
|
|
125927
125462
|
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,
|
|
125463
|
+
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
125464
|
return _ts_generator(this, function(_state) {
|
|
125930
125465
|
switch(_state.label){
|
|
125931
125466
|
case 0:
|
|
@@ -125997,7 +125532,9 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
125997
125532
|
];
|
|
125998
125533
|
return [
|
|
125999
125534
|
4,
|
|
126000
|
-
|
|
125535
|
+
{
|
|
125536
|
+
thought: result.thought
|
|
125537
|
+
}
|
|
126001
125538
|
];
|
|
126002
125539
|
case 5:
|
|
126003
125540
|
_state.sent();
|
|
@@ -126061,10 +125598,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126061
125598
|
3,
|
|
126062
125599
|
15
|
|
126063
125600
|
];
|
|
126064
|
-
_this.values
|
|
125601
|
+
_this.values.thought = (_this_values_thought = _this.values.thought) !== null && _this_values_thought !== void 0 ? _this_values_thought : "" + result.thought;
|
|
126065
125602
|
return [
|
|
126066
125603
|
4,
|
|
126067
|
-
|
|
125604
|
+
{
|
|
125605
|
+
thought: result.thought
|
|
125606
|
+
}
|
|
126068
125607
|
];
|
|
126069
125608
|
case 14:
|
|
126070
125609
|
_state.sent();
|
|
@@ -126193,14 +125732,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126193
125732
|
_state.sent();
|
|
126194
125733
|
_state.label = 34;
|
|
126195
125734
|
case 34:
|
|
126196
|
-
if (ai.getOptions().debug) {
|
|
126197
|
-
logger = ai.getLogger();
|
|
126198
|
-
logger("", {
|
|
126199
|
-
tags: [
|
|
126200
|
-
"responseEnd"
|
|
126201
|
-
]
|
|
126202
|
-
});
|
|
126203
|
-
}
|
|
126204
125735
|
return [
|
|
126205
125736
|
2
|
|
126206
125737
|
];
|
|
@@ -126278,7 +125809,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126278
125809
|
8
|
|
126279
125810
|
];
|
|
126280
125811
|
if (result.thought && result.thought.length > 0) {
|
|
126281
|
-
_this.values
|
|
125812
|
+
_this.values.thought = result.thought;
|
|
126282
125813
|
}
|
|
126283
125814
|
extractValues(_this.signature, _this.values, result.content);
|
|
126284
125815
|
return [
|
|
@@ -126372,7 +125903,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126372
125903
|
value: function _forward2(ai, values, options, span, traceContext) {
|
|
126373
125904
|
var _this = this;
|
|
126374
125905
|
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,
|
|
125906
|
+
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
125907
|
return _ts_generator(this, function(_state) {
|
|
126377
125908
|
switch(_state.label){
|
|
126378
125909
|
case 0:
|
|
@@ -126382,7 +125913,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126382
125913
|
switch(_state.label){
|
|
126383
125914
|
case 0:
|
|
126384
125915
|
_loop = function(errCount) {
|
|
126385
|
-
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue,
|
|
125916
|
+
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue, e, errorFields, _errorFields_map_join, e1, _errorFields_map_join1;
|
|
126386
125917
|
return _ts_generator(this, function(_state) {
|
|
126387
125918
|
switch(_state.label){
|
|
126388
125919
|
case 0:
|
|
@@ -126500,12 +126031,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126500
126031
|
];
|
|
126501
126032
|
}
|
|
126502
126033
|
if (debug) {
|
|
126503
|
-
|
|
126504
|
-
logger("", {
|
|
126505
|
-
tags: [
|
|
126506
|
-
"responseEnd"
|
|
126507
|
-
]
|
|
126508
|
-
});
|
|
126034
|
+
process.stdout.write("\n");
|
|
126509
126035
|
}
|
|
126510
126036
|
return [
|
|
126511
126037
|
2,
|
|
@@ -126607,25 +126133,13 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126607
126133
|
};
|
|
126608
126134
|
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
126135
|
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
|
-
});
|
|
126136
|
+
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;
|
|
126137
|
+
_this.promptTemplate = new promptTemplate(_this.signature, options.functions);
|
|
126628
126138
|
}
|
|
126139
|
+
prompt = _this.promptTemplate.render(values, {
|
|
126140
|
+
examples: _this.examples,
|
|
126141
|
+
demos: _this.demos
|
|
126142
|
+
});
|
|
126629
126143
|
mem.add(prompt, options === null || options === void 0 ? void 0 : options.sessionId);
|
|
126630
126144
|
n = 0;
|
|
126631
126145
|
_state.label = 1;
|
|
@@ -126726,8 +126240,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126726
126240
|
model: options.model
|
|
126727
126241
|
} : {}, (options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) ? {
|
|
126728
126242
|
thinking_token_budget: options.thinkingTokenBudget
|
|
126729
|
-
} : {}, (options === null || options === void 0 ? void 0 : options.showThoughts) ? {
|
|
126730
|
-
show_thoughts: options.showThoughts
|
|
126731
126243
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxSteps) ? {
|
|
126732
126244
|
max_steps: options.maxSteps
|
|
126733
126245
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxRetries) ? {
|
|
@@ -126915,12 +126427,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
126915
126427
|
});
|
|
126916
126428
|
})();
|
|
126917
126429
|
}
|
|
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
126430
|
}
|
|
126925
126431
|
]);
|
|
126926
126432
|
return AxGen;
|
|
@@ -126976,32 +126482,13 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
|
|
|
126976
126482
|
var originalFunc = processedFunction.func;
|
|
126977
126483
|
processedFunction.func = function() {
|
|
126978
126484
|
var _ref = _async_to_generator(function(childArgs, funcOptions) {
|
|
126979
|
-
var
|
|
126485
|
+
var updatedChildArgs;
|
|
126980
126486
|
return _ts_generator(this, function(_state) {
|
|
126981
126487
|
switch(_state.label){
|
|
126982
126488
|
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);
|
|
126489
|
+
updatedChildArgs = _object_spread({}, childArgs, pick(parentValues, injectionKeys));
|
|
126995
126490
|
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
|
-
}
|
|
126491
|
+
process.stdout.write("\nFunction Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)));
|
|
127005
126492
|
}
|
|
127006
126493
|
return [
|
|
127007
126494
|
4,
|
|
@@ -127100,8 +126587,8 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127100
126587
|
_create_class(AxAgent, [
|
|
127101
126588
|
{
|
|
127102
126589
|
key: "setExamples",
|
|
127103
|
-
value: function setExamples(examples
|
|
127104
|
-
this.program.setExamples(examples
|
|
126590
|
+
value: function setExamples(examples) {
|
|
126591
|
+
this.program.setExamples(examples);
|
|
127105
126592
|
}
|
|
127106
126593
|
},
|
|
127107
126594
|
{
|
|
@@ -127147,7 +126634,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127147
126634
|
var _this = this;
|
|
127148
126635
|
var wrappedFunc = function() {
|
|
127149
126636
|
var _ref = _async_to_generator(function(valuesAndModel, options) {
|
|
127150
|
-
var model, values, _this_ai, ai, debug,
|
|
126637
|
+
var model, values, _this_ai, ai, debug, ret, sig, outFields, result;
|
|
127151
126638
|
return _ts_generator(this, function(_state) {
|
|
127152
126639
|
switch(_state.label){
|
|
127153
126640
|
case 0:
|
|
@@ -127160,12 +126647,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127160
126647
|
}
|
|
127161
126648
|
debug = _this.getDebug(ai, options);
|
|
127162
126649
|
if (debug) {
|
|
127163
|
-
|
|
127164
|
-
logger("\uD83E\uDD16 Agent ".concat(_this.name, " starting..."), {
|
|
127165
|
-
tags: [
|
|
127166
|
-
"assistantStart"
|
|
127167
|
-
]
|
|
127168
|
-
});
|
|
126650
|
+
process.stdout.write("\n--- Agent Engaged: ".concat(_this.name, " ---\n"));
|
|
127169
126651
|
}
|
|
127170
126652
|
return [
|
|
127171
126653
|
4,
|
|
@@ -127176,12 +126658,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
127176
126658
|
case 1:
|
|
127177
126659
|
ret = _state.sent();
|
|
127178
126660
|
if (debug) {
|
|
127179
|
-
|
|
127180
|
-
logger1("\uD83E\uDD16 Agent ".concat(_this.name, " completed."), {
|
|
127181
|
-
tags: [
|
|
127182
|
-
"assistantEnd"
|
|
127183
|
-
]
|
|
127184
|
-
});
|
|
126661
|
+
process.stdout.write("\n--- Agent Done: ".concat(_this.name, " ---\n"));
|
|
127185
126662
|
}
|
|
127186
126663
|
sig = _this.program.getSignature();
|
|
127187
126664
|
outFields = sig.getOutputFields();
|
|
@@ -127747,12 +127224,6 @@ function pick(obj, keys) {
|
|
|
127747
127224
|
value: function getOptions() {
|
|
127748
127225
|
return this.currentService.getOptions();
|
|
127749
127226
|
}
|
|
127750
|
-
},
|
|
127751
|
-
{
|
|
127752
|
-
key: "getLogger",
|
|
127753
|
-
value: function getLogger() {
|
|
127754
|
-
return this.currentService.getLogger();
|
|
127755
|
-
}
|
|
127756
127227
|
}
|
|
127757
127228
|
]);
|
|
127758
127229
|
return _AxBalancer;
|
|
@@ -127866,8 +127337,7 @@ var AxChainOfThought = /*#__PURE__*/ function(AxGen) {
|
|
|
127866
127337
|
sig.setOutputFields([
|
|
127867
127338
|
{
|
|
127868
127339
|
name: "reason",
|
|
127869
|
-
description: description
|
|
127870
|
-
isInternal: (options === null || options === void 0 ? void 0 : options.setVisibleReasoning) !== true
|
|
127340
|
+
description: description
|
|
127871
127341
|
}
|
|
127872
127342
|
].concat(_to_consumable_array(sig.getOutputFields())));
|
|
127873
127343
|
return _super.call(this, sig, options);
|
|
@@ -127882,8 +127352,10 @@ for(var i = 0; i < 256; ++i){
|
|
|
127882
127352
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
127883
127353
|
}
|
|
127884
127354
|
({
|
|
127885
|
-
randomUUID:
|
|
127355
|
+
randomUUID: require$$0__default$5["default"].randomUUID
|
|
127886
127356
|
});
|
|
127357
|
+
// mcp/client.ts
|
|
127358
|
+
new ColorLog();
|
|
127887
127359
|
|
|
127888
127360
|
let DspService = class DspService {
|
|
127889
127361
|
async prepareFunctions(functions, context) {
|