supercompat 2.2.4 → 2.3.1
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/dist/index.cjs +92 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -974,11 +974,33 @@ var mistralClientAdapter = function(param) {
|
|
|
974
974
|
}
|
|
975
975
|
};
|
|
976
976
|
};
|
|
977
|
-
// src/
|
|
977
|
+
// src/lib/messages/alternatingMessages.ts
|
|
978
978
|
var agentSideRoles = [
|
|
979
979
|
"assistant",
|
|
980
980
|
"system"
|
|
981
981
|
];
|
|
982
|
+
var alternatingMessages = function(param) {
|
|
983
|
+
var messages3 = param.messages;
|
|
984
|
+
var result = [];
|
|
985
|
+
messages3.forEach(function(message, index) {
|
|
986
|
+
result.push(message);
|
|
987
|
+
var nextMessage = messages3[index + 1];
|
|
988
|
+
if (!nextMessage) return;
|
|
989
|
+
if (message.role === "user" && nextMessage.role === "user") {
|
|
990
|
+
result.push({
|
|
991
|
+
role: "assistant",
|
|
992
|
+
content: "-"
|
|
993
|
+
});
|
|
994
|
+
} else if (agentSideRoles.includes(message.role) && agentSideRoles.includes(nextMessage.role)) {
|
|
995
|
+
result.push({
|
|
996
|
+
role: "user",
|
|
997
|
+
content: "-"
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
return result;
|
|
1002
|
+
};
|
|
1003
|
+
// src/adapters/client/perplexityClientAdapter/completions/post.ts
|
|
982
1004
|
var post4 = function(param) {
|
|
983
1005
|
var perplexity = param.perplexity;
|
|
984
1006
|
return function() {
|
|
@@ -988,22 +1010,8 @@ var post4 = function(param) {
|
|
|
988
1010
|
switch(_state.label){
|
|
989
1011
|
case 0:
|
|
990
1012
|
body = JSON.parse(options.body);
|
|
991
|
-
messages3 =
|
|
992
|
-
|
|
993
|
-
messages3.push(message);
|
|
994
|
-
var nextMessage = body.messages[index + 1];
|
|
995
|
-
if (!nextMessage) return;
|
|
996
|
-
if (message.role === "user" && nextMessage.role === "user") {
|
|
997
|
-
messages3.push({
|
|
998
|
-
role: "assistant",
|
|
999
|
-
content: ""
|
|
1000
|
-
});
|
|
1001
|
-
} else if (agentSideRoles.includes(message.role) && agentSideRoles.includes(nextMessage.role)) {
|
|
1002
|
-
messages3.push({
|
|
1003
|
-
role: "user",
|
|
1004
|
-
content: ""
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1013
|
+
messages3 = alternatingMessages({
|
|
1014
|
+
messages: body.messages
|
|
1007
1015
|
});
|
|
1008
1016
|
if (!body.stream) return [
|
|
1009
1017
|
3,
|
|
@@ -1011,7 +1019,9 @@ var post4 = function(param) {
|
|
|
1011
1019
|
];
|
|
1012
1020
|
return [
|
|
1013
1021
|
4,
|
|
1014
|
-
perplexity.chat.completions.create(body)
|
|
1022
|
+
perplexity.chat.completions.create(_object_spread_props(_object_spread({}, body), {
|
|
1023
|
+
messages: messages3
|
|
1024
|
+
}))
|
|
1015
1025
|
];
|
|
1016
1026
|
case 1:
|
|
1017
1027
|
response = _state.sent();
|
|
@@ -1189,7 +1199,34 @@ var perplexityClientAdapter = function(param) {
|
|
|
1189
1199
|
};
|
|
1190
1200
|
};
|
|
1191
1201
|
// src/adapters/client/anthropicClientAdapter/completions/post.ts
|
|
1192
|
-
import { uid, fork, omit, isEmpty } from "radash";
|
|
1202
|
+
import { uid, fork, omit, isEmpty as isEmpty2 } from "radash";
|
|
1203
|
+
// src/lib/messages/nonEmptyMessages.ts
|
|
1204
|
+
import { isEmpty } from "radash";
|
|
1205
|
+
var nonEmptyMessages = function(param) {
|
|
1206
|
+
var messages3 = param.messages;
|
|
1207
|
+
var result = [];
|
|
1208
|
+
messages3.forEach(function(message) {
|
|
1209
|
+
return result.push(_object_spread_props(_object_spread({}, message), {
|
|
1210
|
+
content: isEmpty(message.content) ? "-" : message.content
|
|
1211
|
+
}));
|
|
1212
|
+
});
|
|
1213
|
+
return result;
|
|
1214
|
+
};
|
|
1215
|
+
// src/lib/messages/firstUserMessages.ts
|
|
1216
|
+
var firstUserMessages = function(param) {
|
|
1217
|
+
var messages3 = param.messages;
|
|
1218
|
+
var firstMessage = messages3[0];
|
|
1219
|
+
if (!firstMessage) return messages3;
|
|
1220
|
+
if (firstMessage.role !== "user") {
|
|
1221
|
+
return [
|
|
1222
|
+
{
|
|
1223
|
+
role: "user",
|
|
1224
|
+
content: "-"
|
|
1225
|
+
}
|
|
1226
|
+
].concat(_to_consumable_array(messages3));
|
|
1227
|
+
}
|
|
1228
|
+
return messages3;
|
|
1229
|
+
};
|
|
1193
1230
|
// src/adapters/client/anthropicClientAdapter/completions/serializeTools.ts
|
|
1194
1231
|
var serializeTools = function(param) {
|
|
1195
1232
|
var tools = param.tools;
|
|
@@ -1257,7 +1294,7 @@ var post5 = function(param) {
|
|
|
1257
1294
|
var anthropic = param.anthropic;
|
|
1258
1295
|
return function() {
|
|
1259
1296
|
var _ref = _async_to_generator(function(_url, options) {
|
|
1260
|
-
var body, messages3, _fork, systemMessages, otherMessages, system, resultOptions, response, stream, data, error;
|
|
1297
|
+
var body, messages3, _fork, systemMessages, otherMessages, system, chatMessages, resultOptions, response, stream, data, error;
|
|
1261
1298
|
return _ts_generator(this, function(_state) {
|
|
1262
1299
|
switch(_state.label){
|
|
1263
1300
|
case 0:
|
|
@@ -1269,19 +1306,20 @@ var post5 = function(param) {
|
|
|
1269
1306
|
system = systemMessages.map(function(message) {
|
|
1270
1307
|
return message.content;
|
|
1271
1308
|
}).join("\n");
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1309
|
+
chatMessages = nonEmptyMessages({
|
|
1310
|
+
messages: firstUserMessages({
|
|
1311
|
+
messages: alternatingMessages({
|
|
1312
|
+
messages: otherMessages
|
|
1313
|
+
})
|
|
1314
|
+
})
|
|
1315
|
+
});
|
|
1278
1316
|
resultOptions = _object_spread_props(_object_spread({}, omit(body, [
|
|
1279
1317
|
"response_format"
|
|
1280
1318
|
])), {
|
|
1281
|
-
stream: body.stream ?
|
|
1319
|
+
stream: body.stream ? isEmpty2(body.tools) : false,
|
|
1282
1320
|
system: system,
|
|
1283
1321
|
messages: serializeMessages({
|
|
1284
|
-
messages:
|
|
1322
|
+
messages: chatMessages
|
|
1285
1323
|
}),
|
|
1286
1324
|
max_tokens: 4096,
|
|
1287
1325
|
tools: serializeTools({
|
|
@@ -1539,7 +1577,7 @@ var anthropicClientAdapter = function(param) {
|
|
|
1539
1577
|
};
|
|
1540
1578
|
// src/adapters/run/completionsRunAdapter/index.ts
|
|
1541
1579
|
import _ from "lodash";
|
|
1542
|
-
import { uid as uid2, omit as omit2, isEmpty as
|
|
1580
|
+
import { uid as uid2, omit as omit2, isEmpty as isEmpty3 } from "radash";
|
|
1543
1581
|
import dayjs from "dayjs";
|
|
1544
1582
|
// src/adapters/run/completionsRunAdapter/messages/index.ts
|
|
1545
1583
|
import { flat } from "radash";
|
|
@@ -1741,7 +1779,7 @@ var completionsRunAdapter = function() {
|
|
|
1741
1779
|
case 1:
|
|
1742
1780
|
opts = _object_spread.apply(void 0, [
|
|
1743
1781
|
(_tmp.messages = _state.sent(), _tmp.model = run2.model, _tmp.stream = true, _tmp.response_format = run2.response_format, _tmp),
|
|
1744
|
-
|
|
1782
|
+
isEmpty3(run2.tools) ? {} : {
|
|
1745
1783
|
tools: run2.tools
|
|
1746
1784
|
}
|
|
1747
1785
|
]);
|
|
@@ -2027,7 +2065,7 @@ var completionsRunAdapter = function() {
|
|
|
2027
2065
|
];
|
|
2028
2066
|
case 22:
|
|
2029
2067
|
message = _state.sent();
|
|
2030
|
-
if (
|
|
2068
|
+
if (isEmpty3(message.toolCalls)) {
|
|
2031
2069
|
return [
|
|
2032
2070
|
2,
|
|
2033
2071
|
onEvent2({
|