@digipair/skill-dsp 0.88.3 → 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.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TransformStream, ReadableStream, TextDecoderStream } from 'stream/web';
|
|
1
|
+
import { TransformStream, ReadableStream as ReadableStream$1, TextDecoderStream } from 'stream/web';
|
|
3
2
|
import require$$2$3 from 'child_process';
|
|
4
3
|
import require$$0$4 from 'fs';
|
|
5
4
|
import require$$1$2 from 'https';
|
|
@@ -19,11 +18,18 @@ import require$$0$5 from 'node:events';
|
|
|
19
18
|
import require$$1$6 from 'node:process';
|
|
20
19
|
import require$$2$2 from 'node:util';
|
|
21
20
|
import require$$3 from 'path';
|
|
22
|
-
import require$$0$6 from '
|
|
23
|
-
import require$$0$7 from '
|
|
24
|
-
import '
|
|
25
|
-
import '
|
|
26
|
-
import '
|
|
21
|
+
import require$$0$6, { createHash } from 'crypto';
|
|
22
|
+
import require$$0$7 from 'buffer';
|
|
23
|
+
import require$$0$8 from 'events';
|
|
24
|
+
import { ReadableStream } from 'node:stream/web';
|
|
25
|
+
import 'node:fs';
|
|
26
|
+
import 'node:crypto';
|
|
27
|
+
import 'node:http';
|
|
28
|
+
import 'node:https';
|
|
29
|
+
import 'node:os';
|
|
30
|
+
import 'node:vm';
|
|
31
|
+
import 'node:child_process';
|
|
32
|
+
import 'node:readline';
|
|
27
33
|
|
|
28
34
|
function _extends() {
|
|
29
35
|
_extends = Object.assign || function assign(target) {
|
|
@@ -23945,14 +23951,14 @@ function indent(str, spaces) {
|
|
|
23945
23951
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
23946
23952
|
// match is required
|
|
23947
23953
|
if (!match) {
|
|
23948
|
-
return
|
|
23954
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
|
|
23949
23955
|
v: nextMatch1
|
|
23950
23956
|
};
|
|
23951
23957
|
}
|
|
23952
23958
|
var token = match.token, offset = match.offset;
|
|
23953
23959
|
i1 += offset;
|
|
23954
23960
|
if (token === " ") {
|
|
23955
|
-
return
|
|
23961
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23956
23962
|
}
|
|
23957
23963
|
tokens1 = _to_consumable_array$5(tokens1).concat([
|
|
23958
23964
|
token
|
|
@@ -23971,7 +23977,7 @@ function indent(str, spaces) {
|
|
|
23971
23977
|
if (contextKeys.some(function(el) {
|
|
23972
23978
|
return el.startsWith(name);
|
|
23973
23979
|
})) {
|
|
23974
|
-
return
|
|
23980
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23975
23981
|
}
|
|
23976
23982
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23977
23983
|
return el === name;
|
|
@@ -23990,9 +23996,9 @@ function indent(str, spaces) {
|
|
|
23990
23996
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23991
23997
|
return el.startsWith(name);
|
|
23992
23998
|
})) {
|
|
23993
|
-
return
|
|
23999
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
|
|
23994
24000
|
}
|
|
23995
|
-
return
|
|
24001
|
+
return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
|
|
23996
24002
|
v: nextMatch1
|
|
23997
24003
|
};
|
|
23998
24004
|
};
|
|
@@ -120848,7 +120854,7 @@ Object.defineProperty(crypto$3, "__esModule", {
|
|
|
120848
120854
|
value: true
|
|
120849
120855
|
});
|
|
120850
120856
|
crypto$3.NodeCrypto = void 0;
|
|
120851
|
-
var crypto$2 =
|
|
120857
|
+
var crypto$2 = require$$0$6;
|
|
120852
120858
|
var NodeCrypto = /*#__PURE__*/ function() {
|
|
120853
120859
|
function NodeCrypto() {
|
|
120854
120860
|
_class_call_check$r(this, NodeCrypto);
|
|
@@ -121347,7 +121353,7 @@ var safeBuffer = {
|
|
|
121347
121353
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
121348
121354
|
|
|
121349
121355
|
(function (module, exports) {
|
|
121350
|
-
/* eslint-disable node/no-deprecated-api */ var buffer = require$$0$
|
|
121356
|
+
/* eslint-disable node/no-deprecated-api */ var buffer = require$$0$7;
|
|
121351
121357
|
var Buffer = buffer.Buffer;
|
|
121352
121358
|
// alternative to using Object.keys for old browsers
|
|
121353
121359
|
function copyProps(src, dst) {
|
|
@@ -121821,7 +121827,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
121821
121827
|
value: true
|
|
121822
121828
|
});
|
|
121823
121829
|
exports.AuthClient = exports.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS = exports.DEFAULT_UNIVERSE = void 0;
|
|
121824
|
-
var events_1 = require$$0$
|
|
121830
|
+
var events_1 = require$$0$8;
|
|
121825
121831
|
var gaxios_1 = src$3;
|
|
121826
121832
|
var transporters_1 = transporters;
|
|
121827
121833
|
var util_1 = util$4;
|
|
@@ -124648,8 +124654,8 @@ DataStream$2.prototype.end = function end(data) {
|
|
|
124648
124654
|
var dataStream = DataStream$2;
|
|
124649
124655
|
|
|
124650
124656
|
/*jshint node:true */
|
|
124651
|
-
var Buffer$5 = require$$0$
|
|
124652
|
-
var SlowBuffer = require$$0$
|
|
124657
|
+
var Buffer$5 = require$$0$7.Buffer; // browserify
|
|
124658
|
+
var SlowBuffer = require$$0$7.SlowBuffer;
|
|
124653
124659
|
var bufferEqualConstantTime = bufferEq;
|
|
124654
124660
|
function bufferEq(a, b) {
|
|
124655
124661
|
// shortcutting on type is necessary for correctness
|
|
@@ -124682,7 +124688,7 @@ bufferEq.restore = function() {
|
|
|
124682
124688
|
|
|
124683
124689
|
var bufferEqual = bufferEqualConstantTime;
|
|
124684
124690
|
var Buffer$4 = safeBuffer.exports.Buffer;
|
|
124685
|
-
var crypto$1 =
|
|
124691
|
+
var crypto$1 = require$$0$6;
|
|
124686
124692
|
var formatEcdsa = ecdsaSigFormatter;
|
|
124687
124693
|
var util$2 = require$$5;
|
|
124688
124694
|
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".';
|
|
@@ -124890,7 +124896,7 @@ var jwa$2 = function jwa(algorithm) {
|
|
|
124890
124896
|
|
|
124891
124897
|
/*global module*/
|
|
124892
124898
|
|
|
124893
|
-
var Buffer$3 = require$$0$
|
|
124899
|
+
var Buffer$3 = require$$0$7.Buffer;
|
|
124894
124900
|
var tostring = function toString(obj) {
|
|
124895
124901
|
if (typeof obj === "string") return obj;
|
|
124896
124902
|
if (typeof obj === "number" || Buffer$3.isBuffer(obj)) return obj.toString();
|
|
@@ -143467,7 +143473,7 @@ var AxAIServiceError = (_Symbol_for = Symbol.for("nodejs.util.inspect.custom"),
|
|
|
143467
143473
|
_this.responseBody = responseBody;
|
|
143468
143474
|
_this.name = _this.constructor.name;
|
|
143469
143475
|
_this.timestamp = /* @__PURE__ */ new Date().toISOString();
|
|
143470
|
-
_this.errorId = crypto
|
|
143476
|
+
_this.errorId = crypto.randomUUID();
|
|
143471
143477
|
_this.context = context3;
|
|
143472
143478
|
_this.stack = _this.toString();
|
|
143473
143479
|
return _this;
|
|
@@ -143565,7 +143571,7 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
|
143565
143571
|
function AxAIServiceTimeoutError(url, timeoutMs, requestBody, context3) {
|
|
143566
143572
|
_class_call_check(this, AxAIServiceTimeoutError);
|
|
143567
143573
|
var _this;
|
|
143568
|
-
_this = _super.call(this, "Request
|
|
143574
|
+
_this = _super.call(this, "Request timeout after ".concat(timeoutMs, "ms"), url, requestBody, void 0, _object_spread({
|
|
143569
143575
|
timeoutMs: timeoutMs
|
|
143570
143576
|
}, context3));
|
|
143571
143577
|
_this.name = _this.constructor.name;
|
|
@@ -143573,20 +143579,6 @@ var AxAIServiceTimeoutError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
|
143573
143579
|
}
|
|
143574
143580
|
return AxAIServiceTimeoutError;
|
|
143575
143581
|
}(AxAIServiceError);
|
|
143576
|
-
var AxAIServiceAbortedError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
143577
|
-
_inherits(AxAIServiceAbortedError, AxAIServiceError);
|
|
143578
|
-
var _super = _create_super(AxAIServiceAbortedError);
|
|
143579
|
-
function AxAIServiceAbortedError(url, reason, requestBody, context3) {
|
|
143580
|
-
_class_call_check(this, AxAIServiceAbortedError);
|
|
143581
|
-
var _this;
|
|
143582
|
-
_this = _super.call(this, "Request aborted".concat(reason ? ": ".concat(reason) : ""), url, requestBody, void 0, _object_spread({
|
|
143583
|
-
abortReason: reason
|
|
143584
|
-
}, context3));
|
|
143585
|
-
_this.name = _this.constructor.name;
|
|
143586
|
-
return _this;
|
|
143587
|
-
}
|
|
143588
|
-
return AxAIServiceAbortedError;
|
|
143589
|
-
}(AxAIServiceError);
|
|
143590
143582
|
var AxAIServiceAuthenticationError = /*#__PURE__*/ function(AxAIServiceError) {
|
|
143591
143583
|
_inherits(AxAIServiceAuthenticationError, AxAIServiceError);
|
|
143592
143584
|
var _super = _create_super(AxAIServiceAuthenticationError);
|
|
@@ -143625,31 +143617,13 @@ var apiCall = function() {
|
|
|
143625
143617
|
switch(_state.label){
|
|
143626
143618
|
case 0:
|
|
143627
143619
|
_loop = function() {
|
|
143628
|
-
var
|
|
143620
|
+
var controller, _api_fetch, res, _api_span, delay, _api_span1, resJson, isValid, lastChunk, chunkCount, trackingStream, closed, error, _api_span2, _api_span3, delay1;
|
|
143629
143621
|
return _ts_generator(this, function(_state) {
|
|
143630
143622
|
switch(_state.label){
|
|
143631
143623
|
case 0:
|
|
143632
|
-
|
|
143633
|
-
if (api.abortSignal) {
|
|
143634
|
-
if (api.abortSignal.aborted) {
|
|
143635
|
-
throw new AxAIServiceAbortedError(apiUrl.href, api.abortSignal.reason, json, {
|
|
143636
|
-
metrics: metrics
|
|
143637
|
-
});
|
|
143638
|
-
}
|
|
143639
|
-
userAbortHandler = function() {
|
|
143640
|
-
combinedAbortController.abort(api.abortSignal.reason || "User aborted request");
|
|
143641
|
-
};
|
|
143642
|
-
api.abortSignal.addEventListener("abort", userAbortHandler, {
|
|
143643
|
-
once: true
|
|
143644
|
-
});
|
|
143645
|
-
originalAbort = combinedAbortController.abort.bind(combinedAbortController);
|
|
143646
|
-
combinedAbortController.abort = function(reason) {
|
|
143647
|
-
api.abortSignal.removeEventListener("abort", userAbortHandler);
|
|
143648
|
-
originalAbort(reason);
|
|
143649
|
-
};
|
|
143650
|
-
}
|
|
143624
|
+
controller = new AbortController();
|
|
143651
143625
|
timeoutId = setTimeout(function() {
|
|
143652
|
-
|
|
143626
|
+
controller.abort("Request timeout");
|
|
143653
143627
|
}, timeoutMs);
|
|
143654
143628
|
_state.label = 1;
|
|
143655
143629
|
case 1:
|
|
@@ -143669,7 +143643,7 @@ var apiCall = function() {
|
|
|
143669
143643
|
"X-Retry-Count": attempt.toString()
|
|
143670
143644
|
}, api.headers),
|
|
143671
143645
|
body: JSON.stringify(json),
|
|
143672
|
-
signal:
|
|
143646
|
+
signal: controller.signal
|
|
143673
143647
|
})
|
|
143674
143648
|
];
|
|
143675
143649
|
case 2:
|
|
@@ -143759,13 +143733,13 @@ var apiCall = function() {
|
|
|
143759
143733
|
lastChunk = void 0;
|
|
143760
143734
|
chunkCount = 0;
|
|
143761
143735
|
trackingStream = new TransformStream({
|
|
143762
|
-
transform: function transform(chunk,
|
|
143736
|
+
transform: function transform(chunk, controller2) {
|
|
143763
143737
|
var _api_span;
|
|
143764
143738
|
lastChunk = chunk;
|
|
143765
143739
|
chunkCount++;
|
|
143766
143740
|
metrics.streamChunks = chunkCount;
|
|
143767
143741
|
metrics.lastChunkTime = Date.now();
|
|
143768
|
-
|
|
143742
|
+
controller2.enqueue(chunk);
|
|
143769
143743
|
(_api_span = api.span) === null || _api_span === void 0 ? void 0 : _api_span.addEvent("stream.chunk", {
|
|
143770
143744
|
"stream.chunks": chunkCount,
|
|
143771
143745
|
"stream.duration": Date.now() - metrics.startTime,
|
|
@@ -143777,8 +143751,8 @@ var apiCall = function() {
|
|
|
143777
143751
|
return [
|
|
143778
143752
|
2,
|
|
143779
143753
|
{
|
|
143780
|
-
v: new ReadableStream({
|
|
143781
|
-
start: function start(
|
|
143754
|
+
v: new ReadableStream$1({
|
|
143755
|
+
start: function start(controller2) {
|
|
143782
143756
|
var reader = res.body.pipeThrough(new textDecoderStream()).pipeThrough(new SSEParser()).pipeThrough(trackingStream).getReader();
|
|
143783
143757
|
function read() {
|
|
143784
143758
|
return _read.apply(this, arguments);
|
|
@@ -143806,7 +143780,7 @@ var apiCall = function() {
|
|
|
143806
143780
|
if (done) {
|
|
143807
143781
|
if (!closed) {
|
|
143808
143782
|
closed = true;
|
|
143809
|
-
|
|
143783
|
+
controller2.close();
|
|
143810
143784
|
}
|
|
143811
143785
|
return [
|
|
143812
143786
|
3,
|
|
@@ -143817,7 +143791,7 @@ var apiCall = function() {
|
|
|
143817
143791
|
3,
|
|
143818
143792
|
3
|
|
143819
143793
|
];
|
|
143820
|
-
|
|
143794
|
+
controller2.enqueue(value);
|
|
143821
143795
|
return [
|
|
143822
143796
|
3,
|
|
143823
143797
|
1
|
|
@@ -143834,16 +143808,16 @@ var apiCall = function() {
|
|
|
143834
143808
|
streamDuration: Date.now() - metrics.startTime
|
|
143835
143809
|
});
|
|
143836
143810
|
if (_$error.name === "AbortError" || ((_error_message = _$error.message) === null || _error_message === void 0 ? void 0 : _error_message.includes("aborted"))) {
|
|
143837
|
-
|
|
143811
|
+
controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
|
|
143838
143812
|
streamMetrics: streamMetrics
|
|
143839
143813
|
}));
|
|
143840
143814
|
} else if (_instanceof(_$error, TypeError) && _$error.message.includes("cancelled")) {
|
|
143841
|
-
|
|
143815
|
+
controller2.error(new AxAIServiceStreamTerminatedError(apiUrl.href, json, lastChunk, {
|
|
143842
143816
|
streamMetrics: streamMetrics,
|
|
143843
143817
|
cancelReason: "Stream cancelled by client"
|
|
143844
143818
|
}));
|
|
143845
143819
|
} else {
|
|
143846
|
-
|
|
143820
|
+
controller2.error(new AxAIServiceNetworkError(_$error, apiUrl.href, json, res.body, {
|
|
143847
143821
|
streamMetrics: streamMetrics
|
|
143848
143822
|
}));
|
|
143849
143823
|
}
|
|
@@ -143875,15 +143849,9 @@ var apiCall = function() {
|
|
|
143875
143849
|
case 9:
|
|
143876
143850
|
error = _state.sent();
|
|
143877
143851
|
if (_instanceof(error, Error) && error.name === "AbortError") {
|
|
143878
|
-
|
|
143879
|
-
|
|
143880
|
-
|
|
143881
|
-
});
|
|
143882
|
-
} else {
|
|
143883
|
-
throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
|
|
143884
|
-
metrics: metrics
|
|
143885
|
-
});
|
|
143886
|
-
}
|
|
143852
|
+
throw new AxAIServiceTimeoutError(apiUrl.href, timeoutMs, json, {
|
|
143853
|
+
metrics: metrics
|
|
143854
|
+
});
|
|
143887
143855
|
}
|
|
143888
143856
|
if ((_api_span2 = api.span) === null || _api_span2 === void 0 ? void 0 : _api_span2.isRecording()) {
|
|
143889
143857
|
api.span.recordException(error);
|
|
@@ -143947,7 +143915,7 @@ var apiCall = function() {
|
|
|
143947
143915
|
api.name
|
|
143948
143916
|
].filter(Boolean).join("/").replace(/\/+/g, "/")).concat(baseUrl.search);
|
|
143949
143917
|
apiUrl = new URL(apiPath, baseUrl);
|
|
143950
|
-
requestId = crypto
|
|
143918
|
+
requestId = crypto.randomUUID();
|
|
143951
143919
|
if (!api.validateRequest) return [
|
|
143952
143920
|
3,
|
|
143953
143921
|
2
|
|
@@ -144121,66 +144089,31 @@ var ColorLog = /*#__PURE__*/ function() {
|
|
|
144121
144089
|
}();
|
|
144122
144090
|
// ai/debug.ts
|
|
144123
144091
|
var colorLog = new ColorLog();
|
|
144124
|
-
var defaultOutput = function(message) {
|
|
144125
|
-
process.stdout.write(message);
|
|
144126
|
-
};
|
|
144127
|
-
var createDefaultLogger = function() {
|
|
144128
|
-
var output = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultOutput;
|
|
144129
|
-
return function(message, options) {
|
|
144130
|
-
var _options_tags;
|
|
144131
|
-
var tags = (_options_tags = options === null || options === void 0 ? void 0 : options.tags) !== null && _options_tags !== void 0 ? _options_tags : [];
|
|
144132
|
-
var formattedMessage = message;
|
|
144133
|
-
if (tags.includes("error")) {
|
|
144134
|
-
formattedMessage = colorLog.red(formattedMessage);
|
|
144135
|
-
} else if (tags.includes("success") || tags.includes("responseContent")) {
|
|
144136
|
-
formattedMessage = colorLog.greenBright(formattedMessage);
|
|
144137
|
-
} else if (tags.includes("functionName")) {
|
|
144138
|
-
formattedMessage = colorLog.whiteBright(formattedMessage);
|
|
144139
|
-
} else if (tags.includes("functionArg") || tags.includes("systemContent") || tags.includes("assistantContent")) {
|
|
144140
|
-
formattedMessage = colorLog.blueBright(formattedMessage);
|
|
144141
|
-
} else if (tags.includes("warning") || tags.includes("discovery")) {
|
|
144142
|
-
formattedMessage = colorLog.yellow(formattedMessage);
|
|
144143
|
-
}
|
|
144144
|
-
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart")) {
|
|
144145
|
-
formattedMessage = "\n".concat(formattedMessage);
|
|
144146
|
-
} else if (tags.includes("responseEnd") || tags.includes("systemEnd") || tags.includes("userEnd")) {
|
|
144147
|
-
formattedMessage = "".concat(formattedMessage, "\n");
|
|
144148
|
-
} else if (tags.includes("assistantStart")) {
|
|
144149
|
-
formattedMessage = "\n".concat(formattedMessage, "\n");
|
|
144150
|
-
} else if (tags.includes("error")) {
|
|
144151
|
-
formattedMessage = "\n".concat(formattedMessage, "\n");
|
|
144152
|
-
} else if (tags.includes("functionEnd")) {
|
|
144153
|
-
formattedMessage = "".concat(formattedMessage, "\n");
|
|
144154
|
-
}
|
|
144155
|
-
output(formattedMessage);
|
|
144156
|
-
};
|
|
144157
|
-
};
|
|
144158
|
-
var defaultLogger = createDefaultLogger();
|
|
144159
144092
|
var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
|
|
144160
144093
|
switch(msg.role){
|
|
144161
144094
|
case "system":
|
|
144162
144095
|
if (hideSystemPrompt) {
|
|
144163
144096
|
return "";
|
|
144164
144097
|
}
|
|
144165
|
-
return "\
|
|
144098
|
+
return "\n".concat(colorLog.blueBright("System:"), "\n").concat(colorLog.whiteBright(msg.content));
|
|
144166
144099
|
case "function":
|
|
144167
|
-
return "\
|
|
144100
|
+
return "\n".concat(colorLog.blueBright("Function Result:"), "\n").concat(colorLog.whiteBright(msg.result));
|
|
144168
144101
|
case "user":
|
|
144169
144102
|
{
|
|
144170
144103
|
if (typeof msg.content === "string") {
|
|
144171
|
-
return "\
|
|
144104
|
+
return "\n".concat(colorLog.blueBright("User:"), "\n").concat(colorLog.whiteBright(msg.content));
|
|
144172
144105
|
}
|
|
144173
144106
|
var items = msg.content.map(function(v) {
|
|
144174
144107
|
switch(v.type){
|
|
144175
144108
|
case "text":
|
|
144176
|
-
return v.text;
|
|
144109
|
+
return "".concat(colorLog.whiteBright(v.text));
|
|
144177
144110
|
case "image":
|
|
144178
|
-
return "(Image, ".concat(v.mimeType, ") ").concat(v.image.substring(0, 10));
|
|
144111
|
+
return "(Image, ".concat(v.mimeType, ") ").concat(colorLog.whiteBright(v.image.substring(0, 10)));
|
|
144179
144112
|
default:
|
|
144180
144113
|
throw new Error("Invalid content type");
|
|
144181
144114
|
}
|
|
144182
144115
|
});
|
|
144183
|
-
return "\
|
|
144116
|
+
return "\n".concat(colorLog.blueBright("User:"), "\n").concat(items.join("\n"));
|
|
144184
144117
|
}
|
|
144185
144118
|
case "assistant":
|
|
144186
144119
|
{
|
|
@@ -144191,106 +144124,46 @@ var formatChatMessage = function(msg, hideContent, hideSystemPrompt) {
|
|
|
144191
144124
|
var args = typeof fn.params !== "string" ? JSON.stringify(fn.params, null, 2) : fn.params;
|
|
144192
144125
|
return "".concat(fn.name, "(").concat(args, ")");
|
|
144193
144126
|
});
|
|
144194
|
-
return "\nFunctions
|
|
144127
|
+
return "\n".concat(colorLog.blueBright("\nFunctions:"), "\n").concat(colorLog.whiteBright(fns.join("\n")));
|
|
144195
144128
|
}
|
|
144196
144129
|
var _msg_content;
|
|
144197
|
-
return "\nAssistant
|
|
144130
|
+
return "\n".concat(colorLog.blueBright("\nAssistant:"), "\n").concat(hideContent ? "" : colorLog.whiteBright((_msg_content = msg.content) !== null && _msg_content !== void 0 ? _msg_content : "<empty>"));
|
|
144198
144131
|
}
|
|
144199
144132
|
default:
|
|
144200
144133
|
throw new Error("Invalid role");
|
|
144201
144134
|
}
|
|
144202
144135
|
};
|
|
144203
144136
|
var logChatRequestMessage = function(msg, hideSystemPrompt) {
|
|
144204
|
-
|
|
144205
|
-
|
|
144206
|
-
if (formattedMessage) {
|
|
144207
|
-
var tags = msg.role === "system" ? [
|
|
144208
|
-
"systemStart",
|
|
144209
|
-
"systemContent"
|
|
144210
|
-
] : msg.role === "function" ? [
|
|
144211
|
-
"functionName"
|
|
144212
|
-
] : msg.role === "user" ? [
|
|
144213
|
-
"userStart",
|
|
144214
|
-
"userContent"
|
|
144215
|
-
] : [];
|
|
144216
|
-
logger(formattedMessage, {
|
|
144217
|
-
tags: tags
|
|
144218
|
-
});
|
|
144219
|
-
}
|
|
144220
|
-
logger("Assistant:", {
|
|
144221
|
-
tags: [
|
|
144222
|
-
"assistantStart"
|
|
144223
|
-
]
|
|
144224
|
-
});
|
|
144137
|
+
process.stdout.write("".concat(formatChatMessage(msg, hideSystemPrompt), "\n"));
|
|
144138
|
+
process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
|
|
144225
144139
|
};
|
|
144226
144140
|
var logChatRequest = function(chatPrompt, hideSystemPrompt) {
|
|
144227
|
-
var
|
|
144228
|
-
|
|
144229
|
-
try {
|
|
144230
|
-
for(var _iterator = (chatPrompt !== null && chatPrompt !== void 0 ? chatPrompt : [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
144231
|
-
var msg = _step.value;
|
|
144232
|
-
var formattedMessage = formatChatMessage(msg, false, hideSystemPrompt);
|
|
144233
|
-
if (formattedMessage) {
|
|
144234
|
-
var tags = msg.role === "system" ? [
|
|
144235
|
-
"systemContent"
|
|
144236
|
-
] : msg.role === "function" ? [
|
|
144237
|
-
"functionName"
|
|
144238
|
-
] : msg.role === "user" ? [
|
|
144239
|
-
"userContent"
|
|
144240
|
-
] : [];
|
|
144241
|
-
logger(formattedMessage, {
|
|
144242
|
-
tags: tags
|
|
144243
|
-
});
|
|
144244
|
-
}
|
|
144245
|
-
}
|
|
144246
|
-
} catch (err) {
|
|
144247
|
-
_didIteratorError = true;
|
|
144248
|
-
_iteratorError = err;
|
|
144249
|
-
} finally{
|
|
144250
|
-
try {
|
|
144251
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
144252
|
-
_iterator.return();
|
|
144253
|
-
}
|
|
144254
|
-
} finally{
|
|
144255
|
-
if (_didIteratorError) {
|
|
144256
|
-
throw _iteratorError;
|
|
144257
|
-
}
|
|
144258
|
-
}
|
|
144259
|
-
}
|
|
144260
|
-
logger("Assistant:", {
|
|
144261
|
-
tags: [
|
|
144262
|
-
"assistantStart"
|
|
144263
|
-
]
|
|
144141
|
+
var items = chatPrompt === null || chatPrompt === void 0 ? void 0 : chatPrompt.map(function(msg) {
|
|
144142
|
+
return formatChatMessage(msg, hideSystemPrompt);
|
|
144264
144143
|
});
|
|
144144
|
+
if (items) {
|
|
144145
|
+
process.stdout.write(items.join("\n"));
|
|
144146
|
+
process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
|
|
144147
|
+
}
|
|
144265
144148
|
};
|
|
144266
144149
|
var logResponseResult = function(r) {
|
|
144267
|
-
var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
|
|
144268
144150
|
if (r.content) {
|
|
144269
|
-
|
|
144270
|
-
tags: [
|
|
144271
|
-
"responseContent"
|
|
144272
|
-
]
|
|
144273
|
-
});
|
|
144151
|
+
process.stdout.write(colorLog.greenBright(r.content));
|
|
144274
144152
|
}
|
|
144275
|
-
if (r.functionCalls
|
|
144153
|
+
if (r.functionCalls) {
|
|
144276
144154
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
144277
144155
|
try {
|
|
144278
144156
|
for(var _iterator = r.functionCalls.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
144279
144157
|
var _step_value = _sliced_to_array(_step.value, 2), i = _step_value[0], f = _step_value[1];
|
|
144280
144158
|
if (f.function.name) {
|
|
144281
|
-
|
|
144282
|
-
|
|
144283
|
-
|
|
144284
|
-
|
|
144285
|
-
});
|
|
144159
|
+
if (i > 0) {
|
|
144160
|
+
process.stdout.write("\n");
|
|
144161
|
+
}
|
|
144162
|
+
process.stdout.write("Function ".concat(i + 1, " -> ").concat(colorLog.greenBright(f.function.name)));
|
|
144286
144163
|
}
|
|
144287
144164
|
if (f.function.params) {
|
|
144288
144165
|
var params = typeof f.function.params === "string" ? f.function.params : JSON.stringify(f.function.params, null, 2);
|
|
144289
|
-
|
|
144290
|
-
tags: [
|
|
144291
|
-
"functionArg"
|
|
144292
|
-
]
|
|
144293
|
-
});
|
|
144166
|
+
process.stdout.write("".concat(colorLog.greenBright(params)));
|
|
144294
144167
|
}
|
|
144295
144168
|
}
|
|
144296
144169
|
} catch (err) {
|
|
@@ -144307,15 +144180,9 @@ var logResponseResult = function(r) {
|
|
|
144307
144180
|
}
|
|
144308
144181
|
}
|
|
144309
144182
|
}
|
|
144310
|
-
logger("", {
|
|
144311
|
-
tags: [
|
|
144312
|
-
"functionEnd"
|
|
144313
|
-
]
|
|
144314
|
-
});
|
|
144315
144183
|
}
|
|
144316
144184
|
};
|
|
144317
144185
|
var logResponse = function(resp) {
|
|
144318
|
-
var logger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogger;
|
|
144319
144186
|
if (!resp.results) {
|
|
144320
144187
|
return;
|
|
144321
144188
|
}
|
|
@@ -144323,7 +144190,7 @@ var logResponse = function(resp) {
|
|
|
144323
144190
|
try {
|
|
144324
144191
|
for(var _iterator = resp.results[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
144325
144192
|
var r = _step.value;
|
|
144326
|
-
logResponseResult(r
|
|
144193
|
+
logResponseResult(r);
|
|
144327
144194
|
}
|
|
144328
144195
|
} catch (err) {
|
|
144329
144196
|
_didIteratorError = true;
|
|
@@ -144341,24 +144208,17 @@ var logResponse = function(resp) {
|
|
|
144341
144208
|
}
|
|
144342
144209
|
};
|
|
144343
144210
|
var logResponseDelta = function(delta) {
|
|
144344
|
-
|
|
144345
|
-
logger(delta, {
|
|
144346
|
-
tags: [
|
|
144347
|
-
"responseContent"
|
|
144348
|
-
]
|
|
144349
|
-
});
|
|
144211
|
+
process.stdout.write(colorLog.greenBright(delta));
|
|
144350
144212
|
};
|
|
144351
144213
|
// ai/base.ts
|
|
144352
144214
|
var axBaseAIDefaultConfig = function() {
|
|
144353
144215
|
return structuredClone({
|
|
144216
|
+
maxTokens: 2e3,
|
|
144354
144217
|
temperature: 0,
|
|
144355
144218
|
topK: 40,
|
|
144356
144219
|
topP: 0.9
|
|
144357
144220
|
});
|
|
144358
144221
|
};
|
|
144359
|
-
var defaultLogger2 = function(message, _options) {
|
|
144360
|
-
process.stdout.write(message);
|
|
144361
|
-
};
|
|
144362
144222
|
var AxBaseAI = /*#__PURE__*/ function() {
|
|
144363
144223
|
function AxBaseAI(aiImpl, param) {
|
|
144364
144224
|
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;
|
|
@@ -144370,8 +144230,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144370
144230
|
_define_property(this, "timeout", void 0);
|
|
144371
144231
|
_define_property(this, "excludeContentFromTrace", void 0);
|
|
144372
144232
|
_define_property(this, "models", void 0);
|
|
144373
|
-
_define_property(this, "abortSignal", void 0);
|
|
144374
|
-
_define_property(this, "logger", defaultLogger2);
|
|
144375
144233
|
_define_property(this, "modelInfo", void 0);
|
|
144376
144234
|
_define_property(this, "modelUsage", void 0);
|
|
144377
144235
|
_define_property(this, "embedModelUsage", void 0);
|
|
@@ -144421,7 +144279,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144421
144279
|
this.tracer = options.tracer;
|
|
144422
144280
|
this.modelInfo = modelInfo;
|
|
144423
144281
|
this.models = models;
|
|
144424
|
-
this.id = crypto
|
|
144282
|
+
this.id = crypto.randomUUID();
|
|
144425
144283
|
var _this_getModel;
|
|
144426
144284
|
var model = (_this_getModel = this.getModel(defaults.model)) !== null && _this_getModel !== void 0 ? _this_getModel : defaults.model;
|
|
144427
144285
|
var _this_getEmbedModel;
|
|
@@ -144473,9 +144331,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144473
144331
|
this.timeout = options.timeout;
|
|
144474
144332
|
this.tracer = options.tracer;
|
|
144475
144333
|
this.excludeContentFromTrace = options.excludeContentFromTrace;
|
|
144476
|
-
this.abortSignal = options.abortSignal;
|
|
144477
|
-
var _options_logger;
|
|
144478
|
-
this.logger = (_options_logger = options.logger) !== null && _options_logger !== void 0 ? _options_logger : defaultLogger2;
|
|
144479
144334
|
}
|
|
144480
144335
|
},
|
|
144481
144336
|
{
|
|
@@ -144487,18 +144342,10 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144487
144342
|
fetch: this.fetch,
|
|
144488
144343
|
tracer: this.tracer,
|
|
144489
144344
|
timeout: this.timeout,
|
|
144490
|
-
excludeContentFromTrace: this.excludeContentFromTrace
|
|
144491
|
-
abortSignal: this.abortSignal,
|
|
144492
|
-
logger: this.logger
|
|
144345
|
+
excludeContentFromTrace: this.excludeContentFromTrace
|
|
144493
144346
|
};
|
|
144494
144347
|
}
|
|
144495
144348
|
},
|
|
144496
|
-
{
|
|
144497
|
-
key: "getLogger",
|
|
144498
|
-
value: function getLogger() {
|
|
144499
|
-
return this.logger;
|
|
144500
|
-
}
|
|
144501
|
-
},
|
|
144502
144349
|
{
|
|
144503
144350
|
key: "getModelList",
|
|
144504
144351
|
value: function getModelList() {
|
|
@@ -144675,7 +144522,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144675
144522
|
value: function _chat1(req, options) {
|
|
144676
144523
|
var _this = this;
|
|
144677
144524
|
return _async_to_generator(function() {
|
|
144678
|
-
var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences,
|
|
144525
|
+
var _this_getModel, _ref, model, modelConfig, _ref1, canStream, _modelConfig_stopSequences, _options_traceContext, _obj;
|
|
144679
144526
|
return _ts_generator(this, function(_state) {
|
|
144680
144527
|
switch(_state.label){
|
|
144681
144528
|
case 0:
|
|
@@ -144684,9 +144531,6 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144684
144531
|
if ((options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) && !_this.getFeatures(model).hasThinkingBudget) {
|
|
144685
144532
|
throw new Error("Model ".concat(model, " does not support thinkingTokenBudget."));
|
|
144686
144533
|
}
|
|
144687
|
-
if ((options === null || options === void 0 ? void 0 : options.showThoughts) && !_this.getFeatures(model).hasShowThoughts) {
|
|
144688
|
-
throw new Error("Model ".concat(model, " does not support showThoughts."));
|
|
144689
|
-
}
|
|
144690
144534
|
modelConfig.stream = (_ref1 = (options === null || options === void 0 ? void 0 : options.stream) !== void 0 ? options.stream : modelConfig.stream) !== null && _ref1 !== void 0 ? _ref1 : true;
|
|
144691
144535
|
canStream = _this.getFeatures(model).streaming;
|
|
144692
144536
|
if (!canStream) {
|
|
@@ -144700,7 +144544,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144700
144544
|
4,
|
|
144701
144545
|
_this.tracer.startActiveSpan("AI Chat Request", {
|
|
144702
144546
|
kind: SpanKind.SERVER,
|
|
144703
|
-
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,
|
|
144547
|
+
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)
|
|
144704
144548
|
}, (_options_traceContext = options === null || options === void 0 ? void 0 : options.traceContext) !== null && _options_traceContext !== void 0 ? _options_traceContext : context.active(), function() {
|
|
144705
144549
|
var _ref = _async_to_generator(function(span) {
|
|
144706
144550
|
return _ts_generator(this, function(_state) {
|
|
@@ -144769,7 +144613,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144769
144613
|
value: function _chat2(model, modelConfig, chatReq, options, span) {
|
|
144770
144614
|
var _this = this;
|
|
144771
144615
|
return _async_to_generator(function() {
|
|
144772
|
-
var _options_debug, debug, functions, req, fn,
|
|
144616
|
+
var _options_debug, debug, functions, req, fn, _options_rateLimiter, rt, rv, _tmp, respFn, wrappedRespFn, doneCb, st, res, tokenUsage;
|
|
144773
144617
|
return _ts_generator(this, function(_state) {
|
|
144774
144618
|
switch(_state.label){
|
|
144775
144619
|
case 0:
|
|
@@ -144791,7 +144635,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144791
144635
|
_this.lastUsedModelConfig = modelConfig;
|
|
144792
144636
|
fn = function() {
|
|
144793
144637
|
var _ref = _async_to_generator(function() {
|
|
144794
|
-
var _this_aiImpl_createChatReq, apiConfig, reqValue,
|
|
144638
|
+
var _this_aiImpl_createChatReq, apiConfig, reqValue, res2, _tmp;
|
|
144795
144639
|
return _ts_generator(this, function(_state) {
|
|
144796
144640
|
switch(_state.label){
|
|
144797
144641
|
case 0:
|
|
@@ -144811,7 +144655,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144811
144655
|
return [
|
|
144812
144656
|
4,
|
|
144813
144657
|
apiCall.apply(void 0, [
|
|
144814
|
-
(_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp
|
|
144658
|
+
(_tmp.headers = _state.sent(), _tmp.stream = modelConfig.stream, _tmp.timeout = _this.timeout, _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.span = span, _tmp),
|
|
144815
144659
|
reqValue
|
|
144816
144660
|
])
|
|
144817
144661
|
];
|
|
@@ -144829,7 +144673,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144829
144673
|
};
|
|
144830
144674
|
}();
|
|
144831
144675
|
if (debug) {
|
|
144832
|
-
logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt
|
|
144676
|
+
logChatRequest(req.chatPrompt, options === null || options === void 0 ? void 0 : options.debugHideSystemPrompt);
|
|
144833
144677
|
}
|
|
144834
144678
|
rt = (_options_rateLimiter = options === null || options === void 0 ? void 0 : options.rateLimiter) !== null && _options_rateLimiter !== void 0 ? _options_rateLimiter : _this.rt;
|
|
144835
144679
|
if (!rt) return [
|
|
@@ -144867,6 +144711,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144867
144711
|
return function(resp) {
|
|
144868
144712
|
var res2 = respFn(resp, state);
|
|
144869
144713
|
res2.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
|
|
144714
|
+
if (options === null || options === void 0 ? void 0 : options.hideThought) {
|
|
144715
|
+
res2.results.forEach(function(result) {
|
|
144716
|
+
if (result.thought) {
|
|
144717
|
+
result.thought = void 0;
|
|
144718
|
+
}
|
|
144719
|
+
});
|
|
144720
|
+
}
|
|
144870
144721
|
if (!res2.modelUsage) {
|
|
144871
144722
|
res2.modelUsage = {
|
|
144872
144723
|
ai: _this.name,
|
|
@@ -144879,23 +144730,16 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144879
144730
|
setChatResponseEvents(res2, span, _this.excludeContentFromTrace);
|
|
144880
144731
|
}
|
|
144881
144732
|
if (debug) {
|
|
144882
|
-
|
|
144883
|
-
logResponse(res2, (_options_logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options_logger !== void 0 ? _options_logger : _this.logger);
|
|
144733
|
+
logResponse(res2);
|
|
144884
144734
|
}
|
|
144885
144735
|
return res2;
|
|
144886
144736
|
};
|
|
144887
144737
|
};
|
|
144888
144738
|
doneCb = function() {
|
|
144889
144739
|
var _ref = _async_to_generator(function(_values) {
|
|
144890
|
-
var _options_logger, logger;
|
|
144891
144740
|
return _ts_generator(this, function(_state) {
|
|
144892
144741
|
if (debug) {
|
|
144893
|
-
|
|
144894
|
-
logger("", {
|
|
144895
|
-
tags: [
|
|
144896
|
-
"responseEnd"
|
|
144897
|
-
]
|
|
144898
|
-
});
|
|
144742
|
+
process.stdout.write("\n");
|
|
144899
144743
|
}
|
|
144900
144744
|
if (span === null || span === void 0 ? void 0 : span.isRecording()) {
|
|
144901
144745
|
span.end();
|
|
@@ -144920,6 +144764,13 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144920
144764
|
}
|
|
144921
144765
|
res = _this.aiImpl.createChatResp(rv);
|
|
144922
144766
|
res.sessionId = options === null || options === void 0 ? void 0 : options.sessionId;
|
|
144767
|
+
if (options === null || options === void 0 ? void 0 : options.hideThought) {
|
|
144768
|
+
res.results.forEach(function(result) {
|
|
144769
|
+
if (result.thought) {
|
|
144770
|
+
result.thought = void 0;
|
|
144771
|
+
}
|
|
144772
|
+
});
|
|
144773
|
+
}
|
|
144923
144774
|
if (!res.modelUsage) {
|
|
144924
144775
|
tokenUsage = _this.aiImpl.getTokenUsage();
|
|
144925
144776
|
if (tokenUsage) {
|
|
@@ -144938,14 +144789,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
144938
144789
|
span.end();
|
|
144939
144790
|
}
|
|
144940
144791
|
if (debug) {
|
|
144941
|
-
logResponse(res
|
|
144942
|
-
}
|
|
144943
|
-
if (debug) {
|
|
144944
|
-
_this.logger("", {
|
|
144945
|
-
tags: [
|
|
144946
|
-
"responseEnd"
|
|
144947
|
-
]
|
|
144948
|
-
});
|
|
144792
|
+
logResponse(res);
|
|
144949
144793
|
}
|
|
144950
144794
|
return [
|
|
144951
144795
|
2,
|
|
@@ -145079,7 +144923,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
145079
144923
|
_this.lastUsedEmbedModel = embedModel;
|
|
145080
144924
|
fn = function() {
|
|
145081
144925
|
var _ref = _async_to_generator(function() {
|
|
145082
|
-
var _this_aiImpl_createEmbedReq, apiConfig, reqValue,
|
|
144926
|
+
var _this_aiImpl_createEmbedReq, apiConfig, reqValue, res2, _tmp;
|
|
145083
144927
|
return _ts_generator(this, function(_state) {
|
|
145084
144928
|
switch(_state.label){
|
|
145085
144929
|
case 0:
|
|
@@ -145096,7 +144940,7 @@ var AxBaseAI = /*#__PURE__*/ function() {
|
|
|
145096
144940
|
return [
|
|
145097
144941
|
4,
|
|
145098
144942
|
apiCall.apply(void 0, [
|
|
145099
|
-
(_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp
|
|
144943
|
+
(_tmp.headers = _state.sent(), _tmp.debug = debug, _tmp.fetch = _this.fetch, _tmp.timeout = _this.timeout, _tmp.span = span, _tmp),
|
|
145100
144944
|
reqValue
|
|
145101
144945
|
])
|
|
145102
144946
|
];
|
|
@@ -145336,40 +145180,50 @@ function setChatResponseEvents(res, span, excludeContentFromTrace) {
|
|
|
145336
145180
|
if (!res.results) {
|
|
145337
145181
|
return;
|
|
145338
145182
|
}
|
|
145339
|
-
|
|
145340
|
-
|
|
145341
|
-
var
|
|
145342
|
-
|
|
145343
|
-
|
|
145344
|
-
|
|
145345
|
-
|
|
145346
|
-
|
|
145183
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
145184
|
+
try {
|
|
145185
|
+
for(var _iterator = res.results.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
145186
|
+
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], result = _step_value[1];
|
|
145187
|
+
var _result_functionCalls;
|
|
145188
|
+
var toolCalls = (_result_functionCalls = result.functionCalls) === null || _result_functionCalls === void 0 ? void 0 : _result_functionCalls.map(function(call) {
|
|
145189
|
+
return {
|
|
145190
|
+
id: call.id,
|
|
145191
|
+
type: call.type,
|
|
145192
|
+
function: call.function.name,
|
|
145193
|
+
arguments: call.function.params
|
|
145194
|
+
};
|
|
145195
|
+
});
|
|
145196
|
+
var message = {};
|
|
145197
|
+
if (toolCalls && toolCalls.length > 0) {
|
|
145198
|
+
if (!excludeContentFromTrace) {
|
|
145199
|
+
message.content = result.content;
|
|
145200
|
+
}
|
|
145201
|
+
message.tool_calls = toolCalls;
|
|
145202
|
+
} else {
|
|
145203
|
+
if (!excludeContentFromTrace) {
|
|
145204
|
+
var _result_content;
|
|
145205
|
+
message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
|
|
145206
|
+
}
|
|
145207
|
+
}
|
|
145208
|
+
span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
|
|
145209
|
+
finish_reason: result.finishReason,
|
|
145210
|
+
index: index,
|
|
145211
|
+
message: JSON.stringify(message, null, 2)
|
|
145212
|
+
});
|
|
145347
145213
|
}
|
|
145348
|
-
|
|
145349
|
-
|
|
145350
|
-
|
|
145351
|
-
|
|
145352
|
-
|
|
145353
|
-
|
|
145354
|
-
|
|
145355
|
-
});
|
|
145356
|
-
var message = {};
|
|
145357
|
-
if (toolCalls && toolCalls.length > 0) {
|
|
145358
|
-
if (!excludeContentFromTrace) {
|
|
145359
|
-
message.content = result.content;
|
|
145214
|
+
} catch (err) {
|
|
145215
|
+
_didIteratorError = true;
|
|
145216
|
+
_iteratorError = err;
|
|
145217
|
+
} finally{
|
|
145218
|
+
try {
|
|
145219
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
145220
|
+
_iterator.return();
|
|
145360
145221
|
}
|
|
145361
|
-
|
|
145362
|
-
|
|
145363
|
-
|
|
145364
|
-
var _result_content;
|
|
145365
|
-
message.content = (_result_content = result.content) !== null && _result_content !== void 0 ? _result_content : "";
|
|
145222
|
+
} finally{
|
|
145223
|
+
if (_didIteratorError) {
|
|
145224
|
+
throw _iteratorError;
|
|
145366
145225
|
}
|
|
145367
145226
|
}
|
|
145368
|
-
span.addEvent(axSpanEvents.GEN_AI_CHOICE, {
|
|
145369
|
-
finish_reason: result.finishReason,
|
|
145370
|
-
index: index,
|
|
145371
|
-
message: JSON.stringify(message, null, 2)
|
|
145372
|
-
});
|
|
145373
145227
|
}
|
|
145374
145228
|
}
|
|
145375
145229
|
function validateModels(models) {
|
|
@@ -145478,80 +145332,50 @@ var GoogleVertexAuth = /*#__PURE__*/ function() {
|
|
|
145478
145332
|
}();
|
|
145479
145333
|
// ai/anthropic/info.ts
|
|
145480
145334
|
var axModelInfoAnthropic = [
|
|
145481
|
-
//
|
|
145482
|
-
{
|
|
145483
|
-
name: "claude-opus-4-20250514" /* Claude4Opus */ ,
|
|
145484
|
-
currency: "usd",
|
|
145485
|
-
promptTokenCostPer1M: 15,
|
|
145486
|
-
completionTokenCostPer1M: 75,
|
|
145487
|
-
maxTokens: 32e3
|
|
145488
|
-
},
|
|
145489
|
-
{
|
|
145490
|
-
name: "claude-sonnet-4-20250514" /* Claude4Sonnet */ ,
|
|
145491
|
-
currency: "usd",
|
|
145492
|
-
promptTokenCostPer1M: 3,
|
|
145493
|
-
completionTokenCostPer1M: 15,
|
|
145494
|
-
maxTokens: 64e3
|
|
145495
|
-
},
|
|
145496
|
-
// 3.7
|
|
145497
|
-
{
|
|
145498
|
-
name: "claude-3-7-sonnet-latest" /* Claude37Sonnet */ ,
|
|
145499
|
-
currency: "usd",
|
|
145500
|
-
promptTokenCostPer1M: 3,
|
|
145501
|
-
completionTokenCostPer1M: 15,
|
|
145502
|
-
maxTokens: 64e3
|
|
145503
|
-
},
|
|
145504
|
-
// 3.5
|
|
145335
|
+
// 35
|
|
145505
145336
|
{
|
|
145506
145337
|
name: "claude-3-5-sonnet-latest" /* Claude35Sonnet */ ,
|
|
145507
145338
|
currency: "usd",
|
|
145508
145339
|
promptTokenCostPer1M: 3,
|
|
145509
|
-
completionTokenCostPer1M: 15
|
|
145510
|
-
maxTokens: 8192
|
|
145340
|
+
completionTokenCostPer1M: 15
|
|
145511
145341
|
},
|
|
145512
145342
|
{
|
|
145513
145343
|
name: "claude-3-5-haiku-latest" /* Claude35Haiku */ ,
|
|
145514
145344
|
currency: "usd",
|
|
145515
145345
|
promptTokenCostPer1M: 0.8,
|
|
145516
|
-
completionTokenCostPer1M: 4
|
|
145517
|
-
maxTokens: 8192
|
|
145346
|
+
completionTokenCostPer1M: 4
|
|
145518
145347
|
},
|
|
145519
145348
|
// 3
|
|
145520
145349
|
{
|
|
145521
145350
|
name: "claude-3-opus-latest" /* Claude3Opus */ ,
|
|
145522
145351
|
currency: "usd",
|
|
145523
145352
|
promptTokenCostPer1M: 15,
|
|
145524
|
-
completionTokenCostPer1M: 75
|
|
145525
|
-
maxTokens: 4096
|
|
145353
|
+
completionTokenCostPer1M: 75
|
|
145526
145354
|
},
|
|
145527
145355
|
{
|
|
145528
145356
|
name: "claude-3-sonnet-20240229" /* Claude3Sonnet */ ,
|
|
145529
145357
|
currency: "usd",
|
|
145530
145358
|
promptTokenCostPer1M: 3,
|
|
145531
|
-
completionTokenCostPer1M: 15
|
|
145532
|
-
maxTokens: 4096
|
|
145359
|
+
completionTokenCostPer1M: 15
|
|
145533
145360
|
},
|
|
145534
145361
|
{
|
|
145535
145362
|
name: "claude-3-haiku-20240307" /* Claude3Haiku */ ,
|
|
145536
145363
|
currency: "usd",
|
|
145537
145364
|
promptTokenCostPer1M: 0.25,
|
|
145538
|
-
completionTokenCostPer1M: 1.25
|
|
145539
|
-
maxTokens: 4096
|
|
145365
|
+
completionTokenCostPer1M: 1.25
|
|
145540
145366
|
},
|
|
145541
|
-
//
|
|
145367
|
+
// 21
|
|
145542
145368
|
{
|
|
145543
145369
|
name: "claude-2.1" /* Claude21 */ ,
|
|
145544
145370
|
currency: "usd",
|
|
145545
145371
|
promptTokenCostPer1M: 8,
|
|
145546
|
-
completionTokenCostPer1M: 25
|
|
145547
|
-
maxTokens: 4096
|
|
145372
|
+
completionTokenCostPer1M: 25
|
|
145548
145373
|
},
|
|
145549
145374
|
{
|
|
145550
145375
|
name: "claude-instant-1.2" /* ClaudeInstant12 */ ,
|
|
145551
145376
|
currency: "usd",
|
|
145552
145377
|
promptTokenCostPer1M: 0.8,
|
|
145553
|
-
completionTokenCostPer1M: 2.24
|
|
145554
|
-
maxTokens: 4096
|
|
145378
|
+
completionTokenCostPer1M: 2.24
|
|
145555
145379
|
}
|
|
145556
145380
|
];
|
|
145557
145381
|
// ai/anthropic/api.ts
|
|
@@ -145635,31 +145459,18 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
|
|
|
145635
145459
|
input_schema: v.parameters
|
|
145636
145460
|
};
|
|
145637
145461
|
});
|
|
145638
|
-
var _req_modelConfig_maxTokens;
|
|
145639
|
-
var
|
|
145640
|
-
var _req_modelConfig_stopSequences;
|
|
145641
|
-
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;
|
|
145642
|
-
var _req_modelConfig_temperature;
|
|
145643
|
-
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;
|
|
145644
|
-
var _req_modelConfig_topP;
|
|
145645
|
-
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;
|
|
145646
|
-
var _req_modelConfig_topK;
|
|
145647
|
-
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;
|
|
145648
|
-
var reqValue = _object_spread_props(_object_spread({}, _this.isVertex ? {
|
|
145462
|
+
var _req_modelConfig_maxTokens, _req_modelConfig_stopSequences, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK;
|
|
145463
|
+
var reqValue = _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, _this.isVertex ? {
|
|
145649
145464
|
anthropic_version: "vertex-2023-10-16"
|
|
145650
145465
|
} : {
|
|
145651
145466
|
model: model
|
|
145652
|
-
},
|
|
145653
|
-
max_tokens: maxTokens
|
|
145654
|
-
|
|
145655
|
-
|
|
145656
|
-
|
|
145657
|
-
|
|
145658
|
-
}
|
|
145659
|
-
top_p: topP
|
|
145660
|
-
} : {}, topK ? {
|
|
145661
|
-
top_k: topK
|
|
145662
|
-
} : {}, toolsChoice, tools && tools.length > 0 ? {
|
|
145467
|
+
}), {
|
|
145468
|
+
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,
|
|
145469
|
+
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,
|
|
145470
|
+
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,
|
|
145471
|
+
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,
|
|
145472
|
+
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
|
|
145473
|
+
}), toolsChoice, tools && tools.length > 0 ? {
|
|
145663
145474
|
tools: tools
|
|
145664
145475
|
} : {}, stream ? {
|
|
145665
145476
|
stream: true
|
|
@@ -145850,9 +145661,8 @@ var AxAIAnthropicImpl = /*#__PURE__*/ function() {
|
|
|
145850
145661
|
key: "getModelConfig",
|
|
145851
145662
|
value: function getModelConfig() {
|
|
145852
145663
|
var config = this.config;
|
|
145853
|
-
var _config_maxTokens;
|
|
145854
145664
|
return {
|
|
145855
|
-
maxTokens:
|
|
145665
|
+
maxTokens: config.maxTokens,
|
|
145856
145666
|
temperature: config.temperature,
|
|
145857
145667
|
topP: config.topP,
|
|
145858
145668
|
topK: config.topK,
|
|
@@ -146285,7 +146095,7 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
146285
146095
|
var _req_modelConfig_stream;
|
|
146286
146096
|
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;
|
|
146287
146097
|
var store = this.config.store;
|
|
146288
|
-
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP,
|
|
146098
|
+
var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_topP, _ref1, _req_modelConfig_n, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
|
|
146289
146099
|
var reqValue = _object_spread({
|
|
146290
146100
|
model: model,
|
|
146291
146101
|
messages: messages,
|
|
@@ -146294,9 +146104,9 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
146294
146104
|
} : void 0,
|
|
146295
146105
|
tools: tools,
|
|
146296
146106
|
tool_choice: toolsChoice,
|
|
146297
|
-
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,
|
|
146107
|
+
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,
|
|
146298
146108
|
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,
|
|
146299
|
-
top_p: (
|
|
146109
|
+
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,
|
|
146300
146110
|
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,
|
|
146301
146111
|
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,
|
|
146302
146112
|
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,
|
|
@@ -146339,9 +146149,6 @@ var AxAIOpenAIImpl = /*#__PURE__*/ function() {
|
|
|
146339
146149
|
}
|
|
146340
146150
|
if (config.thinkingTokenBudget) {
|
|
146341
146151
|
switch(config.thinkingTokenBudget){
|
|
146342
|
-
case "none":
|
|
146343
|
-
reqValue.reasoning_effort = void 0;
|
|
146344
|
-
break;
|
|
146345
146152
|
case "minimal":
|
|
146346
146153
|
reqValue.reasoning_effort = "low";
|
|
146347
146154
|
break;
|
|
@@ -147489,9 +147296,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
147489
147296
|
}
|
|
147490
147297
|
if (config.thinkingTokenBudget) {
|
|
147491
147298
|
switch(config.thinkingTokenBudget){
|
|
147492
|
-
case "none":
|
|
147493
|
-
thinkingConfig.thinkingBudget = 0;
|
|
147494
|
-
break;
|
|
147495
147299
|
case "minimal":
|
|
147496
147300
|
thinkingConfig.thinkingBudget = 200;
|
|
147497
147301
|
break;
|
|
@@ -147509,9 +147313,6 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
147509
147313
|
break;
|
|
147510
147314
|
}
|
|
147511
147315
|
}
|
|
147512
|
-
if (config.showThoughts !== void 0) {
|
|
147513
|
-
thinkingConfig.includeThoughts = config.showThoughts;
|
|
147514
|
-
}
|
|
147515
147316
|
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_topP, _req_modelConfig_topK, _req_modelConfig_frequencyPenalty, _req_modelConfig_stopSequences;
|
|
147516
147317
|
var generationConfig = _object_spread({
|
|
147517
147318
|
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,
|
|
@@ -147522,7 +147323,7 @@ var AxAIGoogleGeminiImpl = /*#__PURE__*/ function() {
|
|
|
147522
147323
|
candidateCount: 1,
|
|
147523
147324
|
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,
|
|
147524
147325
|
responseMimeType: "text/plain"
|
|
147525
|
-
},
|
|
147326
|
+
}, thinkingConfig ? {
|
|
147526
147327
|
thinkingConfig: thinkingConfig
|
|
147527
147328
|
} : {});
|
|
147528
147329
|
var safetySettings2 = _this.config.safetySettings;
|
|
@@ -148271,6 +148072,7 @@ var AxAIMistral = /*#__PURE__*/ function(AxAIOpenAIBase) {
|
|
|
148271
148072
|
modelInfo: modelInfo,
|
|
148272
148073
|
models: models,
|
|
148273
148074
|
supportFor: supportFor,
|
|
148075
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148274
148076
|
chatReqUpdater: chatReqUpdater
|
|
148275
148077
|
});
|
|
148276
148078
|
_get((_assert_this_initialized(_this), _get_prototype_of(AxAIMistral.prototype)), "setName", _this).call(_this, "Mistral");
|
|
@@ -148498,7 +148300,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
148498
148300
|
},
|
|
148499
148301
|
{
|
|
148500
148302
|
key: "createChatReq",
|
|
148501
|
-
value: function createChatReq(req,
|
|
148303
|
+
value: function createChatReq(req, _config) {
|
|
148502
148304
|
var _req_functions, _req_modelConfig, _req_modelConfig1, _req_modelConfig2, _req_modelConfig3, _req_chatPrompt_, _req_chatPrompt_1;
|
|
148503
148305
|
var model = req.model;
|
|
148504
148306
|
var apiConfig = {
|
|
@@ -148543,10 +148345,6 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
148543
148345
|
parameters: (_v_parameters = v.parameters) !== null && _v_parameters !== void 0 ? _v_parameters : {}
|
|
148544
148346
|
};
|
|
148545
148347
|
});
|
|
148546
|
-
var includeFields = [];
|
|
148547
|
-
if (config.showThoughts) {
|
|
148548
|
-
includeFields.push("reasoning.encrypted_content");
|
|
148549
|
-
}
|
|
148550
148348
|
var _req_modelConfig_maxTokens, _ref1, _req_modelConfig_temperature, _ref2, _req_modelConfig_topP, _ref3, _req_modelConfig_stream, _ref4;
|
|
148551
148349
|
var mutableReq = {
|
|
148552
148350
|
model: model,
|
|
@@ -148565,7 +148363,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
148565
148363
|
// Sourced from modelConfig or global config
|
|
148566
148364
|
// Optional fields from AxAIOpenAIResponsesRequest that need to be in Mutable for initialization
|
|
148567
148365
|
background: void 0,
|
|
148568
|
-
include:
|
|
148366
|
+
include: void 0,
|
|
148569
148367
|
metadata: void 0,
|
|
148570
148368
|
parallel_tool_calls: this.config.parallelToolCalls,
|
|
148571
148369
|
previous_response_id: void 0,
|
|
@@ -148640,13 +148438,9 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
148640
148438
|
break;
|
|
148641
148439
|
case "reasoning":
|
|
148642
148440
|
currentResult.id = item.id;
|
|
148643
|
-
|
|
148644
|
-
|
|
148645
|
-
}
|
|
148646
|
-
currentResult.thought = item.summary.map(function(s) {
|
|
148647
|
-
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
148648
|
-
}).join("\n");
|
|
148649
|
-
}
|
|
148441
|
+
currentResult.thought = item.summary.map(function(s) {
|
|
148442
|
+
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
148443
|
+
}).join("\n");
|
|
148650
148444
|
break;
|
|
148651
148445
|
case "file_search_call":
|
|
148652
148446
|
currentResult.id = item.id;
|
|
@@ -148986,9 +148780,7 @@ var AxAIOpenAIResponsesImpl = /*#__PURE__*/ function() {
|
|
|
148986
148780
|
{
|
|
148987
148781
|
var reasoningItem = event.item;
|
|
148988
148782
|
baseResult.id = event.item.id;
|
|
148989
|
-
if (reasoningItem.
|
|
148990
|
-
baseResult.thought = reasoningItem.encrypted_content;
|
|
148991
|
-
} else if (reasoningItem.summary) {
|
|
148783
|
+
if (reasoningItem.summary) {
|
|
148992
148784
|
baseResult.thought = reasoningItem.summary.map(function(s) {
|
|
148993
148785
|
return typeof s === "object" ? JSON.stringify(s) : s;
|
|
148994
148786
|
}).join("\n");
|
|
@@ -149216,6 +149008,7 @@ var axAIOpenAIResponsesDefaultConfig = function() {
|
|
|
149216
149008
|
model: "gpt-4o" /* GPT4O */ ,
|
|
149217
149009
|
embedModel: "text-embedding-ada-002" /* TextEmbeddingAda002 */ ,
|
|
149218
149010
|
temperature: 0.7,
|
|
149011
|
+
maxTokens: 2048,
|
|
149219
149012
|
topP: 1,
|
|
149220
149013
|
stream: true
|
|
149221
149014
|
};
|
|
@@ -149341,14 +149134,14 @@ var AxAIRekaImpl = /*#__PURE__*/ function() {
|
|
|
149341
149134
|
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;
|
|
149342
149135
|
var _req_modelConfig_stream;
|
|
149343
149136
|
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;
|
|
149344
|
-
var _req_modelConfig_maxTokens, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP,
|
|
149137
|
+
var _req_modelConfig_maxTokens, _ref, _req_modelConfig_temperature, _req_modelConfig_n, _req_modelConfig_topP, _ref1, _req_modelConfig_stopSequences, _req_modelConfig_presencePenalty;
|
|
149345
149138
|
var reqValue = _object_spread({
|
|
149346
149139
|
model: model,
|
|
149347
149140
|
messages: messages,
|
|
149348
|
-
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,
|
|
149141
|
+
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,
|
|
149349
149142
|
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,
|
|
149350
149143
|
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,
|
|
149351
|
-
top_p: (
|
|
149144
|
+
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,
|
|
149352
149145
|
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,
|
|
149353
149146
|
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
|
|
149354
149147
|
}, frequencyPenalty ? {
|
|
@@ -149747,12 +149540,6 @@ var AxAI = /*#__PURE__*/ function() {
|
|
|
149747
149540
|
value: function getOptions() {
|
|
149748
149541
|
return this.ai.getOptions();
|
|
149749
149542
|
}
|
|
149750
|
-
},
|
|
149751
|
-
{
|
|
149752
|
-
key: "getLogger",
|
|
149753
|
-
value: function getLogger() {
|
|
149754
|
-
return this.ai.getLogger();
|
|
149755
|
-
}
|
|
149756
149543
|
}
|
|
149757
149544
|
]);
|
|
149758
149545
|
return AxAI;
|
|
@@ -149902,7 +149689,7 @@ var MemoryImpl = /*#__PURE__*/ function() {
|
|
|
149902
149689
|
if ((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.debug) {
|
|
149903
149690
|
if (delta && typeof delta === "string") {
|
|
149904
149691
|
debugResponseDelta(delta);
|
|
149905
|
-
} else if (
|
|
149692
|
+
} else if (lastItem) {
|
|
149906
149693
|
debugResponse({
|
|
149907
149694
|
content: content,
|
|
149908
149695
|
name: name,
|
|
@@ -150321,8 +150108,6 @@ var validateValue = function(field, value) {
|
|
|
150321
150108
|
};
|
|
150322
150109
|
var validateSingleValue = function(expectedType, val) {
|
|
150323
150110
|
switch(expectedType){
|
|
150324
|
-
case "class":
|
|
150325
|
-
return typeof val === "string";
|
|
150326
150111
|
case "code":
|
|
150327
150112
|
return typeof val === "string";
|
|
150328
150113
|
case "string":
|
|
@@ -150377,7 +150162,7 @@ var validateValue = function(field, value) {
|
|
|
150377
150162
|
msg = "object ({ mimeType: string; data: string })";
|
|
150378
150163
|
}
|
|
150379
150164
|
if (msg) {
|
|
150380
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
150165
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg, " instead got '").concat(value, "'"));
|
|
150381
150166
|
}
|
|
150382
150167
|
return;
|
|
150383
150168
|
}
|
|
@@ -150417,7 +150202,7 @@ var validateValue = function(field, value) {
|
|
|
150417
150202
|
msg1 = "object ({ data: string; format?: string })";
|
|
150418
150203
|
}
|
|
150419
150204
|
if (msg1) {
|
|
150420
|
-
throw new Error("Validation failed: Expected '".concat(field.name, "' to be
|
|
150205
|
+
throw new Error("Validation failed: Expected '".concat(field.name, "' to be a ").concat(msg1, " instead got '").concat(value, "'"));
|
|
150421
150206
|
}
|
|
150422
150207
|
return;
|
|
150423
150208
|
}
|
|
@@ -150455,8 +150240,7 @@ var validateValue = function(field, value) {
|
|
|
150455
150240
|
}
|
|
150456
150241
|
if (!isValid) {
|
|
150457
150242
|
var _field_type3;
|
|
150458
|
-
|
|
150459
|
-
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), ")"));
|
|
150243
|
+
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, ")"));
|
|
150460
150244
|
}
|
|
150461
150245
|
};
|
|
150462
150246
|
function mergeProgramUsage(usages) {
|
|
@@ -150657,15 +150441,13 @@ function matchesContent(content, prefix) {
|
|
|
150657
150441
|
// dsp/prompt.ts
|
|
150658
150442
|
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.";
|
|
150659
150443
|
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.";
|
|
150660
|
-
var AxPromptTemplate = function AxPromptTemplate(sig,
|
|
150444
|
+
var AxPromptTemplate = function AxPromptTemplate(sig, functions, fieldTemplates) {
|
|
150661
150445
|
var _this = this;
|
|
150662
150446
|
_class_call_check(this, AxPromptTemplate);
|
|
150663
|
-
var
|
|
150447
|
+
var _functions_map;
|
|
150664
150448
|
_define_property(this, "sig", void 0);
|
|
150665
150449
|
_define_property(this, "fieldTemplates", void 0);
|
|
150666
150450
|
_define_property(this, "task", void 0);
|
|
150667
|
-
_define_property(this, "thoughtFieldName", void 0);
|
|
150668
|
-
_define_property(this, "functions", void 0);
|
|
150669
150451
|
_define_property(this, "render", function(values, param) {
|
|
150670
150452
|
var examples = param.examples, demos = param.demos;
|
|
150671
150453
|
var renderedExamples = examples ? [
|
|
@@ -150675,6 +150457,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150675
150457
|
}
|
|
150676
150458
|
].concat(_to_consumable_array(_this.renderExamples(examples))) : [];
|
|
150677
150459
|
var renderedDemos = demos ? _this.renderDemos(demos) : [];
|
|
150460
|
+
var completion = _this.renderInputFields(values);
|
|
150678
150461
|
var allTextExamples = renderedExamples.every(function(v) {
|
|
150679
150462
|
return v.type === "text";
|
|
150680
150463
|
});
|
|
@@ -150699,92 +150482,23 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150699
150482
|
role: "system",
|
|
150700
150483
|
content: systemContent
|
|
150701
150484
|
};
|
|
150702
|
-
var
|
|
150703
|
-
|
|
150704
|
-
|
|
150705
|
-
|
|
150706
|
-
|
|
150707
|
-
|
|
150708
|
-
|
|
150709
|
-
|
|
150710
|
-
|
|
150711
|
-
|
|
150712
|
-
|
|
150713
|
-
|
|
150714
|
-
|
|
150715
|
-
}).join("").trim();
|
|
150716
|
-
} else if (message.role === "assistant") {
|
|
150717
|
-
var assistantMsgParts = _this.renderInputFields(message.values);
|
|
150718
|
-
messageContent = assistantMsgParts.map(function(part) {
|
|
150719
|
-
return part.type === "text" ? part.text : "";
|
|
150720
|
-
}).join("").trim();
|
|
150721
|
-
}
|
|
150722
|
-
if (messageContent) {
|
|
150723
|
-
if (lastRole === message.role && userMessages.length > 0) {
|
|
150724
|
-
var lastMessage = userMessages[userMessages.length - 1];
|
|
150725
|
-
if (lastMessage) {
|
|
150726
|
-
lastMessage.content += "\n" + messageContent;
|
|
150727
|
-
}
|
|
150728
|
-
} else {
|
|
150729
|
-
if (message.role === "user") {
|
|
150730
|
-
userMessages.push({
|
|
150731
|
-
role: "user",
|
|
150732
|
-
content: messageContent
|
|
150733
|
-
});
|
|
150734
|
-
} else if (message.role === "assistant") {
|
|
150735
|
-
userMessages.push({
|
|
150736
|
-
role: "assistant",
|
|
150737
|
-
content: messageContent
|
|
150738
|
-
});
|
|
150739
|
-
}
|
|
150740
|
-
}
|
|
150741
|
-
lastRole = message.role;
|
|
150742
|
-
}
|
|
150743
|
-
}
|
|
150744
|
-
} catch (err) {
|
|
150745
|
-
_didIteratorError = true;
|
|
150746
|
-
_iteratorError = err;
|
|
150747
|
-
} finally{
|
|
150748
|
-
try {
|
|
150749
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
150750
|
-
_iterator.return();
|
|
150751
|
-
}
|
|
150752
|
-
} finally{
|
|
150753
|
-
if (_didIteratorError) {
|
|
150754
|
-
throw _iteratorError;
|
|
150755
|
-
}
|
|
150756
|
-
}
|
|
150757
|
-
}
|
|
150758
|
-
} else {
|
|
150759
|
-
var currentValues = values;
|
|
150760
|
-
var completion = _this.renderInputFields(currentValues);
|
|
150761
|
-
var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
|
|
150762
|
-
var promptFilter = promptList.filter(function(v) {
|
|
150763
|
-
return v !== void 0;
|
|
150764
|
-
});
|
|
150765
|
-
var userContent;
|
|
150766
|
-
if (promptFilter.every(function(v) {
|
|
150767
|
-
return v.type === "text";
|
|
150768
|
-
})) {
|
|
150769
|
-
userContent = promptFilter.map(function(v) {
|
|
150770
|
-
return v.text;
|
|
150771
|
-
}).join("\n");
|
|
150772
|
-
} else {
|
|
150773
|
-
userContent = promptFilter.map(function(part) {
|
|
150774
|
-
if (part.type === "text") return part.text;
|
|
150775
|
-
if (part.type === "image") return "[IMAGE]";
|
|
150776
|
-
if (part.type === "audio") return "[AUDIO]";
|
|
150777
|
-
return "";
|
|
150778
|
-
}).join("\n").trim();
|
|
150779
|
-
}
|
|
150780
|
-
userMessages.push({
|
|
150781
|
-
role: "user",
|
|
150782
|
-
content: userContent
|
|
150783
|
-
});
|
|
150784
|
-
}
|
|
150485
|
+
var promptList = examplesInSystemPrompt ? completion : _to_consumable_array(renderedExamples).concat(_to_consumable_array(renderedDemos), _to_consumable_array(completion));
|
|
150486
|
+
var prompt = promptList.filter(function(v) {
|
|
150487
|
+
return v !== void 0;
|
|
150488
|
+
});
|
|
150489
|
+
var userContent = prompt.every(function(v) {
|
|
150490
|
+
return v.type === "text";
|
|
150491
|
+
}) ? prompt.map(function(v) {
|
|
150492
|
+
return v.text;
|
|
150493
|
+
}).join("\n") : prompt.reduce(combineConsecutiveStrings("\n"), []);
|
|
150494
|
+
var userPrompt = {
|
|
150495
|
+
role: "user",
|
|
150496
|
+
content: userContent
|
|
150497
|
+
};
|
|
150785
150498
|
return [
|
|
150786
|
-
systemPrompt
|
|
150787
|
-
|
|
150499
|
+
systemPrompt,
|
|
150500
|
+
userPrompt
|
|
150501
|
+
];
|
|
150788
150502
|
});
|
|
150789
150503
|
_define_property(this, "renderExtraFields", function(extraFields) {
|
|
150790
150504
|
var prompt = [];
|
|
@@ -150830,28 +150544,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150830
150544
|
});
|
|
150831
150545
|
_define_property(this, "renderExamples", function(data) {
|
|
150832
150546
|
var list = [];
|
|
150833
|
-
var exampleContext = {
|
|
150834
|
-
isExample: true
|
|
150835
|
-
};
|
|
150836
150547
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
150837
150548
|
try {
|
|
150838
150549
|
var _loop = function() {
|
|
150839
150550
|
var _step_value = _sliced_to_array(_step.value, 2), index = _step_value[0], item = _step_value[1];
|
|
150840
150551
|
var _renderedItem_;
|
|
150841
150552
|
var renderedInputItem = _this.sig.getInputFields().map(function(field) {
|
|
150842
|
-
return _this.renderInField(field, item,
|
|
150843
|
-
isInputField: true
|
|
150844
|
-
}));
|
|
150553
|
+
return _this.renderInField(field, item, true);
|
|
150845
150554
|
}).filter(function(v) {
|
|
150846
150555
|
return v !== void 0;
|
|
150847
150556
|
}).flat();
|
|
150848
150557
|
var renderedOutputItem = _this.sig.getOutputFields().map(function(field) {
|
|
150849
|
-
return _this.renderInField(field, item,
|
|
150850
|
-
isInputField: false
|
|
150851
|
-
}));
|
|
150558
|
+
return _this.renderInField(field, item, true);
|
|
150852
150559
|
}).filter(function(v) {
|
|
150853
150560
|
return v !== void 0;
|
|
150854
150561
|
}).flat();
|
|
150562
|
+
if (renderedOutputItem.length === 0) {
|
|
150563
|
+
throw new Error("Output fields are required in examples: index: ".concat(index, ", data: ").concat(JSON.stringify(item)));
|
|
150564
|
+
}
|
|
150855
150565
|
var renderedItem = _to_consumable_array(renderedInputItem).concat(_to_consumable_array(renderedOutputItem));
|
|
150856
150566
|
if (index > 0 && renderedItem.length > 0 && ((_renderedItem_ = renderedItem[0]) === null || _renderedItem_ === void 0 ? void 0 : _renderedItem_.type) === "text") {
|
|
150857
150567
|
list.push({
|
|
@@ -150888,30 +150598,16 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150888
150598
|
});
|
|
150889
150599
|
_define_property(this, "renderDemos", function(data) {
|
|
150890
150600
|
var list = [];
|
|
150891
|
-
var
|
|
150892
|
-
var outputFields = _this.sig.getOutputFields();
|
|
150893
|
-
var demoContext = {
|
|
150894
|
-
isExample: true
|
|
150895
|
-
};
|
|
150601
|
+
var fields = _to_consumable_array(_this.sig.getInputFields()).concat(_to_consumable_array(_this.sig.getOutputFields()));
|
|
150896
150602
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
150897
150603
|
try {
|
|
150898
150604
|
var _loop = function() {
|
|
150899
150605
|
var item = _step.value;
|
|
150900
|
-
var
|
|
150901
|
-
return _this.renderInField(field, item,
|
|
150902
|
-
isInputField: true
|
|
150903
|
-
}));
|
|
150606
|
+
var renderedItem = fields.map(function(field) {
|
|
150607
|
+
return _this.renderInField(field, item, true);
|
|
150904
150608
|
}).filter(function(v) {
|
|
150905
150609
|
return v !== void 0;
|
|
150906
150610
|
}).flat();
|
|
150907
|
-
var outputRenderedItems = outputFields.map(function(field) {
|
|
150908
|
-
return _this.renderInField(field, item, _object_spread_props(_object_spread({}, demoContext), {
|
|
150909
|
-
isInputField: false
|
|
150910
|
-
}));
|
|
150911
|
-
}).filter(function(v) {
|
|
150912
|
-
return v !== void 0;
|
|
150913
|
-
}).flat();
|
|
150914
|
-
var renderedItem = _to_consumable_array(inputRenderedItems).concat(_to_consumable_array(outputRenderedItems));
|
|
150915
150611
|
renderedItem.slice(0, -1).forEach(function(v) {
|
|
150916
150612
|
if ("text" in v) {
|
|
150917
150613
|
v.text = v.text + "\n";
|
|
@@ -150941,7 +150637,7 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150941
150637
|
});
|
|
150942
150638
|
_define_property(this, "renderInputFields", function(values) {
|
|
150943
150639
|
var renderedItems = _this.sig.getInputFields().map(function(field) {
|
|
150944
|
-
return _this.renderInField(field, values
|
|
150640
|
+
return _this.renderInField(field, values);
|
|
150945
150641
|
}).filter(function(v) {
|
|
150946
150642
|
return v !== void 0;
|
|
150947
150643
|
}).flat();
|
|
@@ -150952,10 +150648,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150952
150648
|
});
|
|
150953
150649
|
return renderedItems;
|
|
150954
150650
|
});
|
|
150955
|
-
_define_property(this, "renderInField", function(field, values,
|
|
150651
|
+
_define_property(this, "renderInField", function(field, values, skipMissing) {
|
|
150956
150652
|
var _this_fieldTemplates;
|
|
150957
150653
|
var value = values[field.name];
|
|
150958
|
-
if (
|
|
150654
|
+
if (skipMissing && !value) {
|
|
150655
|
+
return;
|
|
150656
|
+
}
|
|
150657
|
+
if (isEmptyValue(field, value)) {
|
|
150959
150658
|
return;
|
|
150960
150659
|
}
|
|
150961
150660
|
if (field.type) {
|
|
@@ -150995,19 +150694,19 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
150995
150694
|
throw new Error("Image field value must be an array.");
|
|
150996
150695
|
}
|
|
150997
150696
|
result = result.concat(value.map(function(v) {
|
|
150998
|
-
|
|
150697
|
+
v = validateImage(v);
|
|
150999
150698
|
return {
|
|
151000
150699
|
type: "image",
|
|
151001
|
-
mimeType:
|
|
151002
|
-
image:
|
|
150700
|
+
mimeType: v.mimeType,
|
|
150701
|
+
image: v.data
|
|
151003
150702
|
};
|
|
151004
150703
|
}));
|
|
151005
150704
|
} else {
|
|
151006
|
-
var
|
|
150705
|
+
var v = validateImage(value);
|
|
151007
150706
|
result.push({
|
|
151008
150707
|
type: "image",
|
|
151009
|
-
mimeType:
|
|
151010
|
-
image:
|
|
150708
|
+
mimeType: v.mimeType,
|
|
150709
|
+
image: v.data
|
|
151011
150710
|
});
|
|
151012
150711
|
}
|
|
151013
150712
|
return result;
|
|
@@ -151033,24 +150732,24 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
151033
150732
|
];
|
|
151034
150733
|
if (field.type.isArray) {
|
|
151035
150734
|
if (!Array.isArray(value)) {
|
|
151036
|
-
throw new Error("
|
|
150735
|
+
throw new Error("Image field value must be an array.");
|
|
151037
150736
|
}
|
|
151038
150737
|
result1 = result1.concat(value.map(function(v) {
|
|
151039
|
-
|
|
151040
|
-
var
|
|
150738
|
+
v = validateAudio(v);
|
|
150739
|
+
var _v_format;
|
|
151041
150740
|
return {
|
|
151042
150741
|
type: "audio",
|
|
151043
|
-
format: (
|
|
151044
|
-
data:
|
|
150742
|
+
format: (_v_format = v.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
150743
|
+
data: v.data
|
|
151045
150744
|
};
|
|
151046
150745
|
}));
|
|
151047
150746
|
} else {
|
|
151048
|
-
var
|
|
151049
|
-
var
|
|
150747
|
+
var v1 = validateAudio(value);
|
|
150748
|
+
var _v_format;
|
|
151050
150749
|
result1.push({
|
|
151051
150750
|
type: "audio",
|
|
151052
|
-
format: (
|
|
151053
|
-
data:
|
|
150751
|
+
format: (_v_format = v1.format) !== null && _v_format !== void 0 ? _v_format : "wav",
|
|
150752
|
+
data: v1.data
|
|
151054
150753
|
});
|
|
151055
150754
|
}
|
|
151056
150755
|
return result1;
|
|
@@ -151076,16 +150775,13 @@ var AxPromptTemplate = function AxPromptTemplate(sig, options, fieldTemplates) {
|
|
|
151076
150775
|
});
|
|
151077
150776
|
this.sig = sig;
|
|
151078
150777
|
this.fieldTemplates = fieldTemplates;
|
|
151079
|
-
var _options_thoughtFieldName;
|
|
151080
|
-
this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
|
|
151081
|
-
this.functions = options === null || options === void 0 ? void 0 : options.functions;
|
|
151082
150778
|
var task = [];
|
|
151083
150779
|
var inArgs = renderDescFields(this.sig.getInputFields());
|
|
151084
150780
|
var outArgs = renderDescFields(this.sig.getOutputFields());
|
|
151085
150781
|
task.push("You will be provided with the following fields: ".concat(inArgs, ". Your task is to generate new fields: ").concat(outArgs, "."));
|
|
151086
|
-
var funcs =
|
|
150782
|
+
var funcs = functions === null || functions === void 0 ? void 0 : (_functions_map = functions.map(function(f) {
|
|
151087
150783
|
return "toFunction" in f ? f.toFunction() : f;
|
|
151088
|
-
})) === null ||
|
|
150784
|
+
})) === null || _functions_map === void 0 ? void 0 : _functions_map.flat();
|
|
151089
150785
|
var funcList = funcs === null || funcs === void 0 ? void 0 : funcs.map(function(fn) {
|
|
151090
150786
|
return "- `".concat(fn.name, "`: ").concat(formatDescription(fn.description));
|
|
151091
150787
|
}).join("\n");
|
|
@@ -151198,19 +150894,15 @@ function combineConsecutiveStrings(separator) {
|
|
|
151198
150894
|
return acc;
|
|
151199
150895
|
};
|
|
151200
150896
|
}
|
|
151201
|
-
var isEmptyValue = function(field, value
|
|
150897
|
+
var isEmptyValue = function(field, value) {
|
|
151202
150898
|
if (typeof value === "boolean") {
|
|
151203
150899
|
return false;
|
|
151204
150900
|
}
|
|
151205
150901
|
if (!value || (Array.isArray(value) || typeof value === "string") && value.length === 0) {
|
|
151206
|
-
if (
|
|
151207
|
-
return true;
|
|
151208
|
-
}
|
|
151209
|
-
if (field.isOptional || field.isInternal) {
|
|
150902
|
+
if (field.isOptional) {
|
|
151210
150903
|
return true;
|
|
151211
150904
|
}
|
|
151212
|
-
|
|
151213
|
-
throw new Error("Value for ".concat(fieldType, " field '").concat(field.name, "' is required."));
|
|
150905
|
+
throw new Error("Value for input field '".concat(field.name, "' is required."));
|
|
151214
150906
|
}
|
|
151215
150907
|
return false;
|
|
151216
150908
|
};
|
|
@@ -151219,6 +150911,7 @@ function formatDescription(str) {
|
|
|
151219
150911
|
return value.length > 0 ? "".concat(value.charAt(0).toUpperCase()).concat(value.slice(1)).concat(value.endsWith(".") ? "" : ".") : "";
|
|
151220
150912
|
}
|
|
151221
150913
|
// dsp/validate.ts
|
|
150914
|
+
var colorLog4 = new ColorLog();
|
|
151222
150915
|
var ValidationError = (_Symbol_for2 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
151223
150916
|
_inherits(_class, Error1);
|
|
151224
150917
|
var _super = _create_super(_class);
|
|
@@ -151271,12 +150964,7 @@ function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId)
|
|
|
151271
150964
|
var errors = errorFields.map(function(field) {
|
|
151272
150965
|
return "- ".concat(field.title, ": ").concat(field.description);
|
|
151273
150966
|
}).join("\n");
|
|
151274
|
-
|
|
151275
|
-
logger("❌ Error Correction:\n".concat(errors), {
|
|
151276
|
-
tags: [
|
|
151277
|
-
"error"
|
|
151278
|
-
]
|
|
151279
|
-
});
|
|
150967
|
+
process.stdout.write(colorLog4.red("\n❌ Error Correction:\n".concat(errors, "\n")));
|
|
151280
150968
|
}
|
|
151281
150969
|
}
|
|
151282
150970
|
// dsp/datetime.ts
|
|
@@ -152088,9 +151776,6 @@ var validateJSONSchema = function(schema) {
|
|
|
152088
151776
|
var errors = [];
|
|
152089
151777
|
var validateSchemaObject = function(schema2) {
|
|
152090
151778
|
var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
152091
|
-
if (!schema2 || typeof schema2 !== "object") {
|
|
152092
|
-
return;
|
|
152093
|
-
}
|
|
152094
151779
|
var validTypes = [
|
|
152095
151780
|
"array",
|
|
152096
151781
|
"integer",
|
|
@@ -152100,174 +151785,42 @@ var validateJSONSchema = function(schema) {
|
|
|
152100
151785
|
"null",
|
|
152101
151786
|
"object"
|
|
152102
151787
|
];
|
|
152103
|
-
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
152104
|
-
if (schema2.anyOf.length === 0) {
|
|
152105
|
-
errors.push({
|
|
152106
|
-
path: path || "root",
|
|
152107
|
-
issue: "anyOf array is empty",
|
|
152108
|
-
fix: "Add at least one schema to the anyOf array",
|
|
152109
|
-
example: 'anyOf: [{ type: "string" }, { type: "null" }]'
|
|
152110
|
-
});
|
|
152111
|
-
}
|
|
152112
|
-
schema2.anyOf.forEach(function(subSchema, index) {
|
|
152113
|
-
validateSchemaObject(subSchema, "".concat(path, "anyOf[").concat(index, "]."));
|
|
152114
|
-
});
|
|
152115
|
-
return;
|
|
152116
|
-
}
|
|
152117
|
-
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
152118
|
-
if (schema2.oneOf.length === 0) {
|
|
152119
|
-
errors.push({
|
|
152120
|
-
path: path || "root",
|
|
152121
|
-
issue: "oneOf array is empty",
|
|
152122
|
-
fix: "Add at least one schema to the oneOf array",
|
|
152123
|
-
example: 'oneOf: [{ type: "string" }, { type: "number" }]'
|
|
152124
|
-
});
|
|
152125
|
-
}
|
|
152126
|
-
schema2.oneOf.forEach(function(subSchema, index) {
|
|
152127
|
-
validateSchemaObject(subSchema, "".concat(path, "oneOf[").concat(index, "]."));
|
|
152128
|
-
});
|
|
152129
|
-
return;
|
|
152130
|
-
}
|
|
152131
|
-
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
152132
|
-
if (schema2.allOf.length === 0) {
|
|
152133
|
-
errors.push({
|
|
152134
|
-
path: path || "root",
|
|
152135
|
-
issue: "allOf array is empty",
|
|
152136
|
-
fix: "Add at least one schema to the allOf array",
|
|
152137
|
-
example: 'allOf: [{ type: "object" }, { properties: { name: { type: "string" } } }]'
|
|
152138
|
-
});
|
|
152139
|
-
}
|
|
152140
|
-
schema2.allOf.forEach(function(subSchema, index) {
|
|
152141
|
-
validateSchemaObject(subSchema, "".concat(path, "allOf[").concat(index, "]."));
|
|
152142
|
-
});
|
|
152143
|
-
return;
|
|
152144
|
-
}
|
|
152145
|
-
if (!schema2.type) {
|
|
152146
|
-
return;
|
|
152147
|
-
}
|
|
152148
151788
|
if (!validTypes.includes(schema2.type)) {
|
|
152149
|
-
errors.push(
|
|
152150
|
-
path: path || "root",
|
|
152151
|
-
issue: "Invalid type '".concat(schema2.type, "'"),
|
|
152152
|
-
fix: "Change type to one of: ".concat(validTypes.join(", ")),
|
|
152153
|
-
example: '{ type: "string" } or { type: "object" }'
|
|
152154
|
-
});
|
|
151789
|
+
errors.push("Invalid type '".concat(schema2.type, "' at ").concat(path || "root"));
|
|
152155
151790
|
return;
|
|
152156
151791
|
}
|
|
152157
|
-
if (schema2.type === "object") {
|
|
152158
|
-
if (schema2.properties) {
|
|
152159
|
-
|
|
152160
|
-
|
|
152161
|
-
|
|
152162
|
-
|
|
152163
|
-
|
|
152164
|
-
|
|
152165
|
-
|
|
152166
|
-
} else {
|
|
152167
|
-
for(var key in schema2.properties){
|
|
152168
|
-
var value = schema2.properties[key];
|
|
152169
|
-
if (value === void 0 || value === null) {
|
|
152170
|
-
continue;
|
|
152171
|
-
}
|
|
152172
|
-
if (typeof value !== "object") {
|
|
152173
|
-
errors.push({
|
|
152174
|
-
path: "".concat(path).concat(key),
|
|
152175
|
-
issue: "Property schema must be an object, got ".concat(typeof value === "undefined" ? "undefined" : _type_of(value)),
|
|
152176
|
-
fix: "Define the property as a proper schema object",
|
|
152177
|
-
example: "".concat(key, ': { type: "string", description: "..." }')
|
|
152178
|
-
});
|
|
152179
|
-
continue;
|
|
152180
|
-
}
|
|
152181
|
-
validateSchemaObject(value, "".concat(path).concat(key, "."));
|
|
151792
|
+
if (schema2.type === "object" && schema2.properties) {
|
|
151793
|
+
if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
|
|
151794
|
+
errors.push("Invalid properties object at ".concat(path || "root"));
|
|
151795
|
+
} else {
|
|
151796
|
+
for(var key in schema2.properties){
|
|
151797
|
+
var value = schema2.properties[key];
|
|
151798
|
+
if (typeof value !== "object") {
|
|
151799
|
+
errors.push("Invalid schema object at ".concat(path).concat(key));
|
|
151800
|
+
continue;
|
|
152182
151801
|
}
|
|
151802
|
+
validateSchemaObject(value, "".concat(path).concat(key, "."));
|
|
152183
151803
|
}
|
|
152184
151804
|
}
|
|
152185
|
-
if (schema2.required) {
|
|
152186
|
-
|
|
152187
|
-
errors.push({
|
|
152188
|
-
path: path || "root",
|
|
152189
|
-
issue: "'required' must be an array, got ".concat(_type_of(schema2.required)),
|
|
152190
|
-
fix: "Change required to be an array of property names",
|
|
152191
|
-
example: 'required: ["name", "email"] instead of required: "name,email"'
|
|
152192
|
-
});
|
|
152193
|
-
} else if (schema2.required.length === 0) ; else {
|
|
152194
|
-
if (schema2.properties) {
|
|
152195
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
152196
|
-
try {
|
|
152197
|
-
for(var _iterator = schema2.required[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
152198
|
-
var requiredProp = _step.value;
|
|
152199
|
-
if (typeof requiredProp !== "string") {
|
|
152200
|
-
errors.push({
|
|
152201
|
-
path: "".concat(path, "required"),
|
|
152202
|
-
issue: "Required property names must be strings, got ".concat(typeof requiredProp === "undefined" ? "undefined" : _type_of(requiredProp)),
|
|
152203
|
-
fix: "Ensure all items in required array are strings",
|
|
152204
|
-
example: 'required: ["name", "email"] not required: [123, "email"]'
|
|
152205
|
-
});
|
|
152206
|
-
} else if (!(requiredProp in schema2.properties)) {
|
|
152207
|
-
errors.push({
|
|
152208
|
-
path: "".concat(path, "required"),
|
|
152209
|
-
issue: "Required property '".concat(requiredProp, "' is not defined in properties"),
|
|
152210
|
-
fix: "Either add '".concat(requiredProp, "' to properties or remove it from required"),
|
|
152211
|
-
example: "properties: { ".concat(requiredProp, ': { type: "string" } }')
|
|
152212
|
-
});
|
|
152213
|
-
}
|
|
152214
|
-
}
|
|
152215
|
-
} catch (err) {
|
|
152216
|
-
_didIteratorError = true;
|
|
152217
|
-
_iteratorError = err;
|
|
152218
|
-
} finally{
|
|
152219
|
-
try {
|
|
152220
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
152221
|
-
_iterator.return();
|
|
152222
|
-
}
|
|
152223
|
-
} finally{
|
|
152224
|
-
if (_didIteratorError) {
|
|
152225
|
-
throw _iteratorError;
|
|
152226
|
-
}
|
|
152227
|
-
}
|
|
152228
|
-
}
|
|
152229
|
-
}
|
|
152230
|
-
}
|
|
151805
|
+
if (schema2.required && !Array.isArray(schema2.required)) {
|
|
151806
|
+
errors.push("'required' should be an array at ".concat(path || "root"));
|
|
152231
151807
|
}
|
|
152232
151808
|
}
|
|
152233
|
-
if (schema2.type === "array") {
|
|
152234
|
-
if (schema2.items) {
|
|
152235
|
-
|
|
152236
|
-
|
|
152237
|
-
|
|
152238
|
-
issue: "Array items schema must be an object, got ".concat(_type_of(schema2.items)),
|
|
152239
|
-
fix: "Define items as a proper schema object",
|
|
152240
|
-
example: 'items: { type: "string" } or items: { type: "object", properties: {...} }'
|
|
152241
|
-
});
|
|
152242
|
-
} else {
|
|
152243
|
-
validateSchemaObject(schema2.items, "".concat(path, "items."));
|
|
152244
|
-
}
|
|
151809
|
+
if (schema2.type === "array" && schema2.items) {
|
|
151810
|
+
if (typeof schema2.items !== "object") {
|
|
151811
|
+
errors.push("Invalid items schema at ".concat(path || "root"));
|
|
151812
|
+
} else {
|
|
151813
|
+
validateSchemaObject(schema2.items, "".concat(path, "items."));
|
|
152245
151814
|
}
|
|
152246
151815
|
}
|
|
152247
151816
|
};
|
|
152248
151817
|
validateSchemaObject(schema);
|
|
152249
151818
|
if (errors.length > 0) {
|
|
152250
|
-
|
|
152251
|
-
"JSON Schema validation failed:",
|
|
152252
|
-
""
|
|
152253
|
-
].concat(_to_consumable_array(errors.map(function(error, index) {
|
|
152254
|
-
var parts = [
|
|
152255
|
-
"".concat(index + 1, ". Path: ").concat(error.path),
|
|
152256
|
-
" Issue: ".concat(error.issue),
|
|
152257
|
-
" Fix: ".concat(error.fix)
|
|
152258
|
-
];
|
|
152259
|
-
if (error.example) {
|
|
152260
|
-
parts.push(" Example: ".concat(error.example));
|
|
152261
|
-
}
|
|
152262
|
-
return parts.join("\n");
|
|
152263
|
-
})), [
|
|
152264
|
-
"",
|
|
152265
|
-
"Please fix these issues and try again."
|
|
152266
|
-
]).join("\n");
|
|
152267
|
-
throw new Error(errorMessage);
|
|
151819
|
+
throw new Error(errors.join("; "));
|
|
152268
151820
|
}
|
|
152269
151821
|
};
|
|
152270
151822
|
// dsp/functions.ts
|
|
151823
|
+
var colorLog5 = new ColorLog();
|
|
152271
151824
|
var AxFunctionError = (_Symbol_for3 = Symbol.for("nodejs.util.inspect.custom"), /*#__PURE__*/ function(Error1) {
|
|
152272
151825
|
_inherits(_class, Error1);
|
|
152273
151826
|
var _super = _create_super(_class);
|
|
@@ -152593,12 +152146,7 @@ var processFunctions = function() {
|
|
|
152593
152146
|
}, sessionId);
|
|
152594
152147
|
mem.addTag("error");
|
|
152595
152148
|
if (ai.getOptions().debug) {
|
|
152596
|
-
|
|
152597
|
-
logger("❌ Function Error Correction:\n".concat(result), {
|
|
152598
|
-
tags: [
|
|
152599
|
-
"error"
|
|
152600
|
-
]
|
|
152601
|
-
});
|
|
152149
|
+
process.stdout.write(colorLog5.red("\n❌ Function Error Correction:\n".concat(result, "\n")));
|
|
152602
152150
|
}
|
|
152603
152151
|
} else {
|
|
152604
152152
|
throw e;
|
|
@@ -153341,7 +152889,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153341
152889
|
_define_property(this, "signature", void 0);
|
|
153342
152890
|
_define_property(this, "sigHash", void 0);
|
|
153343
152891
|
_define_property(this, "examples", void 0);
|
|
153344
|
-
_define_property(this, "examplesOptions", void 0);
|
|
153345
152892
|
_define_property(this, "demos", void 0);
|
|
153346
152893
|
_define_property(this, "trace", void 0);
|
|
153347
152894
|
_define_property(this, "usage", []);
|
|
@@ -153436,8 +152983,8 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153436
152983
|
},
|
|
153437
152984
|
{
|
|
153438
152985
|
key: "setExamples",
|
|
153439
|
-
value: function setExamples(examples
|
|
153440
|
-
this._setExamples(examples
|
|
152986
|
+
value: function setExamples(examples) {
|
|
152987
|
+
this._setExamples(examples);
|
|
153441
152988
|
if (!("programId" in examples)) {
|
|
153442
152989
|
return;
|
|
153443
152990
|
}
|
|
@@ -153445,7 +152992,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153445
152992
|
try {
|
|
153446
152993
|
for(var _iterator = this.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
153447
152994
|
var child = _step.value;
|
|
153448
|
-
child.setExamples(examples
|
|
152995
|
+
child.setExamples(examples);
|
|
153449
152996
|
}
|
|
153450
152997
|
} catch (err) {
|
|
153451
152998
|
_didIteratorError = true;
|
|
@@ -153465,7 +153012,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153465
153012
|
},
|
|
153466
153013
|
{
|
|
153467
153014
|
key: "_setExamples",
|
|
153468
|
-
value: function _setExamples(examples
|
|
153015
|
+
value: function _setExamples(examples) {
|
|
153469
153016
|
var traces = [];
|
|
153470
153017
|
if ("programId" in examples && examples.programId === this.key.id) {
|
|
153471
153018
|
traces = examples.traces;
|
|
@@ -153474,7 +153021,6 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153474
153021
|
traces = examples;
|
|
153475
153022
|
}
|
|
153476
153023
|
if (traces) {
|
|
153477
|
-
this.examplesOptions = options;
|
|
153478
153024
|
var sig = this.signature;
|
|
153479
153025
|
var fields = _to_consumable_array(sig.getInputFields()).concat(_to_consumable_array(sig.getOutputFields()));
|
|
153480
153026
|
this.examples = traces.map(function(e) {
|
|
@@ -153484,7 +153030,7 @@ var AxProgramWithSignature = /*#__PURE__*/ function() {
|
|
|
153484
153030
|
for(var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
153485
153031
|
var f = _step.value;
|
|
153486
153032
|
var value = e[f.name];
|
|
153487
|
-
if (value
|
|
153033
|
+
if (value) {
|
|
153488
153034
|
validateValue(f, value);
|
|
153489
153035
|
res[f.name] = value;
|
|
153490
153036
|
}
|
|
@@ -153652,8 +153198,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153652
153198
|
_define_property(_assert_this_initialized(_this), "streamingFieldProcessors", []);
|
|
153653
153199
|
_define_property(_assert_this_initialized(_this), "values", {});
|
|
153654
153200
|
_define_property(_assert_this_initialized(_this), "excludeContentFromTrace", false);
|
|
153655
|
-
_define_property(_assert_this_initialized(_this), "thoughtFieldName", void 0);
|
|
153656
|
-
_define_property(_assert_this_initialized(_this), "logger", void 0);
|
|
153657
153201
|
_define_property(_assert_this_initialized(_this), "addAssert", function(fn, message) {
|
|
153658
153202
|
_this.asserts.push({
|
|
153659
153203
|
fn: fn,
|
|
@@ -153700,15 +153244,8 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153700
153244
|
_this.addFieldProcessorInternal(fieldName, fn, false);
|
|
153701
153245
|
});
|
|
153702
153246
|
_this.options = options;
|
|
153703
|
-
_this.logger = options === null || options === void 0 ? void 0 : options.logger;
|
|
153704
|
-
var _options_thoughtFieldName;
|
|
153705
|
-
_this.thoughtFieldName = (_options_thoughtFieldName = options === null || options === void 0 ? void 0 : options.thoughtFieldName) !== null && _options_thoughtFieldName !== void 0 ? _options_thoughtFieldName : "thought";
|
|
153706
|
-
var promptTemplateOptions = {
|
|
153707
|
-
functions: options === null || options === void 0 ? void 0 : options.functions,
|
|
153708
|
-
thoughtFieldName: _this.thoughtFieldName
|
|
153709
|
-
};
|
|
153710
153247
|
var _options_promptTemplate;
|
|
153711
|
-
_this.promptTemplate = new ((_options_promptTemplate = options === null || options === void 0 ? void 0 : options.promptTemplate) !== null && _options_promptTemplate !== void 0 ? _options_promptTemplate : AxPromptTemplate)(_this.signature,
|
|
153248
|
+
_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);
|
|
153712
153249
|
var _this_options_asserts;
|
|
153713
153250
|
_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 : [];
|
|
153714
153251
|
var _this_options_streamingAsserts;
|
|
@@ -153728,11 +153265,11 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153728
153265
|
var ai = param.ai, mem = param.mem, options = param.options, traceContext = param.traceContext, firstStep = param.firstStep;
|
|
153729
153266
|
var _this = this;
|
|
153730
153267
|
return _async_to_generator(function() {
|
|
153731
|
-
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget,
|
|
153268
|
+
var _functions_map, _this_options, _ref, sessionId, traceId, modelConfig, model, rateLimiter, stream, _functions, _functionCall, thinkingTokenBudget, _mem_history, chatPrompt, functions, functionCall, res;
|
|
153732
153269
|
return _ts_generator(this, function(_state) {
|
|
153733
153270
|
switch(_state.label){
|
|
153734
153271
|
case 0:
|
|
153735
|
-
_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
|
|
153272
|
+
_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;
|
|
153736
153273
|
chatPrompt = (_mem_history = mem === null || mem === void 0 ? void 0 : mem.history(sessionId)) !== null && _mem_history !== void 0 ? _mem_history : [];
|
|
153737
153274
|
if (chatPrompt.length === 0) {
|
|
153738
153275
|
throw new Error("No chat prompt found");
|
|
@@ -153759,9 +153296,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153759
153296
|
stream: stream,
|
|
153760
153297
|
debug: false,
|
|
153761
153298
|
thinkingTokenBudget: thinkingTokenBudget,
|
|
153762
|
-
|
|
153763
|
-
traceContext: traceContext,
|
|
153764
|
-
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal
|
|
153299
|
+
traceContext: traceContext
|
|
153765
153300
|
})
|
|
153766
153301
|
];
|
|
153767
153302
|
case 1:
|
|
@@ -153864,7 +153399,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153864
153399
|
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;
|
|
153865
153400
|
var _this = this;
|
|
153866
153401
|
return _wrap_async_generator(function() {
|
|
153867
|
-
var streamingValidation, functionCalls, xstate, content, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, v, result, _result_functionCalls__function, _result_functionCalls_, _result_functionCalls, skip,
|
|
153402
|
+
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;
|
|
153868
153403
|
return _ts_generator(this, function(_state) {
|
|
153869
153404
|
switch(_state.label){
|
|
153870
153405
|
case 0:
|
|
@@ -153936,7 +153471,9 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
153936
153471
|
];
|
|
153937
153472
|
return [
|
|
153938
153473
|
4,
|
|
153939
|
-
|
|
153474
|
+
{
|
|
153475
|
+
thought: result.thought
|
|
153476
|
+
}
|
|
153940
153477
|
];
|
|
153941
153478
|
case 5:
|
|
153942
153479
|
_state.sent();
|
|
@@ -154000,10 +153537,12 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154000
153537
|
3,
|
|
154001
153538
|
15
|
|
154002
153539
|
];
|
|
154003
|
-
_this.values
|
|
153540
|
+
_this.values.thought = (_this_values_thought = _this.values.thought) !== null && _this_values_thought !== void 0 ? _this_values_thought : "" + result.thought;
|
|
154004
153541
|
return [
|
|
154005
153542
|
4,
|
|
154006
|
-
|
|
153543
|
+
{
|
|
153544
|
+
thought: result.thought
|
|
153545
|
+
}
|
|
154007
153546
|
];
|
|
154008
153547
|
case 14:
|
|
154009
153548
|
_state.sent();
|
|
@@ -154132,14 +153671,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154132
153671
|
_state.sent();
|
|
154133
153672
|
_state.label = 34;
|
|
154134
153673
|
case 34:
|
|
154135
|
-
if (ai.getOptions().debug) {
|
|
154136
|
-
logger = ai.getLogger();
|
|
154137
|
-
logger("", {
|
|
154138
|
-
tags: [
|
|
154139
|
-
"responseEnd"
|
|
154140
|
-
]
|
|
154141
|
-
});
|
|
154142
|
-
}
|
|
154143
153674
|
return [
|
|
154144
153675
|
2
|
|
154145
153676
|
];
|
|
@@ -154217,7 +153748,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154217
153748
|
8
|
|
154218
153749
|
];
|
|
154219
153750
|
if (result.thought && result.thought.length > 0) {
|
|
154220
|
-
_this.values
|
|
153751
|
+
_this.values.thought = result.thought;
|
|
154221
153752
|
}
|
|
154222
153753
|
extractValues(_this.signature, _this.values, result.content);
|
|
154223
153754
|
return [
|
|
@@ -154311,7 +153842,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154311
153842
|
value: function _forward2(ai, values, options, span, traceContext) {
|
|
154312
153843
|
var _this = this;
|
|
154313
153844
|
return _wrap_async_generator(function() {
|
|
154314
|
-
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,
|
|
153845
|
+
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;
|
|
154315
153846
|
return _ts_generator(this, function(_state) {
|
|
154316
153847
|
switch(_state.label){
|
|
154317
153848
|
case 0:
|
|
@@ -154321,7 +153852,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154321
153852
|
switch(_state.label){
|
|
154322
153853
|
case 0:
|
|
154323
153854
|
_loop = function(errCount) {
|
|
154324
|
-
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue,
|
|
153855
|
+
var generator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, delta, err, lastMemItem, shouldContinue, e, errorFields, _errorFields_map_join, e1, _errorFields_map_join1;
|
|
154325
153856
|
return _ts_generator(this, function(_state) {
|
|
154326
153857
|
switch(_state.label){
|
|
154327
153858
|
case 0:
|
|
@@ -154439,12 +153970,7 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154439
153970
|
];
|
|
154440
153971
|
}
|
|
154441
153972
|
if (debug) {
|
|
154442
|
-
|
|
154443
|
-
logger("", {
|
|
154444
|
-
tags: [
|
|
154445
|
-
"responseEnd"
|
|
154446
|
-
]
|
|
154447
|
-
});
|
|
153973
|
+
process.stdout.write("\n");
|
|
154448
153974
|
}
|
|
154449
153975
|
return [
|
|
154450
153976
|
2,
|
|
@@ -154546,25 +154072,13 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154546
154072
|
};
|
|
154547
154073
|
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);
|
|
154548
154074
|
if ((options === null || options === void 0 ? void 0 : options.functions) && options.functions.length > 0) {
|
|
154549
|
-
|
|
154550
|
-
|
|
154551
|
-
functions: options.functions,
|
|
154552
|
-
thoughtFieldName: _this.thoughtFieldName
|
|
154553
|
-
};
|
|
154554
|
-
_this.promptTemplate = new promptTemplateClass(_this.signature, currentPromptTemplateOptions);
|
|
154555
|
-
}
|
|
154556
|
-
if (Array.isArray(values)) {
|
|
154557
|
-
prompt = _this.promptTemplate.render(values, {
|
|
154558
|
-
examples: _this.examples,
|
|
154559
|
-
demos: _this.demos
|
|
154560
|
-
});
|
|
154561
|
-
} else {
|
|
154562
|
-
prompt = _this.promptTemplate.render(values, {
|
|
154563
|
-
// Cast if necessary
|
|
154564
|
-
examples: _this.examples,
|
|
154565
|
-
demos: _this.demos
|
|
154566
|
-
});
|
|
154075
|
+
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;
|
|
154076
|
+
_this.promptTemplate = new promptTemplate(_this.signature, options.functions);
|
|
154567
154077
|
}
|
|
154078
|
+
prompt = _this.promptTemplate.render(values, {
|
|
154079
|
+
examples: _this.examples,
|
|
154080
|
+
demos: _this.demos
|
|
154081
|
+
});
|
|
154568
154082
|
mem.add(prompt, options === null || options === void 0 ? void 0 : options.sessionId);
|
|
154569
154083
|
n = 0;
|
|
154570
154084
|
_state.label = 1;
|
|
@@ -154665,8 +154179,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154665
154179
|
model: options.model
|
|
154666
154180
|
} : {}, (options === null || options === void 0 ? void 0 : options.thinkingTokenBudget) ? {
|
|
154667
154181
|
thinking_token_budget: options.thinkingTokenBudget
|
|
154668
|
-
} : {}, (options === null || options === void 0 ? void 0 : options.showThoughts) ? {
|
|
154669
|
-
show_thoughts: options.showThoughts
|
|
154670
154182
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxSteps) ? {
|
|
154671
154183
|
max_steps: options.maxSteps
|
|
154672
154184
|
} : {}, (options === null || options === void 0 ? void 0 : options.maxRetries) ? {
|
|
@@ -154854,12 +154366,6 @@ var AxGen = /*#__PURE__*/ function(AxProgramWithSignature) {
|
|
|
154854
154366
|
});
|
|
154855
154367
|
})();
|
|
154856
154368
|
}
|
|
154857
|
-
},
|
|
154858
|
-
{
|
|
154859
|
-
key: "setExamples",
|
|
154860
|
-
value: function setExamples(examples, options) {
|
|
154861
|
-
_get(_get_prototype_of(AxGen.prototype), "setExamples", this).call(this, examples, options);
|
|
154862
|
-
}
|
|
154863
154369
|
}
|
|
154864
154370
|
]);
|
|
154865
154371
|
return AxGen;
|
|
@@ -154915,32 +154421,13 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
|
|
|
154915
154421
|
var originalFunc = processedFunction.func;
|
|
154916
154422
|
processedFunction.func = function() {
|
|
154917
154423
|
var _ref = _async_to_generator(function(childArgs, funcOptions) {
|
|
154918
|
-
var
|
|
154424
|
+
var updatedChildArgs;
|
|
154919
154425
|
return _ts_generator(this, function(_state) {
|
|
154920
154426
|
switch(_state.label){
|
|
154921
154427
|
case 0:
|
|
154922
|
-
|
|
154923
|
-
if (Array.isArray(parentValues)) {
|
|
154924
|
-
lastUserMessage = parentValues.filter(function(msg) {
|
|
154925
|
-
return msg.role === "user";
|
|
154926
|
-
}).pop();
|
|
154927
|
-
if (lastUserMessage) {
|
|
154928
|
-
valuesToInject = pick(lastUserMessage.values, injectionKeys);
|
|
154929
|
-
}
|
|
154930
|
-
} else {
|
|
154931
|
-
valuesToInject = pick(parentValues, injectionKeys);
|
|
154932
|
-
}
|
|
154933
|
-
updatedChildArgs = _object_spread({}, childArgs, valuesToInject);
|
|
154428
|
+
updatedChildArgs = _object_spread({}, childArgs, pick(parentValues, injectionKeys));
|
|
154934
154429
|
if (options.debug && injectionKeys.length > 0) {
|
|
154935
|
-
|
|
154936
|
-
if (ai) {
|
|
154937
|
-
logger = ai.getLogger();
|
|
154938
|
-
logger("Function Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)), {
|
|
154939
|
-
tags: [
|
|
154940
|
-
"functionArg"
|
|
154941
|
-
]
|
|
154942
|
-
});
|
|
154943
|
-
}
|
|
154430
|
+
process.stdout.write("\nFunction Params: ".concat(JSON.stringify(updatedChildArgs, null, 2)));
|
|
154944
154431
|
}
|
|
154945
154432
|
return [
|
|
154946
154433
|
4,
|
|
@@ -155039,8 +154526,8 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
155039
154526
|
_create_class(AxAgent, [
|
|
155040
154527
|
{
|
|
155041
154528
|
key: "setExamples",
|
|
155042
|
-
value: function setExamples(examples
|
|
155043
|
-
this.program.setExamples(examples
|
|
154529
|
+
value: function setExamples(examples) {
|
|
154530
|
+
this.program.setExamples(examples);
|
|
155044
154531
|
}
|
|
155045
154532
|
},
|
|
155046
154533
|
{
|
|
@@ -155086,7 +154573,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
155086
154573
|
var _this = this;
|
|
155087
154574
|
var wrappedFunc = function() {
|
|
155088
154575
|
var _ref = _async_to_generator(function(valuesAndModel, options) {
|
|
155089
|
-
var model, values, _this_ai, ai, debug,
|
|
154576
|
+
var model, values, _this_ai, ai, debug, ret, sig, outFields, result;
|
|
155090
154577
|
return _ts_generator(this, function(_state) {
|
|
155091
154578
|
switch(_state.label){
|
|
155092
154579
|
case 0:
|
|
@@ -155099,12 +154586,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
155099
154586
|
}
|
|
155100
154587
|
debug = _this.getDebug(ai, options);
|
|
155101
154588
|
if (debug) {
|
|
155102
|
-
|
|
155103
|
-
logger("\uD83E\uDD16 Agent ".concat(_this.name, " starting..."), {
|
|
155104
|
-
tags: [
|
|
155105
|
-
"assistantStart"
|
|
155106
|
-
]
|
|
155107
|
-
});
|
|
154589
|
+
process.stdout.write("\n--- Agent Engaged: ".concat(_this.name, " ---\n"));
|
|
155108
154590
|
}
|
|
155109
154591
|
return [
|
|
155110
154592
|
4,
|
|
@@ -155115,12 +154597,7 @@ var AxAgent = /*#__PURE__*/ function() {
|
|
|
155115
154597
|
case 1:
|
|
155116
154598
|
ret = _state.sent();
|
|
155117
154599
|
if (debug) {
|
|
155118
|
-
|
|
155119
|
-
logger1("\uD83E\uDD16 Agent ".concat(_this.name, " completed."), {
|
|
155120
|
-
tags: [
|
|
155121
|
-
"assistantEnd"
|
|
155122
|
-
]
|
|
155123
|
-
});
|
|
154600
|
+
process.stdout.write("\n--- Agent Done: ".concat(_this.name, " ---\n"));
|
|
155124
154601
|
}
|
|
155125
154602
|
sig = _this.program.getSignature();
|
|
155126
154603
|
outFields = sig.getOutputFields();
|
|
@@ -155686,12 +155163,6 @@ function pick(obj, keys) {
|
|
|
155686
155163
|
value: function getOptions() {
|
|
155687
155164
|
return this.currentService.getOptions();
|
|
155688
155165
|
}
|
|
155689
|
-
},
|
|
155690
|
-
{
|
|
155691
|
-
key: "getLogger",
|
|
155692
|
-
value: function getLogger() {
|
|
155693
|
-
return this.currentService.getLogger();
|
|
155694
|
-
}
|
|
155695
155166
|
}
|
|
155696
155167
|
]);
|
|
155697
155168
|
return _AxBalancer;
|
|
@@ -155805,8 +155276,7 @@ var AxChainOfThought = /*#__PURE__*/ function(AxGen) {
|
|
|
155805
155276
|
sig.setOutputFields([
|
|
155806
155277
|
{
|
|
155807
155278
|
name: "reason",
|
|
155808
|
-
description: description
|
|
155809
|
-
isInternal: (options === null || options === void 0 ? void 0 : options.setVisibleReasoning) !== true
|
|
155279
|
+
description: description
|
|
155810
155280
|
}
|
|
155811
155281
|
].concat(_to_consumable_array(sig.getOutputFields())));
|
|
155812
155282
|
return _super.call(this, sig, options);
|
|
@@ -155821,8 +155291,10 @@ for(var i = 0; i < 256; ++i){
|
|
|
155821
155291
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
155822
155292
|
}
|
|
155823
155293
|
({
|
|
155824
|
-
randomUUID:
|
|
155294
|
+
randomUUID: require$$0$6.randomUUID
|
|
155825
155295
|
});
|
|
155296
|
+
// mcp/client.ts
|
|
155297
|
+
new ColorLog();
|
|
155826
155298
|
|
|
155827
155299
|
let DspService = class DspService {
|
|
155828
155300
|
async prepareFunctions(functions, context) {
|