deep-chat-dev 9.0.0 → 9.0.2
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/custom-elements.json +402 -327
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.d.ts +2 -0
- package/dist/deepChat.d.ts.map +1 -1
- package/dist/deepChat.js +338 -286
- package/dist/services/assemblyAI/assemblyAIAudioIO.d.ts +2 -2
- package/dist/services/assemblyAI/assemblyAIAudioIO.d.ts.map +1 -1
- package/dist/services/azure/azureSpeechToTextIO.d.ts +2 -2
- package/dist/services/azure/azureSpeechToTextIO.d.ts.map +1 -1
- package/dist/services/azure/azureTextToSpeechIO.d.ts +2 -2
- package/dist/services/azure/azureTextToSpeechIO.d.ts.map +1 -1
- package/dist/services/azure/azureTranslationIO.d.ts +2 -2
- package/dist/services/azure/azureTranslationIO.d.ts.map +1 -1
- package/dist/services/cohere/cohereChatIO.d.ts +2 -2
- package/dist/services/cohere/cohereChatIO.d.ts.map +1 -1
- package/dist/services/cohere/cohereSummarizationIO.d.ts +2 -2
- package/dist/services/cohere/cohereSummarizationIO.d.ts.map +1 -1
- package/dist/services/cohere/cohereTextGenerationIO.d.ts +2 -2
- package/dist/services/cohere/cohereTextGenerationIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceConversationIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceConversationIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceFillMaskIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceFillMaskIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceQuestionAnswerIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceQuestionAnswerIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceSummarizationIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceSummarizationIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceTextGenerationIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceTextGenerationIO.d.ts.map +1 -1
- package/dist/services/huggingFace/huggingFaceTranslationIO.d.ts +2 -2
- package/dist/services/huggingFace/huggingFaceTranslationIO.d.ts.map +1 -1
- package/dist/services/openAI/openAIAudioIO.d.ts +2 -2
- package/dist/services/openAI/openAIAudioIO.d.ts.map +1 -1
- package/dist/services/openAI/openAIChatIO.d.ts +2 -2
- package/dist/services/openAI/openAIChatIO.d.ts.map +1 -1
- package/dist/services/openAI/openAICompletionsIO.d.ts +2 -2
- package/dist/services/openAI/openAICompletionsIO.d.ts.map +1 -1
- package/dist/services/openAI/openAIImagesIO.d.ts +2 -2
- package/dist/services/openAI/openAIImagesIO.d.ts.map +1 -1
- package/dist/services/serviceIO.d.ts +4 -4
- package/dist/services/serviceIO.d.ts.map +1 -1
- package/dist/services/stabilityAI/stabilityAIImageToImageIO.d.ts +2 -2
- package/dist/services/stabilityAI/stabilityAIImageToImageIO.d.ts.map +1 -1
- package/dist/services/stabilityAI/stabilityAIImageToImageMaskingIO.d.ts +2 -2
- package/dist/services/stabilityAI/stabilityAIImageToImageMaskingIO.d.ts.map +1 -1
- package/dist/services/stabilityAI/stabilityAIImageToImageUpscaleIO.d.ts +2 -2
- package/dist/services/stabilityAI/stabilityAIImageToImageUpscaleIO.d.ts.map +1 -1
- package/dist/services/stabilityAI/stabilityAITextToImageIO.d.ts +2 -2
- package/dist/services/stabilityAI/stabilityAITextToImageIO.d.ts.map +1 -1
- package/dist/services/utils/baseServiceIO.d.ts +2 -3
- package/dist/services/utils/baseServiceIO.d.ts.map +1 -1
- package/dist/types/demo.d.ts +2 -2
- package/dist/types/demo.d.ts.map +1 -1
- package/dist/types/interceptors.d.ts +2 -2
- package/dist/types/interceptors.d.ts.map +1 -1
- package/dist/types/request.d.ts +2 -2
- package/dist/types/request.d.ts.map +1 -1
- package/dist/types/{result.d.ts → response.d.ts} +3 -2
- package/dist/types/response.d.ts.map +1 -0
- package/dist/utils/HTTP/HTTPRequest.d.ts.map +1 -1
- package/dist/utils/HTTP/customRequest.d.ts +2 -4
- package/dist/utils/HTTP/customRequest.d.ts.map +1 -1
- package/dist/utils/HTTP/websocket.d.ts +4 -3
- package/dist/utils/HTTP/websocket.d.ts.map +1 -1
- package/dist/utils/demo/demo.d.ts.map +1 -1
- package/dist/utils/events/fireEvents.d.ts +1 -0
- package/dist/utils/events/fireEvents.d.ts.map +1 -1
- package/dist/views/chat/input/buttons/submit/submitButton.d.ts.map +1 -1
- package/dist/views/chat/introPanel/introPanel.d.ts +1 -0
- package/dist/views/chat/introPanel/introPanel.d.ts.map +1 -1
- package/dist/views/chat/messages/fileMessages.d.ts.map +1 -1
- package/dist/views/chat/messages/messages.d.ts +6 -2
- package/dist/views/chat/messages/messages.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/customService.d.ts +0 -6
- package/dist/types/customService.d.ts.map +0 -1
- package/dist/types/result.d.ts.map +0 -1
package/dist/deepChat.js
CHANGED
@@ -316,13 +316,13 @@ function getInterceptorMessage(r) {
|
|
316
316
|
function getInvalidResponseMessage(r, e, t, n) {
|
317
317
|
var s = "\n".concat(capitalizeFirstLetter(e), " message: ").concat(JSON.stringify(r), " \n"),
|
318
318
|
o = t ? "".concat(capitalizeFirstLetter(e), " message after interceptor: ").concat(getInterceptorMessage(n), " \n") : "";
|
319
|
-
return "".concat(s + o, "Make sure the ").concat(e, " message is using the
|
319
|
+
return "".concat(s + o, "Make sure the ").concat(e, " message is using the Response format: https://deepchat.dev/docs/connect/#Response \n You can also augment it using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor");
|
320
320
|
}
|
321
321
|
var ErrorMessages = {
|
322
322
|
INVALID_KEY: "Invalid API Key",
|
323
323
|
CONNECTION_FAILED: "Failed to connect",
|
324
324
|
INVALID_RESPONSE: getInvalidResponseMessage,
|
325
|
-
INVALID_STREAM_RESPONSE: "Make sure the events are using the
|
325
|
+
INVALID_STREAM_RESPONSE: "Make sure the events are using the Response format: https://deepchat.dev/docs/connect/#Response \nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor"
|
326
326
|
},
|
327
327
|
_RequestUtils = /*#__PURE__*/function () {
|
328
328
|
function D() {
|
@@ -539,42 +539,42 @@ function fetchEventSource(r, e) {
|
|
539
539
|
b.abort(), document.hidden || I();
|
540
540
|
}
|
541
541
|
c || document.addEventListener("visibilitychange", m);
|
542
|
-
var
|
543
|
-
|
542
|
+
var g = DefaultRetryInterval,
|
543
|
+
v = 0;
|
544
544
|
function y() {
|
545
|
-
document.removeEventListener("visibilitychange", m), window.clearTimeout(
|
545
|
+
document.removeEventListener("visibilitychange", m), window.clearTimeout(v), b.abort();
|
546
546
|
}
|
547
547
|
t == null || t.addEventListener("abort", function () {
|
548
548
|
y(), h();
|
549
549
|
});
|
550
|
-
var
|
551
|
-
|
550
|
+
var _ = u !== null && u !== void 0 ? u : window.fetch,
|
551
|
+
S = s !== null && s !== void 0 ? s : defaultOnOpen;
|
552
552
|
function I() {
|
553
553
|
return _I.apply(this, arguments);
|
554
554
|
}
|
555
555
|
function _I() {
|
556
556
|
_I = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
557
|
-
var R, w,
|
557
|
+
var R, w, x;
|
558
558
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
559
559
|
while (1) switch (_context3.prev = _context3.next) {
|
560
560
|
case 0:
|
561
561
|
b = new AbortController();
|
562
562
|
_context3.prev = 1;
|
563
563
|
_context3.next = 4;
|
564
|
-
return
|
564
|
+
return _(r, Object.assign(Object.assign({}, d), {
|
565
565
|
headers: f,
|
566
566
|
signal: b.signal
|
567
567
|
}));
|
568
568
|
case 4:
|
569
569
|
w = _context3.sent;
|
570
570
|
_context3.next = 7;
|
571
|
-
return
|
571
|
+
return S(w);
|
572
572
|
case 7:
|
573
573
|
_context3.next = 9;
|
574
|
-
return getBytes(w.body, getLines(getMessages(function (
|
575
|
-
|
576
|
-
}, function (
|
577
|
-
|
574
|
+
return getBytes(w.body, getLines(getMessages(function (x) {
|
575
|
+
x ? f[LastEventId] = x : delete f[LastEventId];
|
576
|
+
}, function (x) {
|
577
|
+
g = x;
|
578
578
|
}, o)));
|
579
579
|
case 9:
|
580
580
|
a == null || a();
|
@@ -586,10 +586,10 @@ function fetchEventSource(r, e) {
|
|
586
586
|
_context3.prev = 14;
|
587
587
|
_context3.t0 = _context3["catch"](1);
|
588
588
|
if (!b.signal.aborted) try {
|
589
|
-
|
590
|
-
window.clearTimeout(
|
591
|
-
} catch (
|
592
|
-
y(), p(
|
589
|
+
x = (R = l == null ? void 0 : l(_context3.t0)) !== null && R !== void 0 ? R : g;
|
590
|
+
window.clearTimeout(v), v = window.setTimeout(I, x);
|
591
|
+
} catch (x) {
|
592
|
+
y(), p(x);
|
593
593
|
}
|
594
594
|
case 17:
|
595
595
|
case "end":
|
@@ -640,9 +640,7 @@ var _Demo = /*#__PURE__*/function () {
|
|
640
640
|
key: "getResponse",
|
641
641
|
value: function getResponse(e) {
|
642
642
|
return e.customDemoResponse ? C.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
|
643
|
-
|
644
|
-
text: C.generateResponse(e)
|
645
|
-
}
|
643
|
+
text: C.generateResponse(e)
|
646
644
|
};
|
647
645
|
}
|
648
646
|
// timeout is used to simulate a timeout for a response to come back
|
@@ -666,7 +664,7 @@ var _Demo = /*#__PURE__*/function () {
|
|
666
664
|
_context4.t0 = s;
|
667
665
|
case 5:
|
668
666
|
o = _context4.t0;
|
669
|
-
o.error ? e.addNewErrorMessage("service", o.error) :
|
667
|
+
o.error ? e.addNewErrorMessage("service", o.error) : e.addNewMessage(o, !0, !0), t();
|
670
668
|
case 7:
|
671
669
|
case "end":
|
672
670
|
return _context4.stop();
|
@@ -679,8 +677,8 @@ var _Demo = /*#__PURE__*/function () {
|
|
679
677
|
key: "requestStream",
|
680
678
|
value: function requestStream(e, t) {
|
681
679
|
setTimeout(function () {
|
682
|
-
var s
|
683
|
-
var n = (
|
680
|
+
var s;
|
681
|
+
var n = (s = C.getResponse(e)) == null ? void 0 : s.text;
|
684
682
|
Stream.simulate(e, t, n);
|
685
683
|
}, 400);
|
686
684
|
}
|
@@ -702,7 +700,7 @@ var Stream = /*#__PURE__*/function () {
|
|
702
700
|
f,
|
703
701
|
b,
|
704
702
|
m,
|
705
|
-
|
703
|
+
g,
|
706
704
|
o,
|
707
705
|
_yield$RequestUtils$p,
|
708
706
|
a,
|
@@ -747,24 +745,24 @@ var Stream = /*#__PURE__*/function () {
|
|
747
745
|
case 16:
|
748
746
|
p = null;
|
749
747
|
fetchEventSource(((m = e.requestSettings) == null ? void 0 : m.url) || e.url || "", {
|
750
|
-
method: ((
|
748
|
+
method: ((g = e.requestSettings) == null ? void 0 : g.method) || "POST",
|
751
749
|
headers: l,
|
752
750
|
body: s ? JSON.stringify(a) : a,
|
753
751
|
openWhenHidden: !0,
|
754
752
|
// keep stream open when browser tab not open
|
755
|
-
onopen: function onopen(
|
753
|
+
onopen: function onopen(v) {
|
756
754
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
757
755
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
758
756
|
while (1) switch (_context5.prev = _context5.next) {
|
759
757
|
case 0:
|
760
|
-
if (!
|
758
|
+
if (!v.ok) {
|
761
759
|
_context5.next = 2;
|
762
760
|
break;
|
763
761
|
}
|
764
762
|
return _context5.abrupt("return", (p = n.addNewStreamedMessage(), u()));
|
765
763
|
case 2:
|
766
764
|
_context5.next = 4;
|
767
|
-
return RequestUtils.processResponseByType(
|
765
|
+
return RequestUtils.processResponseByType(v);
|
768
766
|
case 4:
|
769
767
|
throw _context5.sent;
|
770
768
|
case 5:
|
@@ -774,30 +772,30 @@ var Stream = /*#__PURE__*/function () {
|
|
774
772
|
}, _callee5);
|
775
773
|
}))();
|
776
774
|
},
|
777
|
-
onmessage: function onmessage(
|
775
|
+
onmessage: function onmessage(v) {
|
778
776
|
var y;
|
779
|
-
if (JSON.stringify(
|
780
|
-
var
|
781
|
-
(y = e.extractResultData) == null || y.call(e,
|
782
|
-
(
|
783
|
-
})["catch"](function (
|
784
|
-
return RequestUtils.displayError(n,
|
777
|
+
if (JSON.stringify(v.data) !== JSON.stringify("[DONE]")) {
|
778
|
+
var _ = JSON.parse(v.data);
|
779
|
+
(y = e.extractResultData) == null || y.call(e, _).then(function (S) {
|
780
|
+
(S == null ? void 0 : S.text) === void 0 ? console.error("Response data: ".concat(v.data, " \n ").concat(ErrorMessages.INVALID_STREAM_RESPONSE)) : p && n.updateStreamedMessage(S.text, p);
|
781
|
+
})["catch"](function (S) {
|
782
|
+
return RequestUtils.displayError(n, S);
|
785
783
|
});
|
786
784
|
}
|
787
785
|
},
|
788
|
-
onerror: function onerror(
|
789
|
-
throw d(),
|
786
|
+
onerror: function onerror(v) {
|
787
|
+
throw d(), v;
|
790
788
|
},
|
791
789
|
onclose: function onclose() {
|
792
790
|
n.finaliseStreamedMessage(), d();
|
793
791
|
},
|
794
792
|
signal: h.signal
|
795
|
-
})["catch"](function (
|
793
|
+
})["catch"](function (v) {
|
796
794
|
var y;
|
797
|
-
(y = e.extractResultData) == null || y.call(e,
|
798
|
-
RequestUtils.displayError(n,
|
799
|
-
})["catch"](function (
|
800
|
-
RequestUtils.displayError(n,
|
795
|
+
(y = e.extractResultData) == null || y.call(e, v).then(function () {
|
796
|
+
RequestUtils.displayError(n, v);
|
797
|
+
})["catch"](function (_) {
|
798
|
+
RequestUtils.displayError(n, _);
|
801
799
|
});
|
802
800
|
});
|
803
801
|
case 18:
|
@@ -854,17 +852,15 @@ var CustomRequest = /*#__PURE__*/function () {
|
|
854
852
|
}
|
855
853
|
_createClass(CustomRequest, null, [{
|
856
854
|
key: "request",
|
857
|
-
value:
|
858
|
-
|
859
|
-
|
860
|
-
var o;
|
855
|
+
value: function () {
|
856
|
+
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(e, t, n) {
|
857
|
+
var s, o;
|
861
858
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
862
859
|
while (1) switch (_context8.prev = _context8.next) {
|
863
860
|
case 0:
|
864
|
-
o = e.
|
865
|
-
s(t).then( /*#__PURE__*/function () {
|
861
|
+
(o = (s = e.requestSettings).handler) == null || o.call(s, t).then( /*#__PURE__*/function () {
|
866
862
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(a) {
|
867
|
-
var l;
|
863
|
+
var u, d, l, c;
|
868
864
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
869
865
|
while (1) switch (_context7.prev = _context7.next) {
|
870
866
|
case 0:
|
@@ -875,35 +871,46 @@ var CustomRequest = /*#__PURE__*/function () {
|
|
875
871
|
return _context7.abrupt("return");
|
876
872
|
case 2:
|
877
873
|
_context7.next = 4;
|
878
|
-
return e.
|
874
|
+
return (d = (u = e.deepChat).responseInterceptor) == null ? void 0 : d.call(u, a);
|
879
875
|
case 4:
|
880
|
-
|
881
|
-
if (
|
876
|
+
_context7.t0 = _context7.sent;
|
877
|
+
if (_context7.t0) {
|
882
878
|
_context7.next = 7;
|
883
879
|
break;
|
884
880
|
}
|
885
|
-
|
881
|
+
_context7.t0 = a;
|
886
882
|
case 7:
|
887
|
-
|
888
|
-
|
883
|
+
l = _context7.t0;
|
884
|
+
_context7.next = 10;
|
885
|
+
return e.extractResultData(l);
|
886
|
+
case 10:
|
887
|
+
c = _context7.sent;
|
888
|
+
if (!(!c || _typeof(c) != "object")) {
|
889
|
+
_context7.next = 13;
|
890
|
+
break;
|
891
|
+
}
|
892
|
+
throw Error(ErrorMessages.INVALID_RESPONSE(a, "response", !!e.deepChat.responseInterceptor, c));
|
893
|
+
case 13:
|
894
|
+
e.deepChat.stream && c.text ? Stream.simulate(n, e.streamHandlers, c.text) : (n.addNewMessage(c, !0, !0), e.completionsHandlers.onFinish());
|
895
|
+
case 14:
|
889
896
|
case "end":
|
890
897
|
return _context7.stop();
|
891
898
|
}
|
892
899
|
}, _callee7);
|
893
900
|
}));
|
894
|
-
return function (
|
901
|
+
return function (_x14) {
|
895
902
|
return _ref2.apply(this, arguments);
|
896
903
|
};
|
897
904
|
}())["catch"](function (a) {
|
898
|
-
RequestUtils.displayError(n, a),
|
905
|
+
RequestUtils.displayError(n, a), e.completionsHandlers.onFinish();
|
899
906
|
});
|
900
|
-
case
|
907
|
+
case 1:
|
901
908
|
case "end":
|
902
909
|
return _context8.stop();
|
903
910
|
}
|
904
911
|
}, _callee8);
|
905
912
|
}));
|
906
|
-
function request(_x11, _x12, _x13
|
913
|
+
function request(_x11, _x12, _x13) {
|
907
914
|
return _request2.apply(this, arguments);
|
908
915
|
}
|
909
916
|
return request;
|
@@ -925,6 +932,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
925
932
|
p,
|
926
933
|
f,
|
927
934
|
b,
|
935
|
+
m,
|
928
936
|
o,
|
929
937
|
_yield$RequestUtils$p2,
|
930
938
|
a,
|
@@ -937,48 +945,48 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
937
945
|
while (1) switch (_context10.prev = _context10.next) {
|
938
946
|
case 0:
|
939
947
|
s = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : !0;
|
940
|
-
if (!e.requestSettings.handler) {
|
941
|
-
_context10.next = 3;
|
942
|
-
break;
|
943
|
-
}
|
944
|
-
return _context10.abrupt("return", CustomRequest.request(e, t, n, e.requestSettings.handler));
|
945
|
-
case 3:
|
946
948
|
o = {
|
947
949
|
body: t,
|
948
950
|
headers: (h = e.requestSettings) == null ? void 0 : h.headers
|
949
951
|
};
|
950
|
-
_context10.next =
|
952
|
+
_context10.next = 4;
|
951
953
|
return RequestUtils.processResponseInterceptor(e.deepChat, o);
|
952
|
-
case
|
954
|
+
case 4:
|
953
955
|
_yield$RequestUtils$p2 = _context10.sent;
|
954
956
|
a = _yield$RequestUtils$p2.body;
|
955
957
|
l = _yield$RequestUtils$p2.headers;
|
956
958
|
c = _yield$RequestUtils$p2.error;
|
957
959
|
u = e.completionsHandlers.onFinish;
|
958
960
|
if (!c) {
|
959
|
-
_context10.next =
|
961
|
+
_context10.next = 11;
|
960
962
|
break;
|
961
963
|
}
|
962
964
|
return _context10.abrupt("return", HTTPRequest.onInterceptorError(n, c, u));
|
965
|
+
case 11:
|
966
|
+
if (!((p = e.requestSettings) != null && p.handler)) {
|
967
|
+
_context10.next = 13;
|
968
|
+
break;
|
969
|
+
}
|
970
|
+
return _context10.abrupt("return", CustomRequest.request(e, a, n));
|
963
971
|
case 13:
|
964
|
-
if (!(((
|
972
|
+
if (!(((f = e.requestSettings) == null ? void 0 : f.url) === Demo.URL)) {
|
965
973
|
_context10.next = 15;
|
966
974
|
break;
|
967
975
|
}
|
968
976
|
return _context10.abrupt("return", Demo.request(n, u, e.deepChat.responseInterceptor));
|
969
977
|
case 15:
|
970
978
|
d = !0;
|
971
|
-
fetch(((
|
972
|
-
method: ((
|
979
|
+
fetch(((b = e.requestSettings) == null ? void 0 : b.url) || e.url || "", {
|
980
|
+
method: ((m = e.requestSettings) == null ? void 0 : m.method) || "POST",
|
973
981
|
headers: l,
|
974
982
|
body: s ? JSON.stringify(a) : a
|
975
|
-
}).then(function (
|
976
|
-
return d = !!
|
977
|
-
}).then(function (
|
978
|
-
return RequestUtils.processResponseByType(
|
983
|
+
}).then(function (g) {
|
984
|
+
return d = !!g.ok, g;
|
985
|
+
}).then(function (g) {
|
986
|
+
return RequestUtils.processResponseByType(g);
|
979
987
|
}).then( /*#__PURE__*/function () {
|
980
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(
|
981
|
-
var
|
988
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(g) {
|
989
|
+
var _, S, v, y;
|
982
990
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
983
991
|
while (1) switch (_context9.prev = _context9.next) {
|
984
992
|
case 0:
|
@@ -989,44 +997,44 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
989
997
|
return _context9.abrupt("return");
|
990
998
|
case 2:
|
991
999
|
_context9.next = 4;
|
992
|
-
return (
|
1000
|
+
return (S = (_ = e.deepChat).responseInterceptor) == null ? void 0 : S.call(_, g);
|
993
1001
|
case 4:
|
994
1002
|
_context9.t0 = _context9.sent;
|
995
1003
|
if (_context9.t0) {
|
996
1004
|
_context9.next = 7;
|
997
1005
|
break;
|
998
1006
|
}
|
999
|
-
_context9.t0 =
|
1007
|
+
_context9.t0 = g;
|
1000
1008
|
case 7:
|
1001
1009
|
v = _context9.t0;
|
1002
1010
|
_context9.next = 10;
|
1003
1011
|
return e.extractResultData(v);
|
1004
1012
|
case 10:
|
1005
|
-
|
1013
|
+
y = _context9.sent;
|
1006
1014
|
if (d) {
|
1007
1015
|
_context9.next = 13;
|
1008
1016
|
break;
|
1009
1017
|
}
|
1010
|
-
throw
|
1018
|
+
throw g;
|
1011
1019
|
case 13:
|
1012
|
-
if (!(!
|
1020
|
+
if (!(!y || _typeof(y) != "object")) {
|
1013
1021
|
_context9.next = 15;
|
1014
1022
|
break;
|
1015
1023
|
}
|
1016
|
-
throw Error(ErrorMessages.INVALID_RESPONSE(
|
1024
|
+
throw Error(ErrorMessages.INVALID_RESPONSE(g, "response", !!e.deepChat.responseInterceptor, v));
|
1017
1025
|
case 15:
|
1018
|
-
|
1026
|
+
y.pollingInAnotherRequest || (e.deepChat.stream && y.text ? Stream.simulate(n, e.streamHandlers, y.text) : (n.addNewMessage(y, !0, !0), u()));
|
1019
1027
|
case 16:
|
1020
1028
|
case "end":
|
1021
1029
|
return _context9.stop();
|
1022
1030
|
}
|
1023
1031
|
}, _callee9);
|
1024
1032
|
}));
|
1025
|
-
return function (
|
1033
|
+
return function (_x18) {
|
1026
1034
|
return _ref3.apply(this, arguments);
|
1027
1035
|
};
|
1028
|
-
}())["catch"](function (
|
1029
|
-
RequestUtils.displayError(n,
|
1036
|
+
}())["catch"](function (g) {
|
1037
|
+
RequestUtils.displayError(n, g), u();
|
1030
1038
|
});
|
1031
1039
|
case 17:
|
1032
1040
|
case "end":
|
@@ -1034,7 +1042,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
1034
1042
|
}
|
1035
1043
|
}, _callee10);
|
1036
1044
|
}));
|
1037
|
-
function request(_x16, _x17
|
1045
|
+
function request(_x15, _x16, _x17) {
|
1038
1046
|
return _request3.apply(this, arguments);
|
1039
1047
|
}
|
1040
1048
|
return request;
|
@@ -1083,7 +1091,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
1083
1091
|
}
|
1084
1092
|
}, _callee11);
|
1085
1093
|
}));
|
1086
|
-
return function (
|
1094
|
+
return function (_x19) {
|
1087
1095
|
return _ref4.apply(this, arguments);
|
1088
1096
|
};
|
1089
1097
|
}())["catch"](function (a) {
|
@@ -1142,7 +1150,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
1142
1150
|
}
|
1143
1151
|
}, _callee12);
|
1144
1152
|
}));
|
1145
|
-
function poll(_x21, _x22
|
1153
|
+
function poll(_x20, _x21, _x22) {
|
1146
1154
|
return _poll.apply(this, arguments);
|
1147
1155
|
}
|
1148
1156
|
return poll;
|
@@ -1227,23 +1235,38 @@ var Websocket = /*#__PURE__*/function () {
|
|
1227
1235
|
}
|
1228
1236
|
_createClass(Websocket, null, [{
|
1229
1237
|
key: "setup",
|
1230
|
-
value: function setup(e
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1238
|
+
value: function setup(e) {
|
1239
|
+
e.requestSettings.url !== Demo.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
|
1240
|
+
}
|
1241
|
+
}, {
|
1242
|
+
key: "createConnection",
|
1243
|
+
value: function createConnection(e, t) {
|
1244
|
+
if (!document.body.contains(e.deepChat)) return;
|
1245
|
+
var n = e.requestSettings.websocket;
|
1246
|
+
if (n) try {
|
1247
|
+
var s = typeof n != "boolean" ? n : void 0;
|
1248
|
+
e.websocket = new WebSocket(e.requestSettings.url || "", s), e.websocket.onopen = function () {
|
1249
|
+
t.removeError(), e.websocket && _typeof(e.websocket) == "object" && Websocket.assignListeners(e, e.websocket, t);
|
1250
|
+
}, e.websocket.onerror = function (o) {
|
1251
|
+
console.error(o), Websocket.retryConnection(e, t);
|
1252
|
+
};
|
1253
|
+
} catch (s) {
|
1254
|
+
console.error(s), Websocket.retryConnection(e, t);
|
1234
1255
|
}
|
1235
1256
|
}
|
1236
1257
|
}, {
|
1237
|
-
key: "
|
1238
|
-
value: function
|
1239
|
-
|
1258
|
+
key: "retryConnection",
|
1259
|
+
value: function retryConnection(e, t) {
|
1260
|
+
document.body.contains(e.deepChat) && (e.websocket = "pending", t.isLastMessageError() || t.addNewErrorMessage("service", "Connection error"), setTimeout(function () {
|
1261
|
+
Websocket.createConnection(e, t);
|
1262
|
+
}, 5e3));
|
1240
1263
|
}
|
1241
1264
|
}, {
|
1242
1265
|
key: "assignListeners",
|
1243
|
-
value: function assignListeners(e, t) {
|
1244
|
-
|
1245
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(
|
1246
|
-
var
|
1266
|
+
value: function assignListeners(e, t, n) {
|
1267
|
+
t.onmessage = /*#__PURE__*/function () {
|
1268
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(s) {
|
1269
|
+
var o, a, l, c, u;
|
1247
1270
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
1248
1271
|
while (1) switch (_context13.prev = _context13.next) {
|
1249
1272
|
case 0:
|
@@ -1252,49 +1275,49 @@ var Websocket = /*#__PURE__*/function () {
|
|
1252
1275
|
break;
|
1253
1276
|
}
|
1254
1277
|
_context13.prev = 1;
|
1255
|
-
|
1278
|
+
l = JSON.parse(s.data);
|
1256
1279
|
_context13.next = 5;
|
1257
|
-
return (
|
1280
|
+
return (a = (o = e.deepChat).responseInterceptor) == null ? void 0 : a.call(o, l);
|
1258
1281
|
case 5:
|
1259
1282
|
_context13.t0 = _context13.sent;
|
1260
1283
|
if (_context13.t0) {
|
1261
1284
|
_context13.next = 8;
|
1262
1285
|
break;
|
1263
1286
|
}
|
1264
|
-
_context13.t0 =
|
1287
|
+
_context13.t0 = l;
|
1265
1288
|
case 8:
|
1266
|
-
|
1289
|
+
c = _context13.t0;
|
1267
1290
|
_context13.next = 11;
|
1268
|
-
return e.extractResultData(
|
1291
|
+
return e.extractResultData(c);
|
1269
1292
|
case 11:
|
1270
|
-
|
1271
|
-
if (!(!
|
1293
|
+
u = _context13.sent;
|
1294
|
+
if (!(!u || _typeof(u) != "object")) {
|
1272
1295
|
_context13.next = 14;
|
1273
1296
|
break;
|
1274
1297
|
}
|
1275
|
-
throw Error(ErrorMessages.INVALID_RESPONSE(
|
1298
|
+
throw Error(ErrorMessages.INVALID_RESPONSE(l, "server", !!e.deepChat.responseInterceptor, c));
|
1276
1299
|
case 14:
|
1277
|
-
e.deepChat.stream &&
|
1300
|
+
e.deepChat.stream && u.text ? Stream.simulate(n, e.streamHandlers, u.text) : n.addNewMessage(u, !0, !0);
|
1278
1301
|
_context13.next = 20;
|
1279
1302
|
break;
|
1280
1303
|
case 17:
|
1281
1304
|
_context13.prev = 17;
|
1282
1305
|
_context13.t1 = _context13["catch"](1);
|
1283
|
-
RequestUtils.displayError(
|
1306
|
+
RequestUtils.displayError(n, _context13.t1, "Error in server message");
|
1284
1307
|
case 20:
|
1285
1308
|
case "end":
|
1286
1309
|
return _context13.stop();
|
1287
1310
|
}
|
1288
1311
|
}, _callee13, null, [[1, 17]]);
|
1289
1312
|
}));
|
1290
|
-
return function (
|
1313
|
+
return function (_x23) {
|
1291
1314
|
return _ref5.apply(this, arguments);
|
1292
1315
|
};
|
1293
|
-
}(),
|
1294
|
-
console.error(
|
1295
|
-
},
|
1296
|
-
console.error("Connection closed"),
|
1297
|
-
}
|
1316
|
+
}(), t.onerror = function (s) {
|
1317
|
+
console.error(s), n.isLastMessageError() || n.addNewErrorMessage("service", "Connection error");
|
1318
|
+
}, t.onclose = function () {
|
1319
|
+
console.error("Connection closed"), n.isLastMessageError() || n.addNewErrorMessage("service", "Connection error"), Websocket.createConnection(e, n);
|
1320
|
+
};
|
1298
1321
|
}
|
1299
1322
|
}, {
|
1300
1323
|
key: "sendWebsocket",
|
@@ -1336,14 +1359,14 @@ var Websocket = /*#__PURE__*/function () {
|
|
1336
1359
|
}
|
1337
1360
|
return _context14.abrupt("return", Demo.request(s, t.completionsHandlers.onFinish, t.deepChat.responseInterceptor));
|
1338
1361
|
case 12:
|
1339
|
-
e.readyState !== e.OPEN ? (console.error("Connection is not open"), s.addNewErrorMessage("service", "Connection error")) : e.send(JSON.stringify(u));
|
1362
|
+
e.readyState === void 0 || e.readyState !== e.OPEN ? (console.error("Connection is not open"), s.isLastMessageError() || s.addNewErrorMessage("service", "Connection error")) : e.send(JSON.stringify(u));
|
1340
1363
|
case 13:
|
1341
1364
|
case "end":
|
1342
1365
|
return _context14.stop();
|
1343
1366
|
}
|
1344
1367
|
}, _callee14);
|
1345
1368
|
}));
|
1346
|
-
function sendWebsocket(_x25, _x26, _x27
|
1369
|
+
function sendWebsocket(_x24, _x25, _x26, _x27) {
|
1347
1370
|
return _sendWebsocket.apply(this, arguments);
|
1348
1371
|
}
|
1349
1372
|
return sendWebsocket;
|
@@ -2003,24 +2026,24 @@ function replaceAt(r, e, t) {
|
|
2003
2026
|
return r.substr(0, e) + t + r.substr(e + 1);
|
2004
2027
|
}
|
2005
2028
|
function smartquotes(r) {
|
2006
|
-
var e, t, n, s, o, a, l, c, u, d, h, p, f, b, m,
|
2029
|
+
var e, t, n, s, o, a, l, c, u, d, h, p, f, b, m, g, v;
|
2007
2030
|
if (r.options.typographer) {
|
2008
|
-
for (
|
2009
|
-
for (
|
2010
|
-
for (l =
|
2011
|
-
|
2031
|
+
for (v = [], m = r.tokens.length - 1; m >= 0; m--) if (r.tokens[m].type === "inline") {
|
2032
|
+
for (g = r.tokens[m].children, v.length = 0, e = 0; e < g.length; e++) if (t = g[e], !(t.type !== "text" || QUOTE_TEST_RE.test(t.text))) {
|
2033
|
+
for (l = g[e].level, f = v.length - 1; f >= 0 && !(v[f].level <= l); f--);
|
2034
|
+
v.length = f + 1, n = t.content, o = 0, a = n.length;
|
2012
2035
|
e: for (; o < a && (QUOTE_RE.lastIndex = o, s = QUOTE_RE.exec(n), !!s);) {
|
2013
2036
|
if (c = !isLetter(n, s.index - 1), o = s.index + 1, b = s[0] === "'", u = !isLetter(n, o), !u && !c) {
|
2014
2037
|
b && (t.content = replaceAt(t.content, s.index, APOSTROPHE));
|
2015
2038
|
continue;
|
2016
2039
|
}
|
2017
2040
|
if (h = !u, p = !c, p) {
|
2018
|
-
for (f =
|
2019
|
-
d =
|
2041
|
+
for (f = v.length - 1; f >= 0 && (d = v[f], !(v[f].level < l)); f--) if (d.single === b && v[f].level === l) {
|
2042
|
+
d = v[f], b ? (g[d.token].content = replaceAt(g[d.token].content, d.pos, r.options.quotes[2]), t.content = replaceAt(t.content, s.index, r.options.quotes[3])) : (g[d.token].content = replaceAt(g[d.token].content, d.pos, r.options.quotes[0]), t.content = replaceAt(t.content, s.index, r.options.quotes[1])), v.length = f;
|
2020
2043
|
continue e;
|
2021
2044
|
}
|
2022
2045
|
}
|
2023
|
-
h ?
|
2046
|
+
h ? v.push({
|
2024
2047
|
token: e,
|
2025
2048
|
pos: s.index,
|
2026
2049
|
single: b,
|
@@ -2141,12 +2164,12 @@ function blockquote(r, e, t, n) {
|
|
2141
2164
|
f,
|
2142
2165
|
b,
|
2143
2166
|
m = r.bMarks[e] + r.tShift[e],
|
2144
|
-
|
2145
|
-
if (m >
|
2167
|
+
g = r.eMarks[e];
|
2168
|
+
if (m > g || r.src.charCodeAt(m++) !== 62 || r.level >= r.options.maxNesting) return !1;
|
2146
2169
|
if (n) return !0;
|
2147
|
-
for (r.src.charCodeAt(m) === 32 && m++, c = r.blkIndent, r.blkIndent = 0, l = [r.bMarks[e]], r.bMarks[e] = m, m = m <
|
2170
|
+
for (r.src.charCodeAt(m) === 32 && m++, c = r.blkIndent, r.blkIndent = 0, l = [r.bMarks[e]], r.bMarks[e] = m, m = m < g ? r.skipSpaces(m) : m, o = m >= g, a = [r.tShift[e]], r.tShift[e] = m - r.bMarks[e], h = r.parser.ruler.getRules("blockquote"), s = e + 1; s < t && (m = r.bMarks[s] + r.tShift[s], g = r.eMarks[s], !(m >= g)); s++) {
|
2148
2171
|
if (r.src.charCodeAt(m++) === 62) {
|
2149
|
-
r.src.charCodeAt(m) === 32 && m++, l.push(r.bMarks[s]), r.bMarks[s] = m, m = m <
|
2172
|
+
r.src.charCodeAt(m) === 32 && m++, l.push(r.bMarks[s]), r.bMarks[s] = m, m = m < g ? r.skipSpaces(m) : m, o = m >= g, a.push(r.tShift[s]), r.tShift[s] = m - r.bMarks[s];
|
2150
2173
|
continue;
|
2151
2174
|
}
|
2152
2175
|
if (o) break;
|
@@ -2221,51 +2244,51 @@ function list(r, e, t, n) {
|
|
2221
2244
|
f,
|
2222
2245
|
b,
|
2223
2246
|
m,
|
2224
|
-
v,
|
2225
2247
|
g,
|
2248
|
+
v,
|
2226
2249
|
y,
|
2227
|
-
x,
|
2228
2250
|
_,
|
2251
|
+
S,
|
2229
2252
|
I,
|
2230
2253
|
R = !0,
|
2231
2254
|
w,
|
2232
|
-
|
2255
|
+
x,
|
2233
2256
|
H,
|
2234
2257
|
F;
|
2235
|
-
if ((h = skipOrderedListMarker(r, e)) >= 0)
|
2258
|
+
if ((h = skipOrderedListMarker(r, e)) >= 0) g = !0;else if ((h = skipBulletListMarker(r, e)) >= 0) g = !1;else return !1;
|
2236
2259
|
if (r.level >= r.options.maxNesting) return !1;
|
2237
2260
|
if (m = r.src.charCodeAt(h - 1), n) return !0;
|
2238
|
-
for (y = r.tokens.length,
|
2261
|
+
for (y = r.tokens.length, g ? (d = r.bMarks[e] + r.tShift[e], b = Number(r.src.substr(d, h - d - 1)), r.tokens.push({
|
2239
2262
|
type: "ordered_list_open",
|
2240
2263
|
order: b,
|
2241
|
-
lines:
|
2264
|
+
lines: S = [e, 0],
|
2242
2265
|
level: r.level++
|
2243
2266
|
})) : r.tokens.push({
|
2244
2267
|
type: "bullet_list_open",
|
2245
|
-
lines:
|
2268
|
+
lines: S = [e, 0],
|
2246
2269
|
level: r.level++
|
2247
|
-
}), s = e,
|
2270
|
+
}), s = e, _ = !1, w = r.parser.ruler.getRules("list"); s < t && (v = r.skipSpaces(h), p = r.eMarks[s], v >= p ? f = 1 : f = v - h, f > 4 && (f = 1), f < 1 && (f = 1), o = h - r.bMarks[s] + f, r.tokens.push({
|
2248
2271
|
type: "list_item_open",
|
2249
2272
|
lines: I = [e, 0],
|
2250
2273
|
level: r.level++
|
2251
|
-
}), l = r.blkIndent, c = r.tight, a = r.tShift[e], u = r.parentType, r.tShift[e] =
|
2274
|
+
}), l = r.blkIndent, c = r.tight, a = r.tShift[e], u = r.parentType, r.tShift[e] = v - r.bMarks[e], r.blkIndent = o, r.tight = !0, r.parentType = "list", r.parser.tokenize(r, e, t, !0), (!r.tight || _) && (R = !1), _ = r.line - e > 1 && r.isEmpty(r.line - 1), r.blkIndent = l, r.tShift[e] = a, r.tight = c, r.parentType = u, r.tokens.push({
|
2252
2275
|
type: "list_item_close",
|
2253
2276
|
level: --r.level
|
2254
|
-
}), s = e = r.line, I[1] = s,
|
2255
|
-
for (F = !1,
|
2277
|
+
}), s = e = r.line, I[1] = s, v = r.bMarks[e], !(s >= t || r.isEmpty(s) || r.tShift[s] < r.blkIndent));) {
|
2278
|
+
for (F = !1, x = 0, H = w.length; x < H; x++) if (w[x](r, s, t, !0)) {
|
2256
2279
|
F = !0;
|
2257
2280
|
break;
|
2258
2281
|
}
|
2259
2282
|
if (F) break;
|
2260
|
-
if (
|
2283
|
+
if (g) {
|
2261
2284
|
if (h = skipOrderedListMarker(r, s), h < 0) break;
|
2262
2285
|
} else if (h = skipBulletListMarker(r, s), h < 0) break;
|
2263
2286
|
if (m !== r.src.charCodeAt(h - 1)) break;
|
2264
2287
|
}
|
2265
2288
|
return r.tokens.push({
|
2266
|
-
type:
|
2289
|
+
type: g ? "ordered_list_close" : "bullet_list_close",
|
2267
2290
|
level: --r.level
|
2268
|
-
}),
|
2291
|
+
}), S[1] = s, r.line = s, R && markTightParagraphs(r, y), !0;
|
2269
2292
|
}
|
2270
2293
|
function footnote(r, e, t, n) {
|
2271
2294
|
var s,
|
@@ -2470,7 +2493,7 @@ function markTightParagraphs$1(r, e) {
|
|
2470
2493
|
for (t = e + 2, n = r.tokens.length - 2; t < n; t++) r.tokens[t].level === s && r.tokens[t].type === "paragraph_open" && (r.tokens[t + 2].tight = !0, r.tokens[t].tight = !0, t += 2);
|
2471
2494
|
}
|
2472
2495
|
function deflist(r, e, t, n) {
|
2473
|
-
var s, o, a, l, c, u, d, h, p, f, b, m,
|
2496
|
+
var s, o, a, l, c, u, d, h, p, f, b, m, g, v;
|
2474
2497
|
if (n) return r.ddIndent < 0 ? !1 : skipMarker(r, e) >= 0;
|
2475
2498
|
if (d = e + 1, r.isEmpty(d) && ++d > t || r.tShift[d] < r.blkIndent || (s = skipMarker(r, d), s < 0) || r.level >= r.options.maxNesting) return !1;
|
2476
2499
|
u = r.tokens.length, r.tokens.push({
|
@@ -2479,7 +2502,7 @@ function deflist(r, e, t, n) {
|
|
2479
2502
|
level: r.level++
|
2480
2503
|
}), a = e, o = d;
|
2481
2504
|
e: for (;;) {
|
2482
|
-
for (
|
2505
|
+
for (v = !0, g = !1, r.tokens.push({
|
2483
2506
|
type: "dt_open",
|
2484
2507
|
lines: [a, a],
|
2485
2508
|
level: r.level++
|
@@ -2497,7 +2520,7 @@ function deflist(r, e, t, n) {
|
|
2497
2520
|
type: "dd_open",
|
2498
2521
|
lines: l = [d, 0],
|
2499
2522
|
level: r.level++
|
2500
|
-
}), m = r.tight, p = r.ddIndent, h = r.blkIndent, b = r.tShift[o], f = r.parentType, r.blkIndent = r.ddIndent = r.tShift[o] + 2, r.tShift[o] = s - r.bMarks[o], r.tight = !0, r.parentType = "deflist", r.parser.tokenize(r, o, t, !0), (!r.tight ||
|
2523
|
+
}), m = r.tight, p = r.ddIndent, h = r.blkIndent, b = r.tShift[o], f = r.parentType, r.blkIndent = r.ddIndent = r.tShift[o] + 2, r.tShift[o] = s - r.bMarks[o], r.tight = !0, r.parentType = "deflist", r.parser.tokenize(r, o, t, !0), (!r.tight || g) && (v = !1), g = r.line - o > 1 && r.isEmpty(r.line - 1), r.tShift[o] = b, r.tight = m, r.parentType = f, r.blkIndent = h, r.ddIndent = p, r.tokens.push({
|
2501
2524
|
type: "dd_close",
|
2502
2525
|
level: --r.level
|
2503
2526
|
}), l[1] = d = r.line, d >= t || r.tShift[d] < r.blkIndent) break e;
|
@@ -2509,7 +2532,7 @@ function deflist(r, e, t, n) {
|
|
2509
2532
|
return r.tokens.push({
|
2510
2533
|
type: "dl_close",
|
2511
2534
|
level: --r.level
|
2512
|
-
}), c[1] = d, r.line = d,
|
2535
|
+
}), c[1] = d, r.line = d, v && markTightParagraphs$1(r, u), !0;
|
2513
2536
|
}
|
2514
2537
|
function paragraph(r, e) {
|
2515
2538
|
var t,
|
@@ -3373,7 +3396,7 @@ var BaseServiceIO = /*#__PURE__*/function () {
|
|
3373
3396
|
var _l$url;
|
3374
3397
|
_classCallCheck(this, BaseServiceIO);
|
3375
3398
|
var s, o, a, l;
|
3376
|
-
this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage = BaseServiceIO.canSendMessage, this.requestSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = n, Object.assign(this.rawBody, (s = e.request) == null ? void 0 : s.additionalBodyProps), this.totalMessagesMaxCharLength = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.totalMessagesMaxCharLength, this.maxMessages = (a = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : a.maxMessages, SetFileTypes.set(e, this, t), e.request && (this.requestSettings = e.request), this.demo && ((_l$url = (l = this.requestSettings).url) !== null && _l$url !== void 0 ? _l$url : l.url = Demo.URL), this._directServiceRequiresFiles = !!t && Object.keys(t).length > 0, this.requestSettings.websocket && Websocket.setup(this
|
3399
|
+
this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage = BaseServiceIO.canSendMessage, this.requestSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = n, Object.assign(this.rawBody, (s = e.request) == null ? void 0 : s.additionalBodyProps), this.totalMessagesMaxCharLength = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.totalMessagesMaxCharLength, this.maxMessages = (a = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : a.maxMessages, SetFileTypes.set(e, this, t), e.request && (this.requestSettings = e.request), this.demo && ((_l$url = (l = this.requestSettings).url) !== null && _l$url !== void 0 ? _l$url : l.url = Demo.URL), this._directServiceRequiresFiles = !!t && Object.keys(t).length > 0, this.requestSettings.websocket && Websocket.setup(this);
|
3377
3400
|
}
|
3378
3401
|
_createClass(BaseServiceIO, [{
|
3379
3402
|
key: "verifyKey",
|
@@ -3424,7 +3447,7 @@ var BaseServiceIO = /*#__PURE__*/function () {
|
|
3424
3447
|
}
|
3425
3448
|
}, _callee15, this);
|
3426
3449
|
}));
|
3427
|
-
function callServiceAPI(_x29, _x30
|
3450
|
+
function callServiceAPI(_x28, _x29, _x30) {
|
3428
3451
|
return _callServiceAPI.apply(this, arguments);
|
3429
3452
|
}
|
3430
3453
|
return callServiceAPI;
|
@@ -3449,7 +3472,7 @@ var BaseServiceIO = /*#__PURE__*/function () {
|
|
3449
3472
|
}
|
3450
3473
|
}, _callee16, this);
|
3451
3474
|
}));
|
3452
|
-
function callApiWithFiles(_x32, _x33, _x34
|
3475
|
+
function callApiWithFiles(_x31, _x32, _x33, _x34) {
|
3453
3476
|
return _callApiWithFiles.apply(this, arguments);
|
3454
3477
|
}
|
3455
3478
|
return callApiWithFiles;
|
@@ -3481,11 +3504,12 @@ var BaseServiceIO = /*#__PURE__*/function () {
|
|
3481
3504
|
}
|
3482
3505
|
}, _callee17, this);
|
3483
3506
|
}));
|
3484
|
-
function callAPI(
|
3507
|
+
function callAPI(_x35, _x36) {
|
3485
3508
|
return _callAPI.apply(this, arguments);
|
3486
3509
|
}
|
3487
3510
|
return callAPI;
|
3488
|
-
}()
|
3511
|
+
}() // WORK - validation to say that the response should have text, files or error property, link to example
|
3512
|
+
// and responseInterceptor
|
3489
3513
|
}, {
|
3490
3514
|
key: "extractResultData",
|
3491
3515
|
value: function () {
|
@@ -3499,14 +3523,14 @@ var BaseServiceIO = /*#__PURE__*/function () {
|
|
3499
3523
|
}
|
3500
3524
|
throw e.error;
|
3501
3525
|
case 2:
|
3502
|
-
return _context18.abrupt("return", e.result);
|
3526
|
+
return _context18.abrupt("return", e.result ? (console.error("The {result: ....} response object type is deprecated since version 1.3.0."), console.error("Please change to using the new response object: https://deepchat.dev/docs/connect#Response"), e.result) : e);
|
3503
3527
|
case 3:
|
3504
3528
|
case "end":
|
3505
3529
|
return _context18.stop();
|
3506
3530
|
}
|
3507
3531
|
}, _callee18);
|
3508
3532
|
}));
|
3509
|
-
function extractResultData(
|
3533
|
+
function extractResultData(_x37) {
|
3510
3534
|
return _extractResultData.apply(this, arguments);
|
3511
3535
|
}
|
3512
3536
|
return extractResultData;
|
@@ -3847,17 +3871,17 @@ var HuggingFaceUtils = /*#__PURE__*/function () {
|
|
3847
3871
|
return HuggingFaceUtils;
|
3848
3872
|
}();
|
3849
3873
|
var _HuggingFaceIO = /*#__PURE__*/function (_DirectServiceIO) {
|
3850
|
-
_inherits(
|
3851
|
-
var _super3 = _createSuper(
|
3874
|
+
_inherits(j, _DirectServiceIO);
|
3875
|
+
var _super3 = _createSuper(j);
|
3852
3876
|
// prettier-ignore
|
3853
|
-
function
|
3877
|
+
function j(e, t, n, s, o, a) {
|
3854
3878
|
var _this4;
|
3855
|
-
_classCallCheck(this,
|
3856
|
-
_this4 = _super3.call(this, e, HuggingFaceUtils.buildKeyVerificationDetails(), HuggingFaceUtils.buildHeaders, o, a), _this4.insertKeyPlaceholderText = "Hugging Face Token", _this4.getKeyLink = "https://huggingface.co/settings/tokens", _this4.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Hugging Face</b></div>\n <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>", _this4.permittedErrorPrefixes = ["Authorization header"], _this4.url = "".concat(
|
3879
|
+
_classCallCheck(this, j);
|
3880
|
+
_this4 = _super3.call(this, e, HuggingFaceUtils.buildKeyVerificationDetails(), HuggingFaceUtils.buildHeaders, o, a), _this4.insertKeyPlaceholderText = "Hugging Face Token", _this4.getKeyLink = "https://huggingface.co/settings/tokens", _this4.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Hugging Face</b></div>\n <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>", _this4.permittedErrorPrefixes = ["Authorization header"], _this4.url = "".concat(j.URL_PREFIX).concat(n), _this4.textInputPlaceholderText = t, _typeof(s) == "object" && (s.model && (_this4.url = "".concat(j.URL_PREFIX).concat(s.model)), s.options && (_this4.rawBody.options = s.options), s.parameters && (_this4.rawBody.parameters = s.parameters));
|
3857
3881
|
return _this4;
|
3858
3882
|
}
|
3859
3883
|
// prettier-ignore
|
3860
|
-
_createClass(
|
3884
|
+
_createClass(j, [{
|
3861
3885
|
key: "preprocessBody",
|
3862
3886
|
value: function preprocessBody(e, t, n) {
|
3863
3887
|
var _s$options;
|
@@ -3889,13 +3913,13 @@ var _HuggingFaceIO = /*#__PURE__*/function (_DirectServiceIO) {
|
|
3889
3913
|
}
|
3890
3914
|
}, _callee19, this);
|
3891
3915
|
}));
|
3892
|
-
function callServiceAPI(_x39, _x40
|
3916
|
+
function callServiceAPI(_x38, _x39, _x40) {
|
3893
3917
|
return _callServiceAPI2.apply(this, arguments);
|
3894
3918
|
}
|
3895
3919
|
return callServiceAPI;
|
3896
3920
|
}()
|
3897
3921
|
}]);
|
3898
|
-
return
|
3922
|
+
return j;
|
3899
3923
|
}(DirectServiceIO);
|
3900
3924
|
_HuggingFaceIO.URL_PREFIX = "https://api-inference.huggingface.co/models/";
|
3901
3925
|
var HuggingFaceIO = _HuggingFaceIO;
|
@@ -3941,7 +3965,7 @@ var HuggingFaceFileIO = /*#__PURE__*/function (_HuggingFaceIO2) {
|
|
3941
3965
|
}
|
3942
3966
|
}, _callee20, this);
|
3943
3967
|
}));
|
3944
|
-
function callServiceAPI(_x42, _x43
|
3968
|
+
function callServiceAPI(_x41, _x42, _x43) {
|
3945
3969
|
return _callServiceAPI3.apply(this, arguments);
|
3946
3970
|
}
|
3947
3971
|
return callServiceAPI;
|
@@ -3998,7 +4022,7 @@ var HuggingFaceAudioClassificationIO = /*#__PURE__*/function (_HuggingFaceFileIO
|
|
3998
4022
|
}
|
3999
4023
|
}, _callee21);
|
4000
4024
|
}));
|
4001
|
-
function extractPollResultData(
|
4025
|
+
function extractPollResultData(_x44) {
|
4002
4026
|
return _extractPollResultData.apply(this, arguments);
|
4003
4027
|
}
|
4004
4028
|
return extractPollResultData;
|
@@ -4049,7 +4073,7 @@ var HuggingFaceImageClassificationIO = /*#__PURE__*/function (_HuggingFaceFileIO
|
|
4049
4073
|
}
|
4050
4074
|
}, _callee22);
|
4051
4075
|
}));
|
4052
|
-
function extractPollResultData(
|
4076
|
+
function extractPollResultData(_x45) {
|
4053
4077
|
return _extractPollResultData2.apply(this, arguments);
|
4054
4078
|
}
|
4055
4079
|
return extractPollResultData;
|
@@ -4159,7 +4183,7 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
|
|
4159
4183
|
}
|
4160
4184
|
}, _callee23, this);
|
4161
4185
|
}));
|
4162
|
-
function callServiceAPI(_x47, _x48
|
4186
|
+
function callServiceAPI(_x46, _x47, _x48) {
|
4163
4187
|
return _callServiceAPI4.apply(this, arguments);
|
4164
4188
|
}
|
4165
4189
|
return callServiceAPI;
|
@@ -4191,7 +4215,7 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
|
|
4191
4215
|
}
|
4192
4216
|
}, _callee24);
|
4193
4217
|
}));
|
4194
|
-
function extractResultData(
|
4218
|
+
function extractResultData(_x49) {
|
4195
4219
|
return _extractResultData2.apply(this, arguments);
|
4196
4220
|
}
|
4197
4221
|
return extractResultData;
|
@@ -4268,7 +4292,7 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
|
|
4268
4292
|
}
|
4269
4293
|
}, _callee25, this);
|
4270
4294
|
}));
|
4271
|
-
function callServiceAPI(_x51, _x52
|
4295
|
+
function callServiceAPI(_x50, _x51, _x52) {
|
4272
4296
|
return _callServiceAPI5.apply(this, arguments);
|
4273
4297
|
}
|
4274
4298
|
return callServiceAPI;
|
@@ -4300,7 +4324,7 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
|
|
4300
4324
|
}
|
4301
4325
|
}, _callee26);
|
4302
4326
|
}));
|
4303
|
-
function extractResultData(
|
4327
|
+
function extractResultData(_x53) {
|
4304
4328
|
return _extractResultData3.apply(this, arguments);
|
4305
4329
|
}
|
4306
4330
|
return extractResultData;
|
@@ -4360,7 +4384,7 @@ var HuggingFaceAudioRecognitionIO = /*#__PURE__*/function (_HuggingFaceFileIO3)
|
|
4360
4384
|
}
|
4361
4385
|
}, _callee27);
|
4362
4386
|
}));
|
4363
|
-
function extractPollResultData(
|
4387
|
+
function extractPollResultData(_x54) {
|
4364
4388
|
return _extractPollResultData3.apply(this, arguments);
|
4365
4389
|
}
|
4366
4390
|
return extractPollResultData;
|
@@ -4400,7 +4424,7 @@ var HuggingFaceTextGenerationIO = /*#__PURE__*/function (_HuggingFaceIO3) {
|
|
4400
4424
|
}
|
4401
4425
|
}, _callee28);
|
4402
4426
|
}));
|
4403
|
-
function extractResultData(
|
4427
|
+
function extractResultData(_x55) {
|
4404
4428
|
return _extractResultData4.apply(this, arguments);
|
4405
4429
|
}
|
4406
4430
|
return extractResultData;
|
@@ -4456,7 +4480,7 @@ var HuggingFaceQuestionAnswerIO = /*#__PURE__*/function (_HuggingFaceIO4) {
|
|
4456
4480
|
}
|
4457
4481
|
}, _callee29);
|
4458
4482
|
}));
|
4459
|
-
function extractResultData(
|
4483
|
+
function extractResultData(_x56) {
|
4460
4484
|
return _extractResultData5.apply(this, arguments);
|
4461
4485
|
}
|
4462
4486
|
return extractResultData;
|
@@ -4496,7 +4520,7 @@ var HuggingFaceSummarizationIO = /*#__PURE__*/function (_HuggingFaceIO5) {
|
|
4496
4520
|
}
|
4497
4521
|
}, _callee30);
|
4498
4522
|
}));
|
4499
|
-
function extractResultData(
|
4523
|
+
function extractResultData(_x57) {
|
4500
4524
|
return _extractResultData6.apply(this, arguments);
|
4501
4525
|
}
|
4502
4526
|
return extractResultData;
|
@@ -4576,7 +4600,7 @@ var HuggingFaceConversationIO = /*#__PURE__*/function (_HuggingFaceIO6) {
|
|
4576
4600
|
}
|
4577
4601
|
}, _callee31);
|
4578
4602
|
}));
|
4579
|
-
function extractResultData(
|
4603
|
+
function extractResultData(_x58) {
|
4580
4604
|
return _extractResultData7.apply(this, arguments);
|
4581
4605
|
}
|
4582
4606
|
return extractResultData;
|
@@ -4643,7 +4667,7 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
|
|
4643
4667
|
}
|
4644
4668
|
}, _callee32, this);
|
4645
4669
|
}));
|
4646
|
-
function callServiceAPI(_x60, _x61
|
4670
|
+
function callServiceAPI(_x59, _x60, _x61) {
|
4647
4671
|
return _callServiceAPI6.apply(this, arguments);
|
4648
4672
|
}
|
4649
4673
|
return callServiceAPI;
|
@@ -4675,7 +4699,7 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
|
|
4675
4699
|
}
|
4676
4700
|
}, _callee33);
|
4677
4701
|
}));
|
4678
|
-
function extractResultData(
|
4702
|
+
function extractResultData(_x62) {
|
4679
4703
|
return _extractResultData8.apply(this, arguments);
|
4680
4704
|
}
|
4681
4705
|
return extractResultData;
|
@@ -4725,7 +4749,7 @@ var HuggingFaceTranslationIO = /*#__PURE__*/function (_HuggingFaceIO7) {
|
|
4725
4749
|
}
|
4726
4750
|
}, _callee34);
|
4727
4751
|
}));
|
4728
|
-
function extractResultData(
|
4752
|
+
function extractResultData(_x63) {
|
4729
4753
|
return _extractResultData9.apply(this, arguments);
|
4730
4754
|
}
|
4731
4755
|
return extractResultData;
|
@@ -4778,7 +4802,7 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
|
|
4778
4802
|
}
|
4779
4803
|
}, _callee35, this);
|
4780
4804
|
}));
|
4781
|
-
function callServiceAPI(
|
4805
|
+
function callServiceAPI(_x64, _x65) {
|
4782
4806
|
return _callServiceAPI7.apply(this, arguments);
|
4783
4807
|
}
|
4784
4808
|
return callServiceAPI;
|
@@ -4810,7 +4834,7 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
|
|
4810
4834
|
}
|
4811
4835
|
}, _callee36);
|
4812
4836
|
}));
|
4813
|
-
function extractResultData(
|
4837
|
+
function extractResultData(_x66) {
|
4814
4838
|
return _extractResultData10.apply(this, arguments);
|
4815
4839
|
}
|
4816
4840
|
return extractResultData;
|
@@ -4862,7 +4886,7 @@ var HuggingFaceFillMaskIO = /*#__PURE__*/function (_HuggingFaceIO8) {
|
|
4862
4886
|
}
|
4863
4887
|
}, _callee37);
|
4864
4888
|
}));
|
4865
|
-
function extractResultData(
|
4889
|
+
function extractResultData(_x67) {
|
4866
4890
|
return _extractResultData11.apply(this, arguments);
|
4867
4891
|
}
|
4868
4892
|
return extractResultData;
|
@@ -4956,7 +4980,7 @@ var CohereTextGenerationIO = /*#__PURE__*/function (_CohereIO) {
|
|
4956
4980
|
}
|
4957
4981
|
}, _callee38, this);
|
4958
4982
|
}));
|
4959
|
-
function callServiceAPI(
|
4983
|
+
function callServiceAPI(_x68, _x69) {
|
4960
4984
|
return _callServiceAPI8.apply(this, arguments);
|
4961
4985
|
}
|
4962
4986
|
return callServiceAPI;
|
@@ -4984,7 +5008,7 @@ var CohereTextGenerationIO = /*#__PURE__*/function (_CohereIO) {
|
|
4984
5008
|
}
|
4985
5009
|
}, _callee39);
|
4986
5010
|
}));
|
4987
|
-
function extractResultData(
|
5011
|
+
function extractResultData(_x70) {
|
4988
5012
|
return _extractResultData12.apply(this, arguments);
|
4989
5013
|
}
|
4990
5014
|
return extractResultData;
|
@@ -5033,7 +5057,7 @@ var CohereSummarizationIO = /*#__PURE__*/function (_CohereIO2) {
|
|
5033
5057
|
}
|
5034
5058
|
}, _callee40, this);
|
5035
5059
|
}));
|
5036
|
-
function callServiceAPI(
|
5060
|
+
function callServiceAPI(_x71, _x72) {
|
5037
5061
|
return _callServiceAPI9.apply(this, arguments);
|
5038
5062
|
}
|
5039
5063
|
return callServiceAPI;
|
@@ -5060,7 +5084,7 @@ var CohereSummarizationIO = /*#__PURE__*/function (_CohereIO2) {
|
|
5060
5084
|
}
|
5061
5085
|
}, _callee41);
|
5062
5086
|
}));
|
5063
|
-
function extractResultData(
|
5087
|
+
function extractResultData(_x73) {
|
5064
5088
|
return _extractResultData13.apply(this, arguments);
|
5065
5089
|
}
|
5066
5090
|
return extractResultData;
|
@@ -5236,7 +5260,7 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
|
|
5236
5260
|
}
|
5237
5261
|
}, _callee42, this);
|
5238
5262
|
}));
|
5239
|
-
function callServiceAPI(
|
5263
|
+
function callServiceAPI(_x74, _x75) {
|
5240
5264
|
return _callServiceAPI10.apply(this, arguments);
|
5241
5265
|
}
|
5242
5266
|
return callServiceAPI;
|
@@ -5271,7 +5295,7 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
|
|
5271
5295
|
}
|
5272
5296
|
}, _callee43, this);
|
5273
5297
|
}));
|
5274
|
-
function extractResultData(
|
5298
|
+
function extractResultData(_x76) {
|
5275
5299
|
return _extractResultData14.apply(this, arguments);
|
5276
5300
|
}
|
5277
5301
|
return extractResultData;
|
@@ -5331,7 +5355,7 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
|
|
5331
5355
|
}
|
5332
5356
|
}, _callee44);
|
5333
5357
|
}));
|
5334
|
-
function extractPollResultData(
|
5358
|
+
function extractPollResultData(_x77) {
|
5335
5359
|
return _extractPollResultData4.apply(this, arguments);
|
5336
5360
|
}
|
5337
5361
|
return extractPollResultData;
|
@@ -5449,7 +5473,7 @@ var OpenAICompletionsIO = /*#__PURE__*/function (_DirectServiceIO5) {
|
|
5449
5473
|
}
|
5450
5474
|
}, _callee45, this);
|
5451
5475
|
}));
|
5452
|
-
function callServiceAPI(
|
5476
|
+
function callServiceAPI(_x78, _x79) {
|
5453
5477
|
return _callServiceAPI11.apply(this, arguments);
|
5454
5478
|
}
|
5455
5479
|
return callServiceAPI;
|
@@ -5477,7 +5501,7 @@ var OpenAICompletionsIO = /*#__PURE__*/function (_DirectServiceIO5) {
|
|
5477
5501
|
}
|
5478
5502
|
}, _callee46);
|
5479
5503
|
}));
|
5480
|
-
function extractResultData(
|
5504
|
+
function extractResultData(_x80) {
|
5481
5505
|
return _extractResultData15.apply(this, arguments);
|
5482
5506
|
}
|
5483
5507
|
return extractResultData;
|
@@ -5559,7 +5583,7 @@ var AssemblyAIUtils = /*#__PURE__*/function () {
|
|
5559
5583
|
}
|
5560
5584
|
}, _callee47);
|
5561
5585
|
}));
|
5562
|
-
function poll(
|
5586
|
+
function poll(_x81, _x82) {
|
5563
5587
|
return _poll2.apply(this, arguments);
|
5564
5588
|
}
|
5565
5589
|
return poll;
|
@@ -5631,7 +5655,7 @@ var AssemblyAIAudioIO = /*#__PURE__*/function (_DirectServiceIO6) {
|
|
5631
5655
|
}
|
5632
5656
|
}, _callee48, this);
|
5633
5657
|
}));
|
5634
|
-
function callServiceAPI(_x84, _x85
|
5658
|
+
function callServiceAPI(_x83, _x84, _x85) {
|
5635
5659
|
return _callServiceAPI12.apply(this, arguments);
|
5636
5660
|
}
|
5637
5661
|
return callServiceAPI;
|
@@ -5664,7 +5688,7 @@ var AssemblyAIAudioIO = /*#__PURE__*/function (_DirectServiceIO6) {
|
|
5664
5688
|
}
|
5665
5689
|
}, _callee49, this);
|
5666
5690
|
}));
|
5667
|
-
function extractResultData(
|
5691
|
+
function extractResultData(_x86) {
|
5668
5692
|
return _extractResultData16.apply(this, arguments);
|
5669
5693
|
}
|
5670
5694
|
return extractResultData;
|
@@ -5733,7 +5757,7 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
|
|
5733
5757
|
}
|
5734
5758
|
}, _callee50, this);
|
5735
5759
|
}));
|
5736
|
-
function callServiceAPI(
|
5760
|
+
function callServiceAPI(_x87, _x88) {
|
5737
5761
|
return _callServiceAPI13.apply(this, arguments);
|
5738
5762
|
}
|
5739
5763
|
return callServiceAPI;
|
@@ -5762,7 +5786,7 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
|
|
5762
5786
|
}
|
5763
5787
|
}, _callee51);
|
5764
5788
|
}));
|
5765
|
-
function extractResultData(
|
5789
|
+
function extractResultData(_x89) {
|
5766
5790
|
return _extractResultData17.apply(this, arguments);
|
5767
5791
|
}
|
5768
5792
|
return extractResultData;
|
@@ -5775,11 +5799,11 @@ _AzureTextToSpeechIO.HELP_LINK =
|
|
5775
5799
|
"https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest";
|
5776
5800
|
var AzureTextToSpeechIO = _AzureTextToSpeechIO;
|
5777
5801
|
var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
|
5778
|
-
_inherits(
|
5779
|
-
var _super28 = _createSuper(
|
5780
|
-
function
|
5802
|
+
_inherits(U, _AzureSpeechIO2);
|
5803
|
+
var _super28 = _createSuper(U);
|
5804
|
+
function U(e) {
|
5781
5805
|
var _this21;
|
5782
|
-
_classCallCheck(this,
|
5806
|
+
_classCallCheck(this, U);
|
5783
5807
|
var a, l, c;
|
5784
5808
|
var t = (l = (a = e.directConnection) == null ? void 0 : a.azure) == null ? void 0 : l.speechToText,
|
5785
5809
|
n = (c = e.directConnection) == null ? void 0 : c.azure,
|
@@ -5790,12 +5814,12 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
|
|
5790
5814
|
}
|
5791
5815
|
}
|
5792
5816
|
};
|
5793
|
-
_this21 = _super28.call(this, e, AzureUtils.buildSpeechToTextHeaders, t.region, n, s), _this21.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Azure Speech To Text</b></div>\n <p><b>Upload a .wav or .ogg audio file</b> to transcribe it into text.\n <p>\n Click <a href=\"".concat(
|
5817
|
+
_this21 = _super28.call(this, e, AzureUtils.buildSpeechToTextHeaders, t.region, n, s), _this21.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Azure Speech To Text</b></div>\n <p><b>Upload a .wav or .ogg audio file</b> to transcribe it into text.\n <p>\n Click <a href=\"".concat(U.HELP_LINK, "\">here</a> for more info.\n </p>"), _this21.url = "", _this21.isTextInputDisabled = !0, _this21.textInputPlaceholderText = "Upload an audio file", _this21.canSendMessage = U.canFileSendMessage;
|
5794
5818
|
var o = t.lang || "en-US";
|
5795
5819
|
_this21.url = "https://".concat(t.region, ".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(o, "&format=detailed"), _this21.recordAudio = void 0;
|
5796
5820
|
return _this21;
|
5797
5821
|
}
|
5798
|
-
_createClass(
|
5822
|
+
_createClass(U, [{
|
5799
5823
|
key: "callServiceAPI",
|
5800
5824
|
value: function () {
|
5801
5825
|
var _callServiceAPI14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(e, t, n) {
|
@@ -5822,7 +5846,7 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
|
|
5822
5846
|
}
|
5823
5847
|
}, _callee52, this);
|
5824
5848
|
}));
|
5825
|
-
function callServiceAPI(_x91, _x92
|
5849
|
+
function callServiceAPI(_x90, _x91, _x92) {
|
5826
5850
|
return _callServiceAPI14.apply(this, arguments);
|
5827
5851
|
}
|
5828
5852
|
return callServiceAPI;
|
@@ -5849,7 +5873,7 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
|
|
5849
5873
|
}
|
5850
5874
|
}, _callee53);
|
5851
5875
|
}));
|
5852
|
-
function extractResultData(
|
5876
|
+
function extractResultData(_x93) {
|
5853
5877
|
return _extractResultData18.apply(this, arguments);
|
5854
5878
|
}
|
5855
5879
|
return extractResultData;
|
@@ -5860,7 +5884,7 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
|
|
5860
5884
|
return !!(t != null && t[0]);
|
5861
5885
|
}
|
5862
5886
|
}]);
|
5863
|
-
return
|
5887
|
+
return U;
|
5864
5888
|
}(AzureSpeechIO);
|
5865
5889
|
_AzureSpeechToTextIO.HELP_LINK =
|
5866
5890
|
// eslint-disable-next-line max-len
|
@@ -5911,7 +5935,7 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
|
|
5911
5935
|
}
|
5912
5936
|
}, _callee54, this);
|
5913
5937
|
}));
|
5914
|
-
function callServiceAPI(
|
5938
|
+
function callServiceAPI(_x94, _x95) {
|
5915
5939
|
return _callServiceAPI15.apply(this, arguments);
|
5916
5940
|
}
|
5917
5941
|
return callServiceAPI;
|
@@ -5939,7 +5963,7 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
|
|
5939
5963
|
}
|
5940
5964
|
}, _callee55);
|
5941
5965
|
}));
|
5942
|
-
function extractResultData(
|
5966
|
+
function extractResultData(_x96) {
|
5943
5967
|
return _extractResultData19.apply(this, arguments);
|
5944
5968
|
}
|
5945
5969
|
return extractResultData;
|
@@ -6040,7 +6064,7 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6040
6064
|
}
|
6041
6065
|
}, _callee56, this);
|
6042
6066
|
}));
|
6043
|
-
function callServiceAPI(_x98, _x99
|
6067
|
+
function callServiceAPI(_x97, _x98, _x99) {
|
6044
6068
|
return _callServiceAPI16.apply(this, arguments);
|
6045
6069
|
}
|
6046
6070
|
return callServiceAPI;
|
@@ -6075,7 +6099,7 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6075
6099
|
}
|
6076
6100
|
}, _callee57);
|
6077
6101
|
}));
|
6078
|
-
function extractResultData(
|
6102
|
+
function extractResultData(_x100) {
|
6079
6103
|
return _extractResultData20.apply(this, arguments);
|
6080
6104
|
}
|
6081
6105
|
return extractResultData;
|
@@ -6109,27 +6133,27 @@ _OpenAIImagesIO.IMAGE_VARIATIONS_URL = "https://api.openai.com/v1/images/variati
|
|
6109
6133
|
_OpenAIImagesIO.IMAGE_EDIT_URL = "https://api.openai.com/v1/images/edits";
|
6110
6134
|
var OpenAIImagesIO = _OpenAIImagesIO;
|
6111
6135
|
var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
|
6112
|
-
_inherits(
|
6113
|
-
var _super31 = _createSuper(
|
6114
|
-
function
|
6136
|
+
_inherits(M, _DirectServiceIO10);
|
6137
|
+
var _super31 = _createSuper(M);
|
6138
|
+
function M(e) {
|
6115
6139
|
var _l$model2;
|
6116
6140
|
var _this24;
|
6117
|
-
_classCallCheck(this,
|
6141
|
+
_classCallCheck(this, M);
|
6118
6142
|
var a, l;
|
6119
6143
|
var t = e.directConnection,
|
6120
6144
|
n = e.textInput,
|
6121
6145
|
s = t == null ? void 0 : t.openAI;
|
6122
6146
|
_this24 = _super31.call(this, e, OpenAIUtils.buildKeyVerificationDetails(), OpenAIUtils.buildHeaders, s, {
|
6123
6147
|
audio: {}
|
6124
|
-
}), _this24.insertKeyPlaceholderText = "OpenAI API Key", _this24.getKeyLink = "https://platform.openai.com/account/api-keys", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI Whisper</b></div>\n <p><b>Upload an audio file</b> to transcribe it into text. You can optionally provide text to guide the audio\n processing.\n <p>Click <a href=\"https://platform.openai.com/docs/api-reference/audio/create\">here</a> for more info.</p>", _this24.url = "", _this24.permittedErrorPrefixes = ["Invalid"], _this24._maxCharLength = OpenAIUtils.FILE_MAX_CHAR_LENGTH, _this24._service_url =
|
6148
|
+
}), _this24.insertKeyPlaceholderText = "OpenAI API Key", _this24.getKeyLink = "https://platform.openai.com/account/api-keys", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI Whisper</b></div>\n <p><b>Upload an audio file</b> to transcribe it into text. You can optionally provide text to guide the audio\n processing.\n <p>Click <a href=\"https://platform.openai.com/docs/api-reference/audio/create\">here</a> for more info.</p>", _this24.url = "", _this24.permittedErrorPrefixes = ["Invalid"], _this24._maxCharLength = OpenAIUtils.FILE_MAX_CHAR_LENGTH, _this24._service_url = M.AUDIO_TRANSCRIPTIONS_URL, n != null && n.characterLimit && (_this24._maxCharLength = n.characterLimit);
|
6125
6149
|
var o = (a = t == null ? void 0 : t.openAI) == null ? void 0 : a.audio;
|
6126
|
-
_typeof(o) == "object" && (_this24.processConfig(o),
|
6150
|
+
_typeof(o) == "object" && (_this24.processConfig(o), M.cleanConfig(o), Object.assign(_this24.rawBody, o)), (_l$model2 = (l = _this24.rawBody).model) !== null && _l$model2 !== void 0 ? _l$model2 : l.model = M.DEFAULT_MODEL, _this24.rawBody.response_format = "json", _this24.canSendMessage = M.canSendFileMessage;
|
6127
6151
|
return _this24;
|
6128
6152
|
}
|
6129
|
-
_createClass(
|
6153
|
+
_createClass(M, [{
|
6130
6154
|
key: "processConfig",
|
6131
6155
|
value: function processConfig(e) {
|
6132
|
-
e != null && e.type && e.type === "translation" && (this._service_url =
|
6156
|
+
e != null && e.type && e.type === "translation" && (this._service_url = M.AUDIO_TRANSLATIONS_URL, delete e.language);
|
6133
6157
|
}
|
6134
6158
|
}, {
|
6135
6159
|
key: "preprocessBody",
|
@@ -6165,7 +6189,7 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
|
|
6165
6189
|
throw new Error("No file was added");
|
6166
6190
|
case 4:
|
6167
6191
|
this.url = this.requestSettings.url || this._service_url;
|
6168
|
-
s = this.preprocessBody(this.rawBody, t, n), o =
|
6192
|
+
s = this.preprocessBody(this.rawBody, t, n), o = M.createFormDataBody(s, n[0]);
|
6169
6193
|
RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, o, e), !1);
|
6170
6194
|
case 7:
|
6171
6195
|
case "end":
|
@@ -6173,7 +6197,7 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
|
|
6173
6197
|
}
|
6174
6198
|
}, _callee58, this);
|
6175
6199
|
}));
|
6176
|
-
function callServiceAPI(_x102, _x103
|
6200
|
+
function callServiceAPI(_x101, _x102, _x103) {
|
6177
6201
|
return _callServiceAPI17.apply(this, arguments);
|
6178
6202
|
}
|
6179
6203
|
return callServiceAPI;
|
@@ -6200,7 +6224,7 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
|
|
6200
6224
|
}
|
6201
6225
|
}, _callee59);
|
6202
6226
|
}));
|
6203
|
-
function extractResultData(
|
6227
|
+
function extractResultData(_x104) {
|
6204
6228
|
return _extractResultData21.apply(this, arguments);
|
6205
6229
|
}
|
6206
6230
|
return extractResultData;
|
@@ -6224,7 +6248,7 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
|
|
6224
6248
|
}), n;
|
6225
6249
|
}
|
6226
6250
|
}]);
|
6227
|
-
return
|
6251
|
+
return M;
|
6228
6252
|
}(DirectServiceIO);
|
6229
6253
|
_OpenAIAudioIO.AUDIO_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions";
|
6230
6254
|
_OpenAIAudioIO.AUDIO_TRANSLATIONS_URL = "https://api.openai.com/v1/audio/translations";
|
@@ -6285,7 +6309,7 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
|
|
6285
6309
|
}
|
6286
6310
|
}, _callee60, this);
|
6287
6311
|
}));
|
6288
|
-
function callServiceAPI(
|
6312
|
+
function callServiceAPI(_x105, _x106) {
|
6289
6313
|
return _callServiceAPI18.apply(this, arguments);
|
6290
6314
|
}
|
6291
6315
|
return callServiceAPI;
|
@@ -6316,7 +6340,7 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
|
|
6316
6340
|
}
|
6317
6341
|
}, _callee61);
|
6318
6342
|
}));
|
6319
|
-
function extractResultData(
|
6343
|
+
function extractResultData(_x107) {
|
6320
6344
|
return _extractResultData22.apply(this, arguments);
|
6321
6345
|
}
|
6322
6346
|
return extractResultData;
|
@@ -6383,7 +6407,7 @@ var CohereChatIO = /*#__PURE__*/function (_CohereIO3) {
|
|
6383
6407
|
}
|
6384
6408
|
}, _callee62, this);
|
6385
6409
|
}));
|
6386
|
-
function callServiceAPI(
|
6410
|
+
function callServiceAPI(_x108, _x109) {
|
6387
6411
|
return _callServiceAPI19.apply(this, arguments);
|
6388
6412
|
}
|
6389
6413
|
return callServiceAPI;
|
@@ -6410,7 +6434,7 @@ var CohereChatIO = /*#__PURE__*/function (_CohereIO3) {
|
|
6410
6434
|
}
|
6411
6435
|
}, _callee63);
|
6412
6436
|
}));
|
6413
|
-
function extractResultData(
|
6437
|
+
function extractResultData(_x110) {
|
6414
6438
|
return _extractResultData23.apply(this, arguments);
|
6415
6439
|
}
|
6416
6440
|
return extractResultData;
|
@@ -6512,6 +6536,11 @@ var FireEvents = /*#__PURE__*/function () {
|
|
6512
6536
|
detail: s
|
6513
6537
|
}));
|
6514
6538
|
}
|
6539
|
+
}, {
|
6540
|
+
key: "onClearMessages",
|
6541
|
+
value: function onClearMessages(e) {
|
6542
|
+
e.onClearMessages(), e.dispatchEvent(new CustomEvent("clear-messages"));
|
6543
|
+
}
|
6515
6544
|
}, {
|
6516
6545
|
key: "onRender",
|
6517
6546
|
value: function onRender(e) {
|
@@ -6682,6 +6711,11 @@ var IntroPanel = /*#__PURE__*/function () {
|
|
6682
6711
|
value: function hide() {
|
6683
6712
|
this._isDisplayed && this._elementRef && (this._elementRef.style.display = "none", this._isDisplayed = !1);
|
6684
6713
|
}
|
6714
|
+
}, {
|
6715
|
+
key: "display",
|
6716
|
+
value: function display() {
|
6717
|
+
!this._isDisplayed && this._elementRef && (this._elementRef.style.display = "", this._isDisplayed = !0);
|
6718
|
+
}
|
6685
6719
|
}], [{
|
6686
6720
|
key: "createIntroPanel",
|
6687
6721
|
value: function createIntroPanel(e) {
|
@@ -6753,6 +6787,8 @@ var FileMessages = /*#__PURE__*/function () {
|
|
6753
6787
|
var n = new Image();
|
6754
6788
|
return n.src = e.src, FileMessageUtils.scrollDownOnImageLoad(n.src, t), FileMessageUtils.processContent(n, n.src);
|
6755
6789
|
}
|
6790
|
+
// WORK - should base64 images be clickable?
|
6791
|
+
// WORK - image still does not scroll down when loaded
|
6756
6792
|
}, {
|
6757
6793
|
key: "addNewImageMessage",
|
6758
6794
|
value: function () {
|
@@ -6773,7 +6809,7 @@ var FileMessages = /*#__PURE__*/function () {
|
|
6773
6809
|
}
|
6774
6810
|
}, _callee64);
|
6775
6811
|
}));
|
6776
|
-
function addNewImageMessage(_x112, _x113
|
6812
|
+
function addNewImageMessage(_x111, _x112, _x113) {
|
6777
6813
|
return _addNewImageMessage.apply(this, arguments);
|
6778
6814
|
}
|
6779
6815
|
return addNewImageMessage;
|
@@ -6911,9 +6947,9 @@ var Messages = /*#__PURE__*/function () {
|
|
6911
6947
|
var s = t.permittedErrorPrefixes,
|
6912
6948
|
o = t.introPanelMarkUp,
|
6913
6949
|
a = t.demo;
|
6914
|
-
this._remarkable = RemarkableConfig.createNew(), this.elementRef = Messages.createContainerElement(), this.messageStyles = e.messageStyles, this._avatars = e.avatars, this._names = e.names, this._errorMessageOverrides = (l = e.errorMessages) == null ? void 0 : l.overrides, this._onNewMessage = FireEvents.onNewMessage.bind(this, e), this._displayLoadingMessage = Messages.getDisplayLoadingMessage(e, t), this._permittedErrorPrefixes = s, this.populateIntroPanel(n, o, e.introPanelStyle), e.introMessage && this.addIntroductoryMessage(e.introMessage), e.initialMessages && this.populateInitialMessages(e.initialMessages), this.displayServiceErrorMessages = (c = e.errorMessages) == null ? void 0 : c.displayServiceErrorMessages, e.getMessages = function () {
|
6950
|
+
this._remarkable = RemarkableConfig.createNew(), this.elementRef = Messages.createContainerElement(), this.messageStyles = e.messageStyles, this._avatars = e.avatars, this._names = e.names, this._errorMessageOverrides = (l = e.errorMessages) == null ? void 0 : l.overrides, this._onNewMessage = FireEvents.onNewMessage.bind(this, e), this._onClearMessages = FireEvents.onClearMessages.bind(this, e), this._displayLoadingMessage = Messages.getDisplayLoadingMessage(e, t), this._permittedErrorPrefixes = s, this.populateIntroPanel(n, o, e.introPanelStyle), e.introMessage && this.addIntroductoryMessage(e.introMessage), e.initialMessages && this.populateInitialMessages(e.initialMessages), this.displayServiceErrorMessages = (c = e.errorMessages) == null ? void 0 : c.displayServiceErrorMessages, e.getMessages = function () {
|
6915
6951
|
return JSON.parse(JSON.stringify(_this28.messages));
|
6916
|
-
}, e.refreshMessages = this.refreshTextMessages.bind(this), a && this.prepareDemo(a), e.textToSpeech && TextToSpeech.processConfig(e.textToSpeech, function (u) {
|
6952
|
+
}, e.clearMessages = this.clearMessages.bind(this), e.refreshMessages = this.refreshTextMessages.bind(this), a && this.prepareDemo(a), e.textToSpeech && TextToSpeech.processConfig(e.textToSpeech, function (u) {
|
6917
6953
|
_this28._textToSpeech = u;
|
6918
6954
|
});
|
6919
6955
|
}
|
@@ -6925,9 +6961,11 @@ var Messages = /*#__PURE__*/function () {
|
|
6925
6961
|
}, {
|
6926
6962
|
key: "addIntroductoryMessage",
|
6927
6963
|
value: function addIntroductoryMessage(e) {
|
6928
|
-
var
|
6929
|
-
|
6930
|
-
|
6964
|
+
var t;
|
6965
|
+
if (e && (this._introMessage = e), this._introMessage) {
|
6966
|
+
var n = this.createAndAppendNewMessageElement(this._introMessage, !0);
|
6967
|
+
this.applyCustomStyles(n, !0, !1, (t = this.messageStyles) == null ? void 0 : t.intro);
|
6968
|
+
}
|
6931
6969
|
}
|
6932
6970
|
}, {
|
6933
6971
|
key: "populateInitialMessages",
|
@@ -7048,6 +7086,11 @@ var Messages = /*#__PURE__*/function () {
|
|
7048
7086
|
var e, t, n, s, o;
|
7049
7087
|
return (o = (s = (n = (t = (e = this.elementRef.children[this.elementRef.children.length - 1]) == null ? void 0 : e.children) == null ? void 0 : t[0]) == null ? void 0 : n.children) == null ? void 0 : s[0]) == null ? void 0 : o.classList.contains("error-message-text");
|
7050
7088
|
}
|
7089
|
+
}, {
|
7090
|
+
key: "removeError",
|
7091
|
+
value: function removeError() {
|
7092
|
+
this.isLastMessageError() && this.elementRef.children[this.elementRef.children.length - 1].remove();
|
7093
|
+
}
|
7051
7094
|
}, {
|
7052
7095
|
key: "addLoadingMessage",
|
7053
7096
|
value: function addLoadingMessage() {
|
@@ -7125,22 +7168,21 @@ var Messages = /*#__PURE__*/function () {
|
|
7125
7168
|
}
|
7126
7169
|
}, _callee65);
|
7127
7170
|
}));
|
7128
|
-
function addMultipleFiles(
|
7171
|
+
function addMultipleFiles(_x114) {
|
7129
7172
|
return _addMultipleFiles.apply(this, arguments);
|
7130
7173
|
}
|
7131
7174
|
return addMultipleFiles;
|
7132
|
-
}()
|
7133
|
-
|
7134
|
-
|
7135
|
-
|
7136
|
-
|
7137
|
-
|
7138
|
-
|
7139
|
-
|
7140
|
-
|
7141
|
-
|
7142
|
-
|
7143
|
-
// }
|
7175
|
+
}()
|
7176
|
+
}, {
|
7177
|
+
key: "clearMessages",
|
7178
|
+
value: function clearMessages(e) {
|
7179
|
+
var n, s;
|
7180
|
+
var t = [];
|
7181
|
+
this._messageElementRefs.forEach(function (o) {
|
7182
|
+
var a = o.bubbleElement.classList;
|
7183
|
+
a.contains("loading-message-text") || a.contains("streamed-message") ? t.push(o) : o.outerContainer.remove();
|
7184
|
+
}), this._messageElementRefs = t, e !== !1 && ((n = this._introPanel) != null && n._elementRef && this._introPanel.display(), this.addIntroductoryMessage()), (s = this._onClearMessages) == null || s.call(this);
|
7185
|
+
}
|
7144
7186
|
// this is mostly used for enabling highlight.js to highlight code if it is downloads later
|
7145
7187
|
}, {
|
7146
7188
|
key: "refreshTextMessages",
|
@@ -7872,18 +7914,18 @@ var FileAttachmentsType = /*#__PURE__*/function () {
|
|
7872
7914
|
var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <title>play</title>\n <path d=\"M5.92 24.096q0 1.088 0.928 1.728 0.512 0.288 1.088 0.288 0.448 0 0.896-0.224l16.16-8.064q0.48-0.256 0.8-0.736t0.288-1.088-0.288-1.056-0.8-0.736l-16.16-8.064q-0.448-0.224-0.896-0.224-0.544 0-1.088 0.288-0.928 0.608-0.928 1.728v16.16z\"></path>\n</svg>",
|
7873
7915
|
STOP_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n<title>stop</title>\n<path d=\"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z\"></path>\n</svg>",
|
7874
7916
|
_AudioFileAttachmentType = /*#__PURE__*/function (_FileAttachmentsType) {
|
7875
|
-
_inherits(
|
7876
|
-
var _super35 = _createSuper(
|
7877
|
-
function
|
7878
|
-
_classCallCheck(this,
|
7917
|
+
_inherits(k, _FileAttachmentsType);
|
7918
|
+
var _super35 = _createSuper(k);
|
7919
|
+
function k(e, t, n) {
|
7920
|
+
_classCallCheck(this, k);
|
7879
7921
|
return _super35.call(this, e, t, n);
|
7880
7922
|
}
|
7881
|
-
_createClass(
|
7923
|
+
_createClass(k, [{
|
7882
7924
|
key: "createTimer",
|
7883
7925
|
value: function createTimer(e, t) {
|
7884
7926
|
var _this37 = this;
|
7885
7927
|
var n = 0;
|
7886
|
-
var s = t !== void 0 && t <
|
7928
|
+
var s = t !== void 0 && t < k.TIMER_LIMIT_S ? t : k.TIMER_LIMIT_S;
|
7887
7929
|
return setInterval(function () {
|
7888
7930
|
var l;
|
7889
7931
|
n += 1, n === s && ((l = _this37.stopPlaceholderCallback) == null || l.call(_this37), _this37.clearTimer()), n === 600 && e.classList.add("audio-placeholder-text-4-digits");
|
@@ -7895,7 +7937,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
|
|
7895
7937
|
}, {
|
7896
7938
|
key: "createPlaceholderAudioAttachment",
|
7897
7939
|
value: function createPlaceholderAudioAttachment(e) {
|
7898
|
-
var t =
|
7940
|
+
var t = k.createAudioContainer(),
|
7899
7941
|
n = document.createElement("div");
|
7900
7942
|
n.classList.add("audio-placeholder-text-3-digits");
|
7901
7943
|
var s = document.createElement("div");
|
@@ -7932,7 +7974,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
|
|
7932
7974
|
key: "completePlaceholderAttachment",
|
7933
7975
|
value: function completePlaceholderAttachment(e, t) {
|
7934
7976
|
var n = this._activePlaceholderAttachment;
|
7935
|
-
n && (n.file = e,
|
7977
|
+
n && (n.file = e, k.addAudioElements(n.attachmentContainerElement.children[0], t), n.removeButton = this.createRemoveAttachmentButton(n), n.attachmentContainerElement.appendChild(n.removeButton), this._activePlaceholderAttachment = void 0, this.clearTimer());
|
7936
7978
|
}
|
7937
7979
|
}, {
|
7938
7980
|
key: "removePlaceholderAttachment",
|
@@ -7972,8 +8014,8 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
|
|
7972
8014
|
}, {
|
7973
8015
|
key: "createAudioAttachment",
|
7974
8016
|
value: function createAudioAttachment(e) {
|
7975
|
-
var t =
|
7976
|
-
return
|
8017
|
+
var t = k.createAudioContainer();
|
8018
|
+
return k.addAudioElements(t, e), t;
|
7977
8019
|
}
|
7978
8020
|
}, {
|
7979
8021
|
key: "stopAttachmentPlayback",
|
@@ -7982,7 +8024,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
|
|
7982
8024
|
(s = (n = (t = e.children[0]) == null ? void 0 : t.children) == null ? void 0 : n[0]) != null && s.classList.contains("stop-icon") && e.children[0].click();
|
7983
8025
|
}
|
7984
8026
|
}]);
|
7985
|
-
return
|
8027
|
+
return k;
|
7986
8028
|
}(FileAttachmentsType);
|
7987
8029
|
_AudioFileAttachmentType.TIMER_LIMIT_S = 5999;
|
7988
8030
|
var AudioFileAttachmentType = _AudioFileAttachmentType;
|
@@ -8054,7 +8096,7 @@ var FileAttachments = /*#__PURE__*/function () {
|
|
8054
8096
|
}
|
8055
8097
|
}, _callee66);
|
8056
8098
|
}));
|
8057
|
-
return function (
|
8099
|
+
return function (_x115) {
|
8058
8100
|
return _ref6.apply(this, arguments);
|
8059
8101
|
};
|
8060
8102
|
}()));
|
@@ -9301,7 +9343,7 @@ var AzureSpeechConfig = /*#__PURE__*/function () {
|
|
9301
9343
|
}
|
9302
9344
|
}, _callee68);
|
9303
9345
|
}));
|
9304
|
-
function getNewSpeechConfig(
|
9346
|
+
function getNewSpeechConfig(_x116, _x117) {
|
9305
9347
|
return _getNewSpeechConfig.apply(this, arguments);
|
9306
9348
|
}
|
9307
9349
|
return getNewSpeechConfig;
|
@@ -9330,7 +9372,7 @@ var AzureSpeechConfig = /*#__PURE__*/function () {
|
|
9330
9372
|
}
|
9331
9373
|
}, _callee69);
|
9332
9374
|
}));
|
9333
|
-
function get(
|
9375
|
+
function get(_x118, _x119) {
|
9334
9376
|
return _get.apply(this, arguments);
|
9335
9377
|
}
|
9336
9378
|
return get;
|
@@ -9441,7 +9483,7 @@ var Azure = /*#__PURE__*/function (_speech_1$Speech) {
|
|
9441
9483
|
}
|
9442
9484
|
}, _callee70, this);
|
9443
9485
|
}));
|
9444
|
-
function startAsync(
|
9486
|
+
function startAsync(_x120) {
|
9445
9487
|
return _startAsync.apply(this, arguments);
|
9446
9488
|
}
|
9447
9489
|
return startAsync;
|
@@ -9475,7 +9517,7 @@ var Azure = /*#__PURE__*/function (_speech_1$Speech) {
|
|
9475
9517
|
}
|
9476
9518
|
}, _callee71, this);
|
9477
9519
|
}));
|
9478
|
-
function instantiateService(
|
9520
|
+
function instantiateService(_x121) {
|
9479
9521
|
return _instantiateService.apply(this, arguments);
|
9480
9522
|
}
|
9481
9523
|
return instantiateService;
|
@@ -9849,11 +9891,13 @@ var SubmitButton = /*#__PURE__*/function (_InputButton4) {
|
|
9849
9891
|
}
|
9850
9892
|
// TO-DO - button should be disabled if validateMessageBeforeSending is not valid
|
9851
9893
|
// TO-DO - button should be disabled if websocket connection is not open
|
9894
|
+
// TO-DO - should be disabled when websocket is connecting and option when loading history
|
9895
|
+
// prettier-ignore
|
9852
9896
|
}, {
|
9853
9897
|
key: "submit",
|
9854
9898
|
value: function () {
|
9855
9899
|
var _submit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(e, t) {
|
9856
|
-
var
|
9900
|
+
var c, u, n, s, o, a, l;
|
9857
9901
|
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
9858
9902
|
while (1) switch (_context72.prev = _context72.next) {
|
9859
9903
|
case 0:
|
@@ -9866,8 +9910,8 @@ var SubmitButton = /*#__PURE__*/function (_InputButton4) {
|
|
9866
9910
|
return this._fileAttachments.completePlaceholders();
|
9867
9911
|
case 4:
|
9868
9912
|
n = this._fileAttachments.getAllFileData();
|
9869
|
-
s = n == null ? void 0 : n.map(function (
|
9870
|
-
return
|
9913
|
+
s = n == null ? void 0 : n.map(function (d) {
|
9914
|
+
return d.file;
|
9871
9915
|
});
|
9872
9916
|
case 6:
|
9873
9917
|
o = t === "" ? void 0 : t;
|
@@ -9877,54 +9921,61 @@ var SubmitButton = /*#__PURE__*/function (_InputButton4) {
|
|
9877
9921
|
}
|
9878
9922
|
return _context72.abrupt("return");
|
9879
9923
|
case 9:
|
9880
|
-
|
9881
|
-
|
9924
|
+
a = this._serviceIO.websocket;
|
9925
|
+
if (!(a && (a === "pending" || a.readyState === void 0 || a.readyState !== a.OPEN))) {
|
9926
|
+
_context72.next = 12;
|
9927
|
+
break;
|
9928
|
+
}
|
9929
|
+
return _context72.abrupt("return");
|
9930
|
+
case 12:
|
9931
|
+
if (!((c = this._serviceIO.deepChat) != null && c.validateMessageBeforeSending)) {
|
9932
|
+
_context72.next = 17;
|
9882
9933
|
break;
|
9883
9934
|
}
|
9884
9935
|
if (this._serviceIO.deepChat.validateMessageBeforeSending(o, s)) {
|
9885
|
-
_context72.next =
|
9936
|
+
_context72.next = 15;
|
9886
9937
|
break;
|
9887
9938
|
}
|
9888
9939
|
return _context72.abrupt("return");
|
9889
|
-
case
|
9890
|
-
_context72.next =
|
9940
|
+
case 15:
|
9941
|
+
_context72.next = 19;
|
9891
9942
|
break;
|
9892
|
-
case
|
9943
|
+
case 17:
|
9893
9944
|
if (this._serviceIO.canSendMessage(o, s)) {
|
9894
|
-
_context72.next =
|
9945
|
+
_context72.next = 19;
|
9895
9946
|
break;
|
9896
9947
|
}
|
9897
9948
|
return _context72.abrupt("return");
|
9898
|
-
case
|
9949
|
+
case 19:
|
9899
9950
|
this.changeToLoadingIcon();
|
9900
9951
|
t !== "" && this._messages.addNewMessage({
|
9901
9952
|
text: t
|
9902
9953
|
}, !1, !0);
|
9903
9954
|
_context72.t1 = n;
|
9904
9955
|
if (!_context72.t1) {
|
9905
|
-
_context72.next =
|
9956
|
+
_context72.next = 25;
|
9906
9957
|
break;
|
9907
9958
|
}
|
9908
|
-
_context72.next =
|
9959
|
+
_context72.next = 25;
|
9909
9960
|
return this._messages.addMultipleFiles(n);
|
9910
|
-
case
|
9961
|
+
case 25:
|
9911
9962
|
this._messages.addLoadingMessage();
|
9912
9963
|
e || TextInputEl.clear(this._inputElementRef);
|
9913
|
-
|
9964
|
+
l = {
|
9914
9965
|
text: o,
|
9915
9966
|
files: s
|
9916
9967
|
};
|
9917
|
-
_context72.next =
|
9918
|
-
return this._serviceIO.callAPI(
|
9919
|
-
case
|
9920
|
-
e || (
|
9921
|
-
case
|
9968
|
+
_context72.next = 30;
|
9969
|
+
return this._serviceIO.callAPI(l, this._messages);
|
9970
|
+
case 30:
|
9971
|
+
e || (u = this._fileAttachments) == null || u.removeAllFiles();
|
9972
|
+
case 31:
|
9922
9973
|
case "end":
|
9923
9974
|
return _context72.stop();
|
9924
9975
|
}
|
9925
9976
|
}, _callee72, this);
|
9926
9977
|
}));
|
9927
|
-
function submit(
|
9978
|
+
function submit(_x122, _x123) {
|
9928
9979
|
return _submit.apply(this, arguments);
|
9929
9980
|
}
|
9930
9981
|
return submit;
|
@@ -10229,7 +10280,7 @@ var ChatView = /*#__PURE__*/function () {
|
|
10229
10280
|
var s = document.createElement("div");
|
10230
10281
|
s.id = "chat-view";
|
10231
10282
|
var o = new Messages(e, t, n);
|
10232
|
-
t.websocket && Websocket.
|
10283
|
+
t.websocket && Websocket.createConnection(t, o);
|
10233
10284
|
var a = new Input(e, o, t, s);
|
10234
10285
|
return ElementUtils.addElements(s, o.elementRef, a.elementRef), s;
|
10235
10286
|
}
|
@@ -10262,7 +10313,7 @@ var DeepChat = /*#__PURE__*/function (_InternalHTML2) {
|
|
10262
10313
|
return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");
|
10263
10314
|
}, _this60.focusInput = function () {
|
10264
10315
|
FocusUtils.focusFromParentElement(_this60._elementRef);
|
10265
|
-
}, _this60.refreshMessages = function () {}, _this60.onNewMessage = function () {}, _this60.onComponentRender = function () {}, _this60._hasBeenRendered = !1, _this60._auxiliaryStyleApplied = !1, GoogleFont.appendStyleSheetToHead(), _this60._elementRef = document.createElement("div"), _this60._elementRef.id = "container", _this60.attachShadow({
|
10316
|
+
}, _this60.refreshMessages = function () {}, _this60.clearMessages = function () {}, _this60.onNewMessage = function () {}, _this60.onClearMessages = function () {}, _this60.onComponentRender = function () {}, _this60._hasBeenRendered = !1, _this60._auxiliaryStyleApplied = !1, GoogleFont.appendStyleSheetToHead(), _this60._elementRef = document.createElement("div"), _this60._elementRef.id = "container", _this60.attachShadow({
|
10266
10317
|
mode: "open"
|
10267
10318
|
}).appendChild(_this60._elementRef), WebComponentStyleUtils.apply(style, _this60.shadowRoot), setTimeout(function () {
|
10268
10319
|
_this60._hasBeenRendered || _this60.onRender();
|
@@ -10279,8 +10330,8 @@ var DeepChat = /*#__PURE__*/function (_InternalHTML2) {
|
|
10279
10330
|
key: "onRender",
|
10280
10331
|
value: function onRender() {
|
10281
10332
|
var _this$_activeService, _this$_childElement;
|
10282
|
-
var e, t;
|
10283
|
-
(_this$_activeService = this._activeService) !== null && _this$_activeService !== void 0 ? _this$_activeService : this._activeService = ServiceIOFactory.create(this), this._activeService && (this.auxiliaryStyle && !this._auxiliaryStyleApplied && (WebComponentStyleUtils.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), Object.assign(this._elementRef.style, this.containerStyle), this._activeService.key && this._activeService.validateConfigKey ? ValidateKeyPropertyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : this._activeService instanceof DirectServiceIO && this._activeService.key || (e = this.request) != null && e.url || (t = this.
|
10333
|
+
var e, t, n;
|
10334
|
+
(_this$_activeService = this._activeService) !== null && _this$_activeService !== void 0 ? _this$_activeService : this._activeService = ServiceIOFactory.create(this), this._activeService && (this.auxiliaryStyle && !this._auxiliaryStyleApplied && (WebComponentStyleUtils.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), Object.assign(this._elementRef.style, this.containerStyle), this._activeService.key && this._activeService.validateConfigKey ? ValidateKeyPropertyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : this._activeService instanceof DirectServiceIO && this._activeService.key || (e = this.request) != null && e.url || (t = this.request) != null && t.handler || (n = this.directConnection) != null && n.demo ? ((_this$_childElement = this._childElement) !== null && _this$_childElement !== void 0 ? _this$_childElement : this._childElement = this.children[0], ChatView.render(this, this._elementRef, this._activeService, this._childElement)) : this._activeService instanceof DirectServiceIO ? InsertKeyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : ErrorView.render(this._elementRef, 'Please define "request" with a "url"'), this._hasBeenRendered = !0, FireEvents.onRender(this));
|
10284
10335
|
}
|
10285
10336
|
}]);
|
10286
10337
|
return DeepChat;
|
@@ -10317,6 +10368,7 @@ __decorateClass([Property("object")], DeepChat.prototype, "mixedFiles", 2);
|
|
10317
10368
|
__decorateClass([Property("object")], DeepChat.prototype, "dragAndDrop", 2);
|
10318
10369
|
__decorateClass([Property("object")], DeepChat.prototype, "introPanelStyle", 2);
|
10319
10370
|
__decorateClass([Property("function")], DeepChat.prototype, "onNewMessage", 2);
|
10371
|
+
__decorateClass([Property("function")], DeepChat.prototype, "onClearMessages", 2);
|
10320
10372
|
__decorateClass([Property("function")], DeepChat.prototype, "onComponentRender", 2);
|
10321
10373
|
customElements.define("deep-chat", DeepChat);
|
10322
10374
|
export { DeepChat };
|