@difizen/libro-ai-native 0.2.41-next.2 → 0.2.41-next.4
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/es/ai-native-code-block.d.ts.map +1 -1
- package/es/ai-native-code-block.js +6 -5
- package/es/ai-native-command-contribution.d.ts.map +1 -1
- package/es/ai-native-command-contribution.js +60 -15
- package/es/ai-native-command.d.ts.map +1 -1
- package/es/ai-native-command.js +4 -0
- package/es/ai-native-for-cell-view.d.ts.map +1 -1
- package/es/ai-native-for-cell-view.js +41 -22
- package/es/ai-native-service.d.ts +3 -0
- package/es/ai-native-service.d.ts.map +1 -1
- package/es/ai-native-service.js +3 -0
- package/es/ai-side-toolbar-selector.js +4 -4
- package/es/chat-slot-contribution.d.ts.map +1 -1
- package/es/chat-slot-contribution.js +1 -2
- package/es/chat-view.d.ts +4 -1
- package/es/chat-view.d.ts.map +1 -1
- package/es/chat-view.js +109 -30
- package/es/error-output-model.d.ts.map +1 -1
- package/es/error-output-model.js +8 -5
- package/es/index.less +60 -27
- package/es/libro-ai-msg-item-model.d.ts.map +1 -1
- package/es/libro-ai-msg-item-model.js +1 -0
- package/es/libro-ai-native-chat-service.d.ts.map +1 -1
- package/es/libro-ai-native-chat-service.js +28 -20
- package/es/libro-ai-native-chat-view.d.ts +4 -1
- package/es/libro-ai-native-chat-view.d.ts.map +1 -1
- package/es/libro-ai-native-chat-view.js +8 -10
- package/es/protocol.d.ts +8 -2
- package/es/protocol.d.ts.map +1 -1
- package/es/utils.d.ts +6 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +15 -0
- package/package.json +2 -2
- package/src/ai-native-command-contribution.tsx +10 -6
- package/src/ai-native-for-cell-view.tsx +7 -1
- package/src/index.less +1 -1
- package/src/libro-ai-native-chat-service.ts +9 -2
package/es/chat-view.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
3
3
|
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
8
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
9
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
10
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -15,15 +15,20 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
15
15
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
16
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
17
17
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
19
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
20
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
21
|
import { CloseOutlined } from '@ant-design/icons';
|
|
19
22
|
import { LibroContextKey, LibroSlotManager, LibroSlotView } from '@difizen/libro-jupyter';
|
|
20
23
|
import { BaseView, prop, transient, view, inject, ViewManager, useInject, ViewInstance, ViewRender } from '@difizen/mana-app';
|
|
21
24
|
import { useRef } from 'react';
|
|
22
25
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
23
26
|
import { LibroAiNativeChatView } from "./libro-ai-native-chat-view.js";
|
|
27
|
+
import { cancelCellAIClassname } from "./utils.js";
|
|
24
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
30
|
export var ChatRender = function ChatRender() {
|
|
31
|
+
var _libroChatView$chatVi;
|
|
27
32
|
var containRef = useRef(null);
|
|
28
33
|
var libroChatView = useInject(ViewInstance);
|
|
29
34
|
var libroSlotManager = useInject(LibroSlotManager);
|
|
@@ -47,20 +52,43 @@ export var ChatRender = function ChatRender() {
|
|
|
47
52
|
className: "chat-right-toolbar",
|
|
48
53
|
children: [/*#__PURE__*/_jsx("div", {
|
|
49
54
|
className: "chat-type",
|
|
50
|
-
children: libroChatView.chatView.isCellChat ? 'Focused Cell' : 'General Chat'
|
|
55
|
+
children: (_libroChatView$chatVi = libroChatView.chatView) !== null && _libroChatView$chatVi !== void 0 && _libroChatView$chatVi.isCellChat ? 'Focused Cell' : 'General Chat'
|
|
51
56
|
}), /*#__PURE__*/_jsx("div", {
|
|
52
57
|
children: /*#__PURE__*/_jsx(CloseOutlined, {
|
|
53
58
|
className: "chat-close-icon",
|
|
54
|
-
onClick: function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
|
+
var _libroChatView$chatVi2, libroAINativeForCellView, slotview;
|
|
61
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
+
while (1) switch (_context.prev = _context.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (!libroChatView.parent) {
|
|
65
|
+
_context.next = 9;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (!((_libroChatView$chatVi2 = libroChatView.chatView) !== null && _libroChatView$chatVi2 !== void 0 && _libroChatView$chatVi2.cell)) {
|
|
69
|
+
_context.next = 6;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
_context.next = 4;
|
|
73
|
+
return libroAINativeService.getOrCreateLibroAINativeForCellView(libroChatView.chatView.cell.id, libroChatView.chatView.cell);
|
|
74
|
+
case 4:
|
|
75
|
+
libroAINativeForCellView = _context.sent;
|
|
76
|
+
if (!libroAINativeForCellView.showAI) {
|
|
77
|
+
cancelCellAIClassname(libroChatView.chatView.cell);
|
|
78
|
+
libroAINativeService.cellAIChatMap.set(libroChatView.chatView.cell.id, false);
|
|
79
|
+
}
|
|
80
|
+
case 6:
|
|
81
|
+
libroAINativeService.showChatMap.set(libroChatView.parent.id, false);
|
|
82
|
+
slotview = libroSlotManager.slotViewManager.getSlotView(libroSlotManager.getSlotName(libroChatView.parent, 'right'));
|
|
83
|
+
if (slotview instanceof LibroSlotView) {
|
|
84
|
+
slotview.revertActive();
|
|
85
|
+
}
|
|
86
|
+
case 9:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
61
89
|
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
90
|
+
}, _callee);
|
|
91
|
+
}))
|
|
64
92
|
})
|
|
65
93
|
})]
|
|
66
94
|
})]
|
|
@@ -69,42 +97,93 @@ export var ChatRender = function ChatRender() {
|
|
|
69
97
|
})]
|
|
70
98
|
});
|
|
71
99
|
};
|
|
72
|
-
export var LibroChatView = (_dec = transient(), _dec2 = view('libro-chat-view'), _dec3 = inject(ViewManager), _dec4 =
|
|
100
|
+
export var LibroChatView = (_dec = transient(), _dec2 = view('libro-chat-view'), _dec3 = inject(ViewManager), _dec4 = inject(LibroAINativeService), _dec5 = prop(), _dec6 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
73
101
|
_inherits(LibroChatView, _BaseView);
|
|
74
102
|
var _super = _createSuper(LibroChatView);
|
|
75
|
-
function LibroChatView(
|
|
103
|
+
function LibroChatView() {
|
|
76
104
|
var _this;
|
|
77
105
|
_classCallCheck(this, LibroChatView);
|
|
78
|
-
|
|
106
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
107
|
+
args[_key] = arguments[_key];
|
|
108
|
+
}
|
|
109
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
79
110
|
_this.parent = undefined;
|
|
80
111
|
_initializerDefineProperty(_this, "viewManager", _descriptor, _assertThisInitialized(_this));
|
|
112
|
+
_initializerDefineProperty(_this, "libroAINativeService", _descriptor2, _assertThisInitialized(_this));
|
|
81
113
|
_this.view = ChatRender;
|
|
82
|
-
_initializerDefineProperty(_this, "chatView",
|
|
83
|
-
_initializerDefineProperty(_this, "isDisplay",
|
|
84
|
-
viewManager.getOrCreateView(LibroAiNativeChatView, {
|
|
85
|
-
id: _this.id,
|
|
86
|
-
chat_key: 'LLM:chatgpt'
|
|
87
|
-
}).then(function (chatView) {
|
|
88
|
-
_this.chatView = chatView;
|
|
89
|
-
return;
|
|
90
|
-
}).catch(function () {
|
|
91
|
-
//
|
|
92
|
-
});
|
|
114
|
+
_initializerDefineProperty(_this, "chatView", _descriptor3, _assertThisInitialized(_this));
|
|
115
|
+
_initializerDefineProperty(_this, "isDisplay", _descriptor4, _assertThisInitialized(_this));
|
|
93
116
|
return _this;
|
|
94
117
|
}
|
|
95
|
-
|
|
96
|
-
|
|
118
|
+
_createClass(LibroChatView, [{
|
|
119
|
+
key: "setAINativeChatView",
|
|
120
|
+
value: function () {
|
|
121
|
+
var _setAINativeChatView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(option) {
|
|
122
|
+
var _this$chatView,
|
|
123
|
+
_this2 = this;
|
|
124
|
+
var _this$chatView2, _option$cell, libroAINativeForCellView;
|
|
125
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
126
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!((_this$chatView = this.chatView) !== null && _this$chatView !== void 0 && _this$chatView.cell)) {
|
|
129
|
+
_context2.next = 7;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (!(((_this$chatView2 = this.chatView) === null || _this$chatView2 === void 0 ? void 0 : _this$chatView2.cell.id) === ((_option$cell = option.cell) === null || _option$cell === void 0 ? void 0 : _option$cell.id))) {
|
|
133
|
+
_context2.next = 3;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
return _context2.abrupt("return");
|
|
137
|
+
case 3:
|
|
138
|
+
_context2.next = 5;
|
|
139
|
+
return this.libroAINativeService.getOrCreateLibroAINativeForCellView(this.chatView.cell.id, this.chatView.cell);
|
|
140
|
+
case 5:
|
|
141
|
+
libroAINativeForCellView = _context2.sent;
|
|
142
|
+
if (this.libroAINativeService.cellAIChatMap.get(this.chatView.cell.id) && !libroAINativeForCellView.showAI) {
|
|
143
|
+
cancelCellAIClassname(this.chatView.cell);
|
|
144
|
+
this.libroAINativeService.cellAIChatMap.set(this.chatView.cell.id, false);
|
|
145
|
+
}
|
|
146
|
+
case 7:
|
|
147
|
+
this.viewManager.getOrCreateView(LibroAiNativeChatView, option).then(function (chatView) {
|
|
148
|
+
chatView.libro = _this2.parent;
|
|
149
|
+
if (option.isCellChat && option.cell) {
|
|
150
|
+
chatView.cell = option.cell;
|
|
151
|
+
_this2.libroAINativeService.cellAIChatMap.set(option.cell.id, true);
|
|
152
|
+
}
|
|
153
|
+
_this2.chatView = chatView;
|
|
154
|
+
return;
|
|
155
|
+
}).catch(function () {
|
|
156
|
+
//
|
|
157
|
+
});
|
|
158
|
+
case 8:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context2.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee2, this);
|
|
163
|
+
}));
|
|
164
|
+
function setAINativeChatView(_x) {
|
|
165
|
+
return _setAINativeChatView.apply(this, arguments);
|
|
166
|
+
}
|
|
167
|
+
return setAINativeChatView;
|
|
168
|
+
}()
|
|
169
|
+
}]);
|
|
170
|
+
return LibroChatView;
|
|
97
171
|
}(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec3], {
|
|
98
172
|
configurable: true,
|
|
99
173
|
enumerable: true,
|
|
100
174
|
writable: true,
|
|
101
175
|
initializer: null
|
|
102
|
-
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "
|
|
176
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "libroAINativeService", [_dec4], {
|
|
177
|
+
configurable: true,
|
|
178
|
+
enumerable: true,
|
|
179
|
+
writable: true,
|
|
180
|
+
initializer: null
|
|
181
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "chatView", [_dec5], {
|
|
103
182
|
configurable: true,
|
|
104
183
|
enumerable: true,
|
|
105
184
|
writable: true,
|
|
106
185
|
initializer: null
|
|
107
|
-
}),
|
|
186
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "isDisplay", [_dec6], {
|
|
108
187
|
configurable: true,
|
|
109
188
|
enumerable: true,
|
|
110
189
|
writable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-output-model.d.ts","sourceRoot":"","sources":["../src/error-output-model.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,gBAAgB,EAIjB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"error-output-model.d.ts","sourceRoot":"","sources":["../src/error-output-model.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,gBAAgB,EAIjB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,cAAc,CAAC;AAmFtB,qBAEa,kBAAmB,SAAQ,gBAAgB;IAC7C,IAAI,2FAA4B;IACjC,QAAQ,UAAS;CAC1B"}
|
package/es/error-output-model.js
CHANGED
|
@@ -22,11 +22,13 @@ import { concatMultilineString } from '@difizen/libro-jupyter';
|
|
|
22
22
|
import { ErrorOutputModel, defaultSanitizer, RenderMimeRegistry, renderText } from '@difizen/libro-jupyter';
|
|
23
23
|
import { prop, transient } from '@difizen/mana-app';
|
|
24
24
|
import { getOrigin, useInject, view, ViewInstance } from '@difizen/mana-app';
|
|
25
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
25
26
|
import { Button } from 'antd';
|
|
26
27
|
import { forwardRef, createRef, useEffect } from 'react';
|
|
27
28
|
import "./index.less";
|
|
28
29
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
29
30
|
import { AIIcon } from "./icon.js";
|
|
31
|
+
import { addCellAIClassname } from "./utils.js";
|
|
30
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
33
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
34
|
var AIErrorOutputModelRender = /*#__PURE__*/forwardRef(function ErrorOutputModelRender(_props, ref) {
|
|
@@ -56,15 +58,16 @@ var AIErrorOutputModelRender = /*#__PURE__*/forwardRef(function ErrorOutputModel
|
|
|
56
58
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
59
|
while (1) switch (_context.prev = _context.next) {
|
|
58
60
|
case 0:
|
|
59
|
-
|
|
60
|
-
_context.next = 3;
|
|
61
|
+
_context.next = 2;
|
|
61
62
|
return libroAINativeService.getOrCreateLibroAINativeForCellView(output.cell.id, getOrigin(output.cell));
|
|
62
|
-
case
|
|
63
|
+
case 2:
|
|
63
64
|
libroAINativeForCellView = _context.sent;
|
|
65
|
+
addCellAIClassname(output.cell);
|
|
64
66
|
libroAINativeForCellView.showAI = true;
|
|
65
67
|
libroAINativeForCellView.chatStream({
|
|
66
|
-
chat_key: 'LLM:debug
|
|
67
|
-
content: "\u4EE3\u7801\u4E3A:\n".concat(output.cell.model.value, "\n\u62A5\u9519\u4E3A:\n").concat(concatMultilineString(source.traceback))
|
|
68
|
+
chat_key: 'LLM:debug',
|
|
69
|
+
content: "\u4EE3\u7801\u4E3A:\n".concat(output.cell.model.value, "\n\u62A5\u9519\u4E3A:\n").concat(concatMultilineString(source.traceback)),
|
|
70
|
+
language: l10n.getLang()
|
|
68
71
|
});
|
|
69
72
|
case 6:
|
|
70
73
|
case "end":
|
package/es/index.less
CHANGED
|
@@ -46,9 +46,13 @@
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.libro-
|
|
50
|
-
|
|
49
|
+
.libro-ai-native-cell-chat-icon {
|
|
50
|
+
svg {
|
|
51
|
+
color: var(--mana-libro-ai-native-color);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
51
54
|
|
|
55
|
+
.libro-view-content-right {
|
|
52
56
|
.libro-slot-container {
|
|
53
57
|
height: 100%;
|
|
54
58
|
}
|
|
@@ -70,7 +74,8 @@
|
|
|
70
74
|
border: 1px solid var(--mana-libro-ai-native-color);
|
|
71
75
|
box-shadow: var(--mana-libro-ai-native-box-shadow) 0 0 0 2px;
|
|
72
76
|
border-radius: 6px;
|
|
73
|
-
|
|
77
|
+
margin: 16px 0;
|
|
78
|
+
height: calc(100% - 32px);
|
|
74
79
|
width: 460px;
|
|
75
80
|
|
|
76
81
|
.chat {
|
|
@@ -86,11 +91,21 @@
|
|
|
86
91
|
cursor: pointer;
|
|
87
92
|
}
|
|
88
93
|
|
|
94
|
+
.chat-input-upload {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.chat-input-iconBottom {
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
89
103
|
.chat-input-searchInput:focus-within {
|
|
90
104
|
border-color: var(--mana-libro-ai-native-color);
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
.chat-input-sendButton {
|
|
108
|
+
margin: unset;
|
|
94
109
|
background-color: var(--mana-libro-ai-native-color);
|
|
95
110
|
}
|
|
96
111
|
|
|
@@ -107,36 +122,39 @@
|
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
.ai-cell-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
.libro-dnd-cell:has(.ai-cell-focus) {
|
|
126
|
+
&.active {
|
|
127
|
+
border: 1px solid var(--mana-libro-ai-native-color);
|
|
128
|
+
box-shadow: var(--mana-libro-ai-native-box-shadow) 0 0 0 2px;
|
|
129
|
+
|
|
130
|
+
.libro-cell-input-collapser,
|
|
131
|
+
.libro-cell-output-collapser,
|
|
132
|
+
.libro-cell-collapser {
|
|
133
|
+
background: var(--mana-libro-ai-native-color);
|
|
134
|
+
opacity: 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&.error {
|
|
113
138
|
border: 1px solid var(--mana-libro-ai-native-color);
|
|
114
139
|
box-shadow: var(--mana-libro-ai-native-box-shadow) 0 0 0 2px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
115
142
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
background: var(--mana-libro-ai-native-color);
|
|
120
|
-
opacity: 1;
|
|
121
|
-
}
|
|
143
|
+
&.error {
|
|
144
|
+
border: 1px solid var(--mana-libro-ai-native-color);
|
|
145
|
+
box-shadow: var(--mana-libro-ai-native-box-shadow) 0 0 0 2px;
|
|
122
146
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
.libro-cell-output-collapser,
|
|
129
|
-
.libro-cell-collapser {
|
|
130
|
-
background: var(--mana-libro-ai-native-color);
|
|
131
|
-
opacity: 1;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
147
|
+
.libro-cell-input-collapser,
|
|
148
|
+
.libro-cell-output-collapser,
|
|
149
|
+
.libro-cell-collapser {
|
|
150
|
+
background: var(--mana-libro-ai-native-color);
|
|
151
|
+
opacity: 1;
|
|
134
152
|
}
|
|
153
|
+
}
|
|
135
154
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
155
|
+
&.active.command-mode {
|
|
156
|
+
border: 1px solid var(--mana-libro-ai-native-color);
|
|
157
|
+
box-shadow: unset;
|
|
140
158
|
}
|
|
141
159
|
}
|
|
142
160
|
|
|
@@ -170,6 +188,16 @@
|
|
|
170
188
|
&:hover {
|
|
171
189
|
border-color: var(--mana-libro-ai-native-color) !important;
|
|
172
190
|
color: var(--mana-libro-ai-native-color) !important;
|
|
191
|
+
|
|
192
|
+
&.error {
|
|
193
|
+
border-color: var(--mana-libro-error-color) !important;
|
|
194
|
+
color: var(--mana-libro-error-color) !important;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&.error {
|
|
199
|
+
border-color: var(--mana-libro-error-color);
|
|
200
|
+
color: var(--mana-libro-error-color);
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
203
|
}
|
|
@@ -237,6 +265,7 @@
|
|
|
237
265
|
|
|
238
266
|
.libro-ai-native-for-cell-container {
|
|
239
267
|
display: flex;
|
|
268
|
+
padding-top: 18px;
|
|
240
269
|
justify-content: space-between;
|
|
241
270
|
}
|
|
242
271
|
|
|
@@ -295,3 +324,7 @@
|
|
|
295
324
|
color: var(--mana-libro-editor-class-color);
|
|
296
325
|
}
|
|
297
326
|
}
|
|
327
|
+
|
|
328
|
+
.libro-ai-native-for-cell-error {
|
|
329
|
+
color: var(--mana-libro-error-color);
|
|
330
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-ai-msg-item-model.d.ts","sourceRoot":"","sources":["../src/libro-ai-msg-item-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAI9B,qBACa,2BAA2B;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;IAG3B,KAAK,EAAE,WAAW,CAAC;IAGnB,SAAS,CAAC,QAAQ,SAAM;IACxB,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,IAAI,OAAO,CAAC,CAAC,EAHE,MAGF,EAEZ;IAED,MAAM,EAAE,gBAAgB,CAAC;IAGzB,KAAK,CAAC,EAAE,YAAY,CAAC;gBAEkB,MAAM,EAAE,gBAAgB;IAQ/D,eAAe,CAAC,CAAC,EAAE,UAAU;IAY7B,WAAW,CAAC,CAAC,EAAE,cAAc;IAI7B,YAAY,CAAC,CAAC,EAAE,eAAe;IAK/B,WAAW,CAAC,CAAC,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"libro-ai-msg-item-model.d.ts","sourceRoot":"","sources":["../src/libro-ai-msg-item-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAI9B,qBACa,2BAA2B;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;IAG3B,KAAK,EAAE,WAAW,CAAC;IAGnB,SAAS,CAAC,QAAQ,SAAM;IACxB,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,IAAI,OAAO,CAAC,CAAC,EAHE,MAGF,EAEZ;IAED,MAAM,EAAE,gBAAgB,CAAC;IAGzB,KAAK,CAAC,EAAE,YAAY,CAAC;gBAEkB,MAAM,EAAE,gBAAgB;IAQ/D,eAAe,CAAC,CAAC,EAAE,UAAU;IAY7B,WAAW,CAAC,CAAC,EAAE,cAAc;IAI7B,YAAY,CAAC,CAAC,EAAE,eAAe;IAK/B,WAAW,CAAC,CAAC,EAAE,cAAc;CAI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-ai-native-chat-service.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAGxE,qBACa,wBAAyB,SAAQ,gBAAgB;IACnD,IAAI,WACH,kCAAkC,KACzC,QAAQ,gBAAgB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"libro-ai-native-chat-service.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAGxE,qBACa,wBAAyB,SAAQ,gBAAgB;IACnD,IAAI,WACH,kCAAkC,KACzC,QAAQ,gBAAgB,EAAE,CAAC,CAkB5B;IACO,UAAU,WACT,kCAAkC,0BAClB,gBAAgB,KAAK,IAAI,yBAC1B,UAAU,KAAK,IAAI,mBA0D1C;CACH"}
|
|
@@ -32,14 +32,13 @@ export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PU
|
|
|
32
32
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
33
|
_this.chat = /*#__PURE__*/function () {
|
|
34
34
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(option) {
|
|
35
|
-
var
|
|
35
|
+
var content, system_prompt, res;
|
|
36
36
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
37
37
|
while (1) switch (_context.prev = _context.next) {
|
|
38
38
|
case 0:
|
|
39
|
-
|
|
39
|
+
content = option.content, system_prompt = option.system_prompt;
|
|
40
40
|
_context.next = 3;
|
|
41
41
|
return _this.fetcher.post("/libro/api/chat", {
|
|
42
|
-
chat_key: chat_key,
|
|
43
42
|
prompt: content,
|
|
44
43
|
system_prompt: system_prompt
|
|
45
44
|
});
|
|
@@ -56,7 +55,7 @@ export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PU
|
|
|
56
55
|
return _context.abrupt("return", [{
|
|
57
56
|
sender: {
|
|
58
57
|
type: 'AI',
|
|
59
|
-
id:
|
|
58
|
+
id: 'libro'
|
|
60
59
|
},
|
|
61
60
|
content: res.data.output
|
|
62
61
|
}]);
|
|
@@ -74,14 +73,13 @@ export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PU
|
|
|
74
73
|
}();
|
|
75
74
|
_this.chatStream = /*#__PURE__*/function () {
|
|
76
75
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(option, messgeCallback, eventCallback) {
|
|
77
|
-
var
|
|
76
|
+
var content, system_prompt, url, msg, res, reader, stream, alreayDone, _yield$reader$read, value, done, data, _event;
|
|
78
77
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
79
78
|
while (1) switch (_context2.prev = _context2.next) {
|
|
80
79
|
case 0:
|
|
81
|
-
|
|
80
|
+
content = option.content, system_prompt = option.system_prompt;
|
|
82
81
|
url = "/libro/api/chatstream";
|
|
83
82
|
msg = {
|
|
84
|
-
chat_key: chat_key,
|
|
85
83
|
prompt: content,
|
|
86
84
|
system_prompt: system_prompt
|
|
87
85
|
};
|
|
@@ -96,7 +94,7 @@ export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PU
|
|
|
96
94
|
case 5:
|
|
97
95
|
res = _context2.sent;
|
|
98
96
|
if (!(res.status === 200)) {
|
|
99
|
-
_context2.next =
|
|
97
|
+
_context2.next = 32;
|
|
100
98
|
break;
|
|
101
99
|
}
|
|
102
100
|
if (typeof res.data === 'string') {
|
|
@@ -108,44 +106,54 @@ export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PU
|
|
|
108
106
|
messgeCallback({
|
|
109
107
|
sender: {
|
|
110
108
|
type: 'AI',
|
|
111
|
-
id:
|
|
109
|
+
id: 'libro'
|
|
112
110
|
},
|
|
113
111
|
content: ''
|
|
114
112
|
});
|
|
115
113
|
alreayDone = false;
|
|
116
|
-
|
|
114
|
+
_context2.prev = 10;
|
|
115
|
+
case 11:
|
|
117
116
|
if (alreayDone) {
|
|
118
|
-
_context2.next =
|
|
117
|
+
_context2.next = 26;
|
|
119
118
|
break;
|
|
120
119
|
}
|
|
121
|
-
_context2.next =
|
|
120
|
+
_context2.next = 14;
|
|
122
121
|
return reader.read();
|
|
123
|
-
case
|
|
122
|
+
case 14:
|
|
124
123
|
_yield$reader$read = _context2.sent;
|
|
125
124
|
value = _yield$reader$read.value;
|
|
126
125
|
done = _yield$reader$read.done;
|
|
127
126
|
if (!done) {
|
|
128
|
-
_context2.next =
|
|
127
|
+
_context2.next = 21;
|
|
129
128
|
break;
|
|
130
129
|
}
|
|
131
130
|
alreayDone = true;
|
|
132
131
|
eventCallback({
|
|
133
132
|
type: 'done'
|
|
134
133
|
});
|
|
135
|
-
return _context2.abrupt("break",
|
|
136
|
-
case
|
|
134
|
+
return _context2.abrupt("break", 26);
|
|
135
|
+
case 21:
|
|
137
136
|
data = JSON.parse(value.data);
|
|
138
137
|
_event = ChatEvent.format(value.event || 'chunk', data);
|
|
139
138
|
eventCallback(_event);
|
|
140
|
-
_context2.next =
|
|
139
|
+
_context2.next = 11;
|
|
141
140
|
break;
|
|
142
|
-
case 25:
|
|
143
|
-
return _context2.abrupt("return");
|
|
144
141
|
case 26:
|
|
142
|
+
_context2.next = 31;
|
|
143
|
+
break;
|
|
144
|
+
case 28:
|
|
145
|
+
_context2.prev = 28;
|
|
146
|
+
_context2.t0 = _context2["catch"](10);
|
|
147
|
+
eventCallback({
|
|
148
|
+
type: 'error'
|
|
149
|
+
});
|
|
150
|
+
case 31:
|
|
151
|
+
return _context2.abrupt("return");
|
|
152
|
+
case 32:
|
|
145
153
|
case "end":
|
|
146
154
|
return _context2.stop();
|
|
147
155
|
}
|
|
148
|
-
}, _callee2);
|
|
156
|
+
}, _callee2, null, [[10, 28]]);
|
|
149
157
|
}));
|
|
150
158
|
return function (_x2, _x3, _x4) {
|
|
151
159
|
return _ref2.apply(this, arguments);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type { LibroView } from '@difizen/libro-jupyter';
|
|
1
|
+
import type { CellView, LibroView } from '@difizen/libro-jupyter';
|
|
2
2
|
import { ChatView } from '@difizen/magent-chat';
|
|
3
3
|
import breaks from 'remark-breaks';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
5
5
|
import './index.less';
|
|
6
|
+
import type { AiNativeChatViewOption } from './protocol.js';
|
|
6
7
|
import { ImageModal } from './utils.js';
|
|
7
8
|
export declare class LibroAiNativeChatView extends ChatView {
|
|
8
9
|
isCellChat: boolean;
|
|
9
10
|
libro?: LibroView;
|
|
11
|
+
cell?: CellView;
|
|
12
|
+
constructor(option: AiNativeChatViewOption);
|
|
10
13
|
getMarkdownProps(): {
|
|
11
14
|
components: {
|
|
12
15
|
code: (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-ai-native-chat-view.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"libro-ai-native-chat-view.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,qBAEa,qBAAsB,SAAQ,QAAQ;IAEjD,UAAU,UAAS;IAEnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,IAAI,CAAC,EAAE,QAAQ,CAAC;gBAEgB,MAAM,EAAE,sBAAsB;IAMrD,gBAAgB;;;;;;;cAON,eAAe,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAiBtD"}
|
|
@@ -19,28 +19,26 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
19
19
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
20
20
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
21
21
|
import { ChatView } from '@difizen/magent-chat';
|
|
22
|
-
import { prop, transient, view } from '@difizen/mana-app';
|
|
22
|
+
import { inject, prop, transient, view, ViewOption } from '@difizen/mana-app';
|
|
23
23
|
import breaks from 'remark-breaks';
|
|
24
24
|
import remarkGfm from 'remark-gfm';
|
|
25
25
|
import { CodeBlockInChat } from "./ai-native-code-block.js";
|
|
26
26
|
import "./index.less";
|
|
27
27
|
import { ImageModal } from "./utils.js";
|
|
28
|
-
// import { ImageModal } from './utils.js';
|
|
29
|
-
|
|
30
28
|
var viewId = 'magent-chat';
|
|
31
29
|
export var LibroAiNativeChatView = (_dec = transient(), _dec2 = view(viewId), _dec3 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_ChatView) {
|
|
32
30
|
_inherits(LibroAiNativeChatView, _ChatView);
|
|
33
31
|
var _super = _createSuper(LibroAiNativeChatView);
|
|
34
|
-
function LibroAiNativeChatView() {
|
|
32
|
+
function LibroAiNativeChatView(option) {
|
|
35
33
|
var _this;
|
|
36
34
|
_classCallCheck(this, LibroAiNativeChatView);
|
|
37
|
-
|
|
38
|
-
args[_key] = arguments[_key];
|
|
39
|
-
}
|
|
40
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
35
|
+
_this = _super.call(this, option);
|
|
41
36
|
_initializerDefineProperty(_this, "isCellChat", _descriptor, _assertThisInitialized(_this));
|
|
37
|
+
_this.option = option;
|
|
38
|
+
_this.isCellChat = option.isCellChat;
|
|
42
39
|
return _this;
|
|
43
40
|
}
|
|
41
|
+
LibroAiNativeChatView = inject(ViewOption)(LibroAiNativeChatView, undefined, 0) || LibroAiNativeChatView;
|
|
44
42
|
_createClass(LibroAiNativeChatView, [{
|
|
45
43
|
key: "getMarkdownProps",
|
|
46
44
|
value: function getMarkdownProps() {
|
|
@@ -56,7 +54,7 @@ export var LibroAiNativeChatView = (_dec = transient(), _dec2 = view(viewId), _d
|
|
|
56
54
|
key: "toMessageOption",
|
|
57
55
|
value: function toMessageOption(msgContent) {
|
|
58
56
|
if (this.isCellChat) {
|
|
59
|
-
var _this$
|
|
57
|
+
var _this$cell;
|
|
60
58
|
return _objectSpread(_objectSpread({
|
|
61
59
|
stream: true
|
|
62
60
|
}, this.option), {}, {
|
|
@@ -64,7 +62,7 @@ export var LibroAiNativeChatView = (_dec = transient(), _dec2 = view(viewId), _d
|
|
|
64
62
|
type: 'HUMAN'
|
|
65
63
|
},
|
|
66
64
|
input: msgContent,
|
|
67
|
-
system_prompt: "\u6709\u5982\u4E0B\u7684\u4EE3\u7801\u4F5C\u4E3A\u5BF9\u8BDD\u7684\u4E0A\u4E0B\u6587\uFF1A".concat((_this$
|
|
65
|
+
system_prompt: "\u6709\u5982\u4E0B\u7684\u4EE3\u7801\u4F5C\u4E3A\u5BF9\u8BDD\u7684\u4E0A\u4E0B\u6587\uFF1A".concat((_this$cell = this.cell) === null || _this$cell === void 0 ? void 0 : _this$cell.model.value)
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
return _objectSpread(_objectSpread({
|
package/es/protocol.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { CellView } from '@difizen/libro-jupyter';
|
|
2
|
-
import type { IChatMessageItem } from '@difizen/magent-chat';
|
|
2
|
+
import type { ChatViewOption, IChatMessageItem } from '@difizen/magent-chat';
|
|
3
3
|
export interface IAINativeForCellViewOption {
|
|
4
4
|
cell: CellView;
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
7
7
|
export interface LibroAINativeChatMessageItemOption extends IChatMessageItem {
|
|
8
|
-
chat_key
|
|
8
|
+
chat_key?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AiNativeChatViewOption extends ChatViewOption {
|
|
11
|
+
id: string;
|
|
12
|
+
chat_key?: string;
|
|
13
|
+
isCellChat: boolean;
|
|
14
|
+
cell?: CellView;
|
|
9
15
|
}
|
|
10
16
|
//# sourceMappingURL=protocol.d.ts.map
|