supercompat 2.8.0 → 2.9.0
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 +105 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +105 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -165,6 +165,33 @@ function _object_spread_props(target, source) {
|
|
|
165
165
|
}
|
|
166
166
|
return target;
|
|
167
167
|
}
|
|
168
|
+
function _object_without_properties(source, excluded) {
|
|
169
|
+
if (source == null) return {};
|
|
170
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
171
|
+
var key, i;
|
|
172
|
+
if (Object.getOwnPropertySymbols) {
|
|
173
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
174
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
175
|
+
key = sourceSymbolKeys[i];
|
|
176
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
177
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
178
|
+
target[key] = source[key];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return target;
|
|
182
|
+
}
|
|
183
|
+
function _object_without_properties_loose(source, excluded) {
|
|
184
|
+
if (source == null) return {};
|
|
185
|
+
var target = {};
|
|
186
|
+
var sourceKeys = Object.keys(source);
|
|
187
|
+
var key, i;
|
|
188
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
189
|
+
key = sourceKeys[i];
|
|
190
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
191
|
+
target[key] = source[key];
|
|
192
|
+
}
|
|
193
|
+
return target;
|
|
194
|
+
}
|
|
168
195
|
function _sliced_to_array(arr, i) {
|
|
169
196
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
170
197
|
}
|
|
@@ -813,30 +840,88 @@ var azureOpenaiClientAdapter = function(param) {
|
|
|
813
840
|
}
|
|
814
841
|
};
|
|
815
842
|
};
|
|
843
|
+
// src/adapters/client/mistralClientAdapter/completions/serializeChunk.ts
|
|
844
|
+
var serializeDelta = function(_param) {
|
|
845
|
+
var toolCalls = _param.delta.toolCalls, rest = _object_without_properties(_param.delta, [
|
|
846
|
+
"toolCalls"
|
|
847
|
+
]);
|
|
848
|
+
return _object_spread({}, rest, toolCalls ? {
|
|
849
|
+
tool_calls: toolCalls
|
|
850
|
+
} : {});
|
|
851
|
+
};
|
|
852
|
+
var serializeChoice = function(_param) {
|
|
853
|
+
var _param_choice = _param.choice, finishReason = _param_choice.finishReason, delta = _param_choice.delta, rest = _object_without_properties(_param.choice, [
|
|
854
|
+
"finishReason",
|
|
855
|
+
"delta"
|
|
856
|
+
]);
|
|
857
|
+
return _object_spread_props(_object_spread({}, rest), {
|
|
858
|
+
finish_reason: finishReason !== null && finishReason !== void 0 ? finishReason : null,
|
|
859
|
+
delta: serializeDelta({
|
|
860
|
+
delta: delta
|
|
861
|
+
})
|
|
862
|
+
});
|
|
863
|
+
};
|
|
864
|
+
var serializeChunk = function(param) {
|
|
865
|
+
var chunk = param.chunk;
|
|
866
|
+
return _object_spread({}, chunk.data, chunk.data.choices ? {
|
|
867
|
+
choices: chunk.data.choices.map(function(choice) {
|
|
868
|
+
return serializeChoice({
|
|
869
|
+
choice: choice
|
|
870
|
+
});
|
|
871
|
+
})
|
|
872
|
+
} : {});
|
|
873
|
+
};
|
|
874
|
+
// src/adapters/client/mistralClientAdapter/completions/serializeBody.ts
|
|
875
|
+
var serializeMessage = function(_param) {
|
|
876
|
+
var _param_message = _param.message, // @ts-ignore-next-line
|
|
877
|
+
tool_calls = _param_message.tool_calls, // @ts-ignore-next-line
|
|
878
|
+
tool_call_id = _param_message.tool_call_id, rest = _object_without_properties(_param.message, [
|
|
879
|
+
"tool_calls",
|
|
880
|
+
"tool_call_id"
|
|
881
|
+
]);
|
|
882
|
+
return _object_spread({}, rest, tool_call_id ? {
|
|
883
|
+
toolCallId: tool_call_id
|
|
884
|
+
} : {}, tool_calls ? {
|
|
885
|
+
toolCalls: tool_calls
|
|
886
|
+
} : {});
|
|
887
|
+
};
|
|
888
|
+
var serializeBody = function(param) {
|
|
889
|
+
var body = param.body;
|
|
890
|
+
return _object_spread_props(_object_spread({}, body), {
|
|
891
|
+
messages: body.messages.map(function(message) {
|
|
892
|
+
return serializeMessage({
|
|
893
|
+
message: message
|
|
894
|
+
});
|
|
895
|
+
})
|
|
896
|
+
});
|
|
897
|
+
};
|
|
816
898
|
// src/adapters/client/mistralClientAdapter/completions/post.ts
|
|
817
899
|
var post3 = function(param) {
|
|
818
900
|
var mistral = param.mistral;
|
|
819
901
|
return /*#__PURE__*/ function() {
|
|
820
902
|
var _ref = _async_to_generator(function(_url, options) {
|
|
821
|
-
var body, response, stream, data, error;
|
|
903
|
+
var body, serializedBody, response, stream, data, error;
|
|
822
904
|
return _ts_generator(this, function(_state) {
|
|
823
905
|
switch(_state.label){
|
|
824
906
|
case 0:
|
|
825
907
|
body = JSON.parse(options.body);
|
|
908
|
+
serializedBody = serializeBody({
|
|
909
|
+
body: body
|
|
910
|
+
});
|
|
826
911
|
if (!body.stream) return [
|
|
827
912
|
3,
|
|
828
913
|
2
|
|
829
914
|
];
|
|
830
915
|
return [
|
|
831
916
|
4,
|
|
832
|
-
mistral.chat.stream(
|
|
917
|
+
mistral.chat.stream(serializedBody)
|
|
833
918
|
];
|
|
834
919
|
case 1:
|
|
835
920
|
response = _state.sent();
|
|
836
921
|
stream = new ReadableStream({
|
|
837
922
|
start: function start(controller) {
|
|
838
923
|
return _async_to_generator(function() {
|
|
839
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err;
|
|
924
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, serializedChunk, err;
|
|
840
925
|
return _ts_generator(this, function(_state) {
|
|
841
926
|
switch(_state.label){
|
|
842
927
|
case 0:
|
|
@@ -863,7 +948,10 @@ var post3 = function(param) {
|
|
|
863
948
|
];
|
|
864
949
|
_value = _step.value;
|
|
865
950
|
chunk = _value;
|
|
866
|
-
|
|
951
|
+
serializedChunk = serializeChunk({
|
|
952
|
+
chunk: chunk
|
|
953
|
+
});
|
|
954
|
+
controller.enqueue("data: ".concat(JSON.stringify(serializedChunk), "\n\n"));
|
|
867
955
|
_state.label = 4;
|
|
868
956
|
case 4:
|
|
869
957
|
_iteratorAbruptCompletion = false;
|
|
@@ -945,7 +1033,7 @@ var post3 = function(param) {
|
|
|
945
1033
|
]);
|
|
946
1034
|
return [
|
|
947
1035
|
4,
|
|
948
|
-
mistral.chat.complete(
|
|
1036
|
+
mistral.chat.complete(serializedBody)
|
|
949
1037
|
];
|
|
950
1038
|
case 3:
|
|
951
1039
|
data = _state.sent();
|
|
@@ -1277,7 +1365,7 @@ var serializeTools = function(param) {
|
|
|
1277
1365
|
});
|
|
1278
1366
|
};
|
|
1279
1367
|
// src/adapters/client/anthropicClientAdapter/completions/serializeMessages/serializeMessage.ts
|
|
1280
|
-
var
|
|
1368
|
+
var serializeMessage2 = function(param) {
|
|
1281
1369
|
var message = param.message;
|
|
1282
1370
|
if (message.role === "user") {
|
|
1283
1371
|
return {
|
|
@@ -1319,7 +1407,7 @@ var serializeMessage = function(param) {
|
|
|
1319
1407
|
var serializeMessages = function(param) {
|
|
1320
1408
|
var messages3 = param.messages;
|
|
1321
1409
|
return messages3.map(function(message) {
|
|
1322
|
-
return
|
|
1410
|
+
return serializeMessage2({
|
|
1323
1411
|
message: message
|
|
1324
1412
|
});
|
|
1325
1413
|
});
|
|
@@ -1645,7 +1733,7 @@ var serializeContent = function(param) {
|
|
|
1645
1733
|
return content2.text.value;
|
|
1646
1734
|
}).join("\n");
|
|
1647
1735
|
};
|
|
1648
|
-
var
|
|
1736
|
+
var serializeMessage3 = function(param) {
|
|
1649
1737
|
var message = param.message;
|
|
1650
1738
|
var _message_metadata;
|
|
1651
1739
|
var result = [
|
|
@@ -1700,7 +1788,7 @@ var messages = /*#__PURE__*/ function() {
|
|
|
1700
1788
|
_to_consumable_array.apply(void 0, [
|
|
1701
1789
|
flat.apply(void 0, [
|
|
1702
1790
|
_state.sent().map(function(message) {
|
|
1703
|
-
return
|
|
1791
|
+
return serializeMessage3({
|
|
1704
1792
|
message: message
|
|
1705
1793
|
});
|
|
1706
1794
|
})
|
|
@@ -1786,7 +1874,7 @@ var toolCallsData = function(param) {
|
|
|
1786
1874
|
var completionsRunAdapter = function() {
|
|
1787
1875
|
return /*#__PURE__*/ function() {
|
|
1788
1876
|
var _ref = _async_to_generator(function(param) {
|
|
1789
|
-
var clientAdapter, run2, onEvent2, getMessages2, client, opts, _tmp, providerResponse, e, _e_cause, _e_message, _e_cause_message, message, toolCallsRunStep, currentContent, currentToolCalls, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, choice, delta, _delta_content, err;
|
|
1877
|
+
var clientAdapter, run2, onEvent2, getMessages2, client, opts, _tmp, providerResponse, e, _e_cause, _e_message, _e_cause_message, message, toolCallsRunStep, currentContent, currentToolCalls, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_choices, choices, choice, delta, _delta_content, err;
|
|
1790
1878
|
return _ts_generator(this, function(_state) {
|
|
1791
1879
|
switch(_state.label){
|
|
1792
1880
|
case 0:
|
|
@@ -1936,7 +2024,8 @@ var completionsRunAdapter = function() {
|
|
|
1936
2024
|
];
|
|
1937
2025
|
_value = _step.value;
|
|
1938
2026
|
chunk = _value;
|
|
1939
|
-
|
|
2027
|
+
choices = (_chunk_choices = chunk.choices) !== null && _chunk_choices !== void 0 ? _chunk_choices : [];
|
|
2028
|
+
choice = choices[0];
|
|
1940
2029
|
if (!choice) return [
|
|
1941
2030
|
3,
|
|
1942
2031
|
13
|
|
@@ -2244,7 +2333,7 @@ var threads = function(param) {
|
|
|
2244
2333
|
// src/adapters/storage/prismaStorageAdapter/threads/messages/serializeMessage.ts
|
|
2245
2334
|
import dayjs4 from "dayjs";
|
|
2246
2335
|
import { assign as assign2 } from "radash";
|
|
2247
|
-
var
|
|
2336
|
+
var serializeMessage4 = function(param) {
|
|
2248
2337
|
var message = param.message;
|
|
2249
2338
|
var _message_metadata;
|
|
2250
2339
|
return {
|
|
@@ -2307,7 +2396,7 @@ var post7 = function(param) {
|
|
|
2307
2396
|
message = _state.sent();
|
|
2308
2397
|
return [
|
|
2309
2398
|
2,
|
|
2310
|
-
new Response(JSON.stringify(
|
|
2399
|
+
new Response(JSON.stringify(serializeMessage4({
|
|
2311
2400
|
message: message
|
|
2312
2401
|
})), {
|
|
2313
2402
|
status: 200,
|
|
@@ -2363,7 +2452,7 @@ var get = function(param) {
|
|
|
2363
2452
|
2,
|
|
2364
2453
|
new Response(JSON.stringify({
|
|
2365
2454
|
data: messages3.map(function(message) {
|
|
2366
|
-
return
|
|
2455
|
+
return serializeMessage4({
|
|
2367
2456
|
message: message
|
|
2368
2457
|
});
|
|
2369
2458
|
}),
|
|
@@ -2674,7 +2763,7 @@ var threadMessageCreated = /*#__PURE__*/ function() {
|
|
|
2674
2763
|
];
|
|
2675
2764
|
case 1:
|
|
2676
2765
|
message = _state.sent();
|
|
2677
|
-
serializedMessage =
|
|
2766
|
+
serializedMessage = serializeMessage4({
|
|
2678
2767
|
message: message
|
|
2679
2768
|
});
|
|
2680
2769
|
controller.enqueue(_object_spread_props(_object_spread({}, event), {
|
|
@@ -2843,7 +2932,7 @@ var getMessages = function(param) {
|
|
|
2843
2932
|
return [
|
|
2844
2933
|
2,
|
|
2845
2934
|
messages3.map(function(message) {
|
|
2846
|
-
return _object_spread_props(_object_spread({},
|
|
2935
|
+
return _object_spread_props(_object_spread({}, serializeMessage4({
|
|
2847
2936
|
message: message
|
|
2848
2937
|
})), {
|
|
2849
2938
|
run: message.run ? _object_spread_props(_object_spread({}, serializeRun({
|