@difizen/libro-prompt-cell 0.0.0-snapshot-20241017072317
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/LICENSE +21 -0
- package/README.md +8 -0
- package/es/index.d.ts +8 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +7 -0
- package/es/index.less +72 -0
- package/es/input-handler/chat-record-input.d.ts +12 -0
- package/es/input-handler/chat-record-input.d.ts.map +1 -0
- package/es/input-handler/chat-record-input.js +105 -0
- package/es/input-handler/index.d.ts +3 -0
- package/es/input-handler/index.d.ts.map +1 -0
- package/es/input-handler/index.js +2 -0
- package/es/input-handler/index.less +91 -0
- package/es/input-handler/variable-name-input.d.ts +18 -0
- package/es/input-handler/variable-name-input.d.ts.map +1 -0
- package/es/input-handler/variable-name-input.js +120 -0
- package/es/libro-formatter-prompt-magic-contribution.d.ts +35 -0
- package/es/libro-formatter-prompt-magic-contribution.d.ts.map +1 -0
- package/es/libro-formatter-prompt-magic-contribution.js +68 -0
- package/es/libro-llm-render.d.ts +10 -0
- package/es/libro-llm-render.d.ts.map +1 -0
- package/es/libro-llm-render.js +75 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +25 -0
- package/es/prompt-cell-command-contribution.d.ts +18 -0
- package/es/prompt-cell-command-contribution.d.ts.map +1 -0
- package/es/prompt-cell-command-contribution.js +62 -0
- package/es/prompt-cell-contribution.d.ts +16 -0
- package/es/prompt-cell-contribution.d.ts.map +1 -0
- package/es/prompt-cell-contribution.js +75 -0
- package/es/prompt-cell-model.d.ts +49 -0
- package/es/prompt-cell-model.d.ts.map +1 -0
- package/es/prompt-cell-model.js +189 -0
- package/es/prompt-cell-protocol.d.ts +5 -0
- package/es/prompt-cell-protocol.d.ts.map +1 -0
- package/es/prompt-cell-protocol.js +1 -0
- package/es/prompt-cell-script.d.ts +5 -0
- package/es/prompt-cell-script.d.ts.map +1 -0
- package/es/prompt-cell-script.js +13 -0
- package/es/prompt-cell-utils.d.ts +2 -0
- package/es/prompt-cell-utils.d.ts.map +1 -0
- package/es/prompt-cell-utils.js +7 -0
- package/es/prompt-cell-view.d.ts +63 -0
- package/es/prompt-cell-view.d.ts.map +1 -0
- package/es/prompt-cell-view.js +616 -0
- package/es/prompt-output-render.d.ts +6 -0
- package/es/prompt-output-render.d.ts.map +1 -0
- package/es/prompt-output-render.js +193 -0
- package/es/prompt-output-rendermime-contribution.d.ts +13 -0
- package/es/prompt-output-rendermime-contribution.d.ts.map +1 -0
- package/es/prompt-output-rendermime-contribution.js +22 -0
- package/package.json +75 -0
- package/src/index.less +72 -0
- package/src/index.spec.ts +9 -0
- package/src/index.ts +7 -0
- package/src/input-handler/chat-record-input.tsx +106 -0
- package/src/input-handler/index.less +91 -0
- package/src/input-handler/index.ts +2 -0
- package/src/input-handler/variable-name-input.tsx +121 -0
- package/src/libro-formatter-prompt-magic-contribution.ts +80 -0
- package/src/libro-llm-render.tsx +64 -0
- package/src/module.ts +38 -0
- package/src/prompt-cell-command-contribution.ts +61 -0
- package/src/prompt-cell-contribution.ts +47 -0
- package/src/prompt-cell-model.ts +128 -0
- package/src/prompt-cell-protocol.ts +8 -0
- package/src/prompt-cell-script.ts +9 -0
- package/src/prompt-cell-utils.ts +6 -0
- package/src/prompt-cell-view.tsx +554 -0
- package/src/prompt-output-render.tsx +124 -0
- package/src/prompt-output-rendermime-contribution.ts +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Difizen Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './prompt-cell-contribution.js';
|
|
2
|
+
export * from './prompt-cell-model.js';
|
|
3
|
+
export * from './prompt-cell-protocol.js';
|
|
4
|
+
export * from './prompt-cell-view.js';
|
|
5
|
+
export * from './prompt-cell-script.js';
|
|
6
|
+
export * from './input-handler/index.js';
|
|
7
|
+
export * from './module.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./prompt-cell-contribution.js";
|
|
2
|
+
export * from "./prompt-cell-model.js";
|
|
3
|
+
export * from "./prompt-cell-protocol.js";
|
|
4
|
+
export * from "./prompt-cell-view.js";
|
|
5
|
+
export * from "./prompt-cell-script.js";
|
|
6
|
+
export * from "./input-handler/index.js";
|
|
7
|
+
export * from "./module.js";
|
package/es/index.less
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.libro-prompt-cell-header {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.libro-llm-hljs {
|
|
8
|
+
overflow-x: auto;
|
|
9
|
+
white-space: pre-wrap !important;
|
|
10
|
+
word-wrap: break-word !important;
|
|
11
|
+
text-shadow: unset !important;
|
|
12
|
+
color: var(--mana-libro-editor-variable-color) !important;
|
|
13
|
+
|
|
14
|
+
.hljs-title.function_ {
|
|
15
|
+
color: var(--mana-libro-editor-def-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hljs-keyword {
|
|
19
|
+
color: var(--mana-libro-editor-keyword-color);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.hljs-number {
|
|
23
|
+
color: var(--mana-libro-editor-number-color);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.hljs-comment {
|
|
27
|
+
color: var(--mana-libro-editor-comment-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hljs-string {
|
|
31
|
+
color: var(--mana-libro-editor-string-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hljs-built_in {
|
|
35
|
+
color: var(--mana-libro-editor-builtin-color);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.libro-llm-output-render {
|
|
40
|
+
p {
|
|
41
|
+
color: var(--mana-libro-llm-response-output-text-color);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.libro-prompt-output-render-container {
|
|
46
|
+
padding: 10px 24px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.libro-prompt-output-llm-render {
|
|
50
|
+
.libro-llm-output-render pre {
|
|
51
|
+
background: #f4f6fb;
|
|
52
|
+
padding: 16px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.libro-prompt-output-btn {
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
color: #1677ff;
|
|
59
|
+
margin-right: 16px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.libro-prompt-cell-selection {
|
|
63
|
+
&-disabled {
|
|
64
|
+
.libro-prompt-cell-selection-tag {
|
|
65
|
+
color: var(--mana-text-quaternary);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.libro-prompt-cell-selection-name {
|
|
69
|
+
color: var(--mana-text-quaternary);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface ChatRecordInputProps {
|
|
4
|
+
value: string | undefined;
|
|
5
|
+
handleChange: (value: string | undefined) => void;
|
|
6
|
+
onFocus?: () => void;
|
|
7
|
+
classname?: string;
|
|
8
|
+
records: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare const ChatRecordInput: FC<ChatRecordInputProps>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=chat-record-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-record-input.d.ts","sourceRoot":"","sources":["../../src/input-handler/chat-record-input.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,cAAc,CAAC;AAEtB,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoFpD,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { EditFilled } from '@ant-design/icons';
|
|
8
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
9
|
+
import { useInject } from '@difizen/mana-app';
|
|
10
|
+
import { Select, Tag } from 'antd';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import { useEffect } from 'react';
|
|
13
|
+
import { useRef } from 'react';
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import "./index.less";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
var ChatRecordInputCls = 'libro-chat-record-input';
|
|
20
|
+
export var ChatRecordInput = function ChatRecordInput(props) {
|
|
21
|
+
var value = props.value,
|
|
22
|
+
records = props.records,
|
|
23
|
+
handleChange = props.handleChange,
|
|
24
|
+
_onFocus = props.onFocus;
|
|
25
|
+
var selectRef = useRef(null);
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
selecting = _useState2[0],
|
|
29
|
+
setSelecting = _useState2[1];
|
|
30
|
+
var ref = useRef(null);
|
|
31
|
+
var contextKey = useInject(LibroContextKey);
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (selecting) {
|
|
34
|
+
var _selectRef$current;
|
|
35
|
+
(_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 || _selectRef$current.focus();
|
|
36
|
+
}
|
|
37
|
+
}, [selecting]);
|
|
38
|
+
var handleSelecting = function handleSelecting(v) {
|
|
39
|
+
if (v) {
|
|
40
|
+
contextKey.disableCommandMode();
|
|
41
|
+
} else {
|
|
42
|
+
contextKey.enableCommandMode();
|
|
43
|
+
}
|
|
44
|
+
setSelecting(v);
|
|
45
|
+
};
|
|
46
|
+
var handleSelectChange = function handleSelectChange(arr) {
|
|
47
|
+
if (arr instanceof Array) {
|
|
48
|
+
handleChange(arr[0]);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
52
|
+
className: classNames(ChatRecordInputCls, props.classname),
|
|
53
|
+
ref: ref,
|
|
54
|
+
tabIndex: 0,
|
|
55
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
56
|
+
className: "libro-chat-record-input-label",
|
|
57
|
+
children: "Chat: "
|
|
58
|
+
}), selecting ? /*#__PURE__*/_jsx(Select, {
|
|
59
|
+
ref: selectRef,
|
|
60
|
+
className: "libro-chat-record-input-select",
|
|
61
|
+
size: "small",
|
|
62
|
+
mode: "tags",
|
|
63
|
+
style: {
|
|
64
|
+
width: '100%'
|
|
65
|
+
},
|
|
66
|
+
placeholder: "\u9009\u62E9\u6216\u8F93\u5165\u804A\u5929\u6807\u8BC6",
|
|
67
|
+
onSelect: handleSelectChange,
|
|
68
|
+
onChange: handleSelectChange,
|
|
69
|
+
showSearch: false,
|
|
70
|
+
allowClear: true,
|
|
71
|
+
value: value,
|
|
72
|
+
onClear: function onClear() {
|
|
73
|
+
handleChange(undefined);
|
|
74
|
+
},
|
|
75
|
+
onBlur: function onBlur() {
|
|
76
|
+
handleSelecting(false);
|
|
77
|
+
},
|
|
78
|
+
onFocus: function onFocus() {
|
|
79
|
+
if (_onFocus) {
|
|
80
|
+
_onFocus();
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
options: records.map(function (record) {
|
|
84
|
+
return {
|
|
85
|
+
label: record,
|
|
86
|
+
value: record
|
|
87
|
+
};
|
|
88
|
+
}) || []
|
|
89
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
90
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
91
|
+
className: "libro-chat-record-input-value",
|
|
92
|
+
children: value ? /*#__PURE__*/_jsx(Tag, {
|
|
93
|
+
children: value
|
|
94
|
+
}) : '...'
|
|
95
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
96
|
+
onClick: function onClick() {
|
|
97
|
+
handleSelecting(true);
|
|
98
|
+
},
|
|
99
|
+
children: /*#__PURE__*/_jsx(EditFilled, {
|
|
100
|
+
className: "libro-chat-record-input-editor-icon"
|
|
101
|
+
})
|
|
102
|
+
})]
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input-handler/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
.libro-chat-record-input {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: 0 8px;
|
|
5
|
+
|
|
6
|
+
&-select {
|
|
7
|
+
min-width: 180px;
|
|
8
|
+
padding: 0 8px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-value {
|
|
12
|
+
padding-left: 2px;
|
|
13
|
+
|
|
14
|
+
span {
|
|
15
|
+
margin-inline-end: 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-label {
|
|
20
|
+
padding-left: 16px;
|
|
21
|
+
color: var(--mana-libro-cell-header-title);
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
letter-spacing: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-editor-icon {
|
|
27
|
+
margin-left: 4px;
|
|
28
|
+
color: #bdc0c4 !important;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
color: #1590ff !important;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.libro-variable-name-input {
|
|
38
|
+
border-left: 1px solid var(--mana-color-border);
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
|
|
42
|
+
svg {
|
|
43
|
+
margin-left: 4px;
|
|
44
|
+
color: #bdc0c4 !important;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
color: #1590ff !important;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-value {
|
|
53
|
+
padding-left: 2px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&-label {
|
|
57
|
+
padding-left: 16px;
|
|
58
|
+
color: var(--mana-libro-cell-header-title);
|
|
59
|
+
font-size: 14px;
|
|
60
|
+
letter-spacing: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-input {
|
|
64
|
+
width: 120px;
|
|
65
|
+
height: 32px;
|
|
66
|
+
border: 1px solid #d6d8da;
|
|
67
|
+
border-radius: 6px;
|
|
68
|
+
box-shadow: unset;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&-popover {
|
|
72
|
+
vertical-align: middle;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&-warning-text {
|
|
76
|
+
margin-top: 4px;
|
|
77
|
+
color: #faad14;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&-actions {
|
|
81
|
+
padding: 2px 0;
|
|
82
|
+
|
|
83
|
+
span + span {
|
|
84
|
+
margin-left: 8px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
span {
|
|
88
|
+
color: #1890ff;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface VariableNameInputPopoverContentProps {
|
|
4
|
+
value: string;
|
|
5
|
+
handleVariableNameChange: (variableName: string) => void;
|
|
6
|
+
checkVariableNameAvailable: (variableName: string) => boolean;
|
|
7
|
+
cancel: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const VariableNameInputPopoverContent: FC<VariableNameInputPopoverContentProps>;
|
|
10
|
+
interface VariableNameInputProps {
|
|
11
|
+
value: string;
|
|
12
|
+
handleVariableNameChange: (variableName: string) => void;
|
|
13
|
+
checkVariableNameAvailable: (variableName: string) => boolean;
|
|
14
|
+
classname?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const VariableNameInput: FC<VariableNameInputProps>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=variable-name-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-name-input.d.ts","sourceRoot":"","sources":["../../src/input-handler/variable-name-input.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,cAAc,CAAC;AAEtB,UAAU,oCAAoC;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,0BAA0B,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9D,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,+BAA+B,EAAE,EAAE,CAC9C,oCAAoC,CAgDrC,CAAC;AAEF,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,0BAA0B,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA2CxD,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { EditFilled } from '@ant-design/icons';
|
|
14
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
15
|
+
import { useInject } from '@difizen/mana-app';
|
|
16
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
17
|
+
import { Input, Popover } from 'antd';
|
|
18
|
+
import classNames from 'classnames';
|
|
19
|
+
import { useEffect } from 'react';
|
|
20
|
+
import { useRef } from 'react';
|
|
21
|
+
import { useCallback, useState } from 'react';
|
|
22
|
+
import "./index.less";
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
+
export var VariableNameInputPopoverContent = function VariableNameInputPopoverContent(props) {
|
|
27
|
+
var value = props.value,
|
|
28
|
+
handleVariableNameChange = props.handleVariableNameChange,
|
|
29
|
+
checkVariableNameAvailable = props.checkVariableNameAvailable,
|
|
30
|
+
cancel = props.cancel;
|
|
31
|
+
var _useState = useState(true),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
variableNameAvailable = _useState2[0],
|
|
34
|
+
setVariableNameAvailable = _useState2[1];
|
|
35
|
+
var _useState3 = useState(value),
|
|
36
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
+
variableName = _useState4[0],
|
|
38
|
+
setVariableName = _useState4[1];
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
setVariableName(value);
|
|
41
|
+
}, [value]);
|
|
42
|
+
var handleValueChange = useCallback(function (e) {
|
|
43
|
+
if (checkVariableNameAvailable(e.target.value)) {
|
|
44
|
+
setVariableNameAvailable(false);
|
|
45
|
+
} else {
|
|
46
|
+
setVariableNameAvailable(true);
|
|
47
|
+
}
|
|
48
|
+
setVariableName(e.target.value);
|
|
49
|
+
}, [checkVariableNameAvailable]);
|
|
50
|
+
var handValueSave = useCallback(function () {
|
|
51
|
+
handleVariableNameChange(variableName);
|
|
52
|
+
cancel();
|
|
53
|
+
}, [variableName, handleVariableNameChange, cancel]);
|
|
54
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
55
|
+
children: [/*#__PURE__*/_jsx(Input, {
|
|
56
|
+
status: "".concat(variableNameAvailable ? '' : 'warning'),
|
|
57
|
+
className: "libro-variable-name-input-component",
|
|
58
|
+
onChange: handleValueChange,
|
|
59
|
+
value: variableName
|
|
60
|
+
}), !variableNameAvailable && /*#__PURE__*/_jsx("span", {
|
|
61
|
+
className: "libro-variable-name-input-warning-text",
|
|
62
|
+
children: l10n.t('当前变量名已存在')
|
|
63
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
64
|
+
className: "libro-variable-name-input-actions",
|
|
65
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
66
|
+
onClick: cancel,
|
|
67
|
+
children: l10n.t('取消')
|
|
68
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
69
|
+
onClick: handValueSave,
|
|
70
|
+
children: l10n.t('保存')
|
|
71
|
+
})]
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
var variableNameInputCls = 'libro-variable-name-input';
|
|
76
|
+
export var VariableNameInput = function VariableNameInput(props) {
|
|
77
|
+
var value = props.value;
|
|
78
|
+
var _useState5 = useState(false),
|
|
79
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
+
popoverVisible = _useState6[0],
|
|
81
|
+
setPopoverVisible = _useState6[1];
|
|
82
|
+
var contextKey = useInject(LibroContextKey);
|
|
83
|
+
var ref = useRef(null);
|
|
84
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
85
|
+
className: classNames(variableNameInputCls, props.classname),
|
|
86
|
+
ref: ref,
|
|
87
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
88
|
+
className: "libro-variable-name-input-label",
|
|
89
|
+
children: "Save: "
|
|
90
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
91
|
+
className: "libro-variable-name-input-value",
|
|
92
|
+
children: value || '...'
|
|
93
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
94
|
+
className: "libro-variable-name-input-popover",
|
|
95
|
+
children: /*#__PURE__*/_jsx(Popover, {
|
|
96
|
+
content: /*#__PURE__*/_jsx(VariableNameInputPopoverContent, _objectSpread(_objectSpread({}, props), {}, {
|
|
97
|
+
cancel: function cancel() {
|
|
98
|
+
setPopoverVisible(false);
|
|
99
|
+
}
|
|
100
|
+
})),
|
|
101
|
+
placement: "bottomLeft",
|
|
102
|
+
open: popoverVisible,
|
|
103
|
+
onOpenChange: function onOpenChange(visible) {
|
|
104
|
+
if (visible) {
|
|
105
|
+
contextKey.disableCommandMode();
|
|
106
|
+
} else {
|
|
107
|
+
contextKey.enableCommandMode();
|
|
108
|
+
}
|
|
109
|
+
setPopoverVisible(visible);
|
|
110
|
+
},
|
|
111
|
+
getPopupContainer: function getPopupContainer() {
|
|
112
|
+
var _ref$current;
|
|
113
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getElementsByClassName(variableNameInputCls)[0];
|
|
114
|
+
},
|
|
115
|
+
trigger: "click",
|
|
116
|
+
children: /*#__PURE__*/_jsx(EditFilled, {})
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
120
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DefaultEncodedFormatter } from '@difizen/libro-jupyter';
|
|
2
|
+
import { DefaultDecodedFormatter, FormatterContribution } from '@difizen/libro-jupyter';
|
|
3
|
+
export interface PromptDecodedFormatter extends DefaultDecodedFormatter {
|
|
4
|
+
modelType?: string;
|
|
5
|
+
chatKey?: string;
|
|
6
|
+
variableName?: string;
|
|
7
|
+
cellId?: string;
|
|
8
|
+
record?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class FormatterPromptMagicContribution implements FormatterContribution<PromptDecodedFormatter> {
|
|
11
|
+
formatter: string;
|
|
12
|
+
formatterOptions?: object;
|
|
13
|
+
canHandle: (libroFormatter: string) => 1 | 100;
|
|
14
|
+
encode: (source: PromptDecodedFormatter) => {
|
|
15
|
+
source: string;
|
|
16
|
+
metadata: {
|
|
17
|
+
libroFormatter: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
decode: (formatterValue: DefaultEncodedFormatter) => {
|
|
21
|
+
value: any;
|
|
22
|
+
variableName: any;
|
|
23
|
+
chatKey: any;
|
|
24
|
+
cellId: any;
|
|
25
|
+
record: any;
|
|
26
|
+
} | {
|
|
27
|
+
value: string;
|
|
28
|
+
variableName?: undefined;
|
|
29
|
+
chatKey?: undefined;
|
|
30
|
+
cellId?: undefined;
|
|
31
|
+
record?: undefined;
|
|
32
|
+
};
|
|
33
|
+
validate: (source: PromptDecodedFormatter) => source is PromptDecodedFormatter;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=libro-formatter-prompt-magic-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-formatter-prompt-magic-contribution.d.ts","sourceRoot":"","sources":["../src/libro-formatter-prompt-magic-contribution.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBACa,gCACX,YAAW,qBAAqB,CAAC,sBAAsB,CAAC;IAExD,SAAS,SAA4B;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,mBAAoB,MAAM,aAKjC;IAEF,MAAM,WAAY,sBAAsB;;;;;MAiBtC;IAEF,MAAM,mBAAoB,uBAAuB;;;;;;;;;;;;MAqB/C;IAEF,QAAQ,WAAY,sBAAsB,sCAKxC;CACH"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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, _class;
|
|
3
|
+
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); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
9
|
+
|
|
10
|
+
import { concatMultilineString, DefaultDecodedFormatter, FormatterContribution } from '@difizen/libro-jupyter';
|
|
11
|
+
import { singleton } from '@difizen/mana-app';
|
|
12
|
+
export var FormatterPromptMagicContribution = (_dec = singleton({
|
|
13
|
+
contrib: FormatterContribution
|
|
14
|
+
}), _dec(_class = /*#__PURE__*/_createClass(function FormatterPromptMagicContribution() {
|
|
15
|
+
var _this = this;
|
|
16
|
+
_classCallCheck(this, FormatterPromptMagicContribution);
|
|
17
|
+
this.formatter = 'formatter-prompt-magic';
|
|
18
|
+
this.formatterOptions = void 0;
|
|
19
|
+
this.canHandle = function (libroFormatter) {
|
|
20
|
+
if (libroFormatter === _this.formatter) {
|
|
21
|
+
return 100;
|
|
22
|
+
}
|
|
23
|
+
return 1;
|
|
24
|
+
};
|
|
25
|
+
this.encode = function (source) {
|
|
26
|
+
var chat_key = source.chatKey || source.modelType || 'LLM:chatgpt';
|
|
27
|
+
var promptObj = {
|
|
28
|
+
model_name: chat_key,
|
|
29
|
+
chat_key: chat_key,
|
|
30
|
+
prompt: source.value,
|
|
31
|
+
variable_name: source.variableName,
|
|
32
|
+
cell_id: source.cellId,
|
|
33
|
+
record: source.record
|
|
34
|
+
};
|
|
35
|
+
var encodeValue = "%%prompt \n".concat(JSON.stringify(promptObj));
|
|
36
|
+
return {
|
|
37
|
+
source: encodeValue,
|
|
38
|
+
metadata: {
|
|
39
|
+
libroFormatter: _this.formatter
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
this.decode = function (formatterValue) {
|
|
44
|
+
var value = concatMultilineString(formatterValue.source);
|
|
45
|
+
if (value.startsWith('%%prompt \n')) {
|
|
46
|
+
var run = value.split('%%prompt \n')[1];
|
|
47
|
+
var runValue = JSON.parse(run);
|
|
48
|
+
var codeValue = runValue.prompt;
|
|
49
|
+
var chatKey = runValue.chat_key || runValue.model_name;
|
|
50
|
+
var variableName = runValue.variable_name;
|
|
51
|
+
var cellId = runValue.cell_id;
|
|
52
|
+
var record = runValue.record;
|
|
53
|
+
return {
|
|
54
|
+
value: codeValue,
|
|
55
|
+
variableName: variableName,
|
|
56
|
+
chatKey: chatKey,
|
|
57
|
+
cellId: cellId,
|
|
58
|
+
record: record
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
value: ''
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
this.validate = function (source) {
|
|
66
|
+
return DefaultDecodedFormatter.is(source) && ('chatKey' in source || 'modelType ' in source);
|
|
67
|
+
};
|
|
68
|
+
})) || _class);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'highlight.js/styles/default.css';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export declare const LibroLLMRender: React.FC<{
|
|
5
|
+
data: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const LibroLLMRenderMemo: React.NamedExoticComponent<{
|
|
8
|
+
data: string;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=libro-llm-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-llm-render.d.ts","sourceRoot":"","sources":["../src/libro-llm-render.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,iCAAiC,CAAC;AAEzC,OAAO,cAAc,CAAC;AAiBtB,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAqCrD,CAAC;AACF,eAAO,MAAM,kBAAkB;UAtCe,MAAM;EAsCE,CAAC"}
|