@lobehub/ui 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Chat/const.d.ts +1 -0
- package/es/Chat/const.js +1 -0
- package/es/Chat/index.d.ts +2 -0
- package/es/Chat/index.js +2 -0
- package/es/Chat/store/index.d.ts +20 -0
- package/es/Chat/store/index.js +16 -0
- package/es/Chat/store/initialState.d.ts +28 -0
- package/es/Chat/store/initialState.js +9 -0
- package/es/Chat/store/messageReducer.d.ts +37 -0
- package/es/Chat/store/messageReducer.js +67 -0
- package/es/Chat/store/selectors.d.ts +9 -0
- package/es/Chat/store/selectors.js +44 -0
- package/es/Chat/store/store.d.ts +34 -0
- package/es/Chat/store/store.js +240 -0
- package/es/Chat/types.d.ts +77 -0
- package/es/Chat/types.js +1 -0
- package/es/Chat/utils/fetch.d.ts +11 -0
- package/es/Chat/utils/fetch.js +100 -0
- package/es/Conversation/App.d.ts +13 -0
- package/es/Conversation/App.js +43 -0
- package/es/Conversation/ChatList/MessageItem/Content.d.ts +8 -0
- package/es/Conversation/ChatList/MessageItem/Content.js +103 -0
- package/es/Conversation/ChatList/MessageItem/Toolbar.d.ts +10 -0
- package/es/Conversation/ChatList/MessageItem/Toolbar.js +94 -0
- package/es/Conversation/ChatList/MessageItem/index.d.ts +9 -0
- package/es/Conversation/ChatList/MessageItem/index.js +126 -0
- package/es/Conversation/ChatList/index.d.ts +14 -0
- package/es/Conversation/ChatList/index.js +62 -0
- package/es/Conversation/InputArea/ActionBar.d.ts +4 -0
- package/es/Conversation/InputArea/ActionBar.js +71 -0
- package/es/Conversation/InputArea/index.d.ts +4 -0
- package/es/Conversation/InputArea/index.js +101 -0
- package/es/Conversation/StoreUpdater.d.ts +7 -0
- package/es/Conversation/StoreUpdater.js +27 -0
- package/es/Conversation/index.d.ts +8 -0
- package/es/Conversation/index.js +28 -0
- package/es/EditableMessageList/index.d.ts +9 -0
- package/es/EditableMessageList/index.js +101 -0
- package/es/EditableText/index.d.ts +1 -1
- package/es/EditableText/index.js +1 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +2 -0
- package/lib/Chat/const.d.ts +1 -0
- package/lib/Chat/const.js +29 -0
- package/lib/Chat/index.d.ts +2 -0
- package/lib/Chat/index.js +31 -0
- package/lib/Chat/store/index.d.ts +20 -0
- package/lib/Chat/store/index.js +44 -0
- package/lib/Chat/store/initialState.d.ts +28 -0
- package/lib/Chat/store/initialState.js +37 -0
- package/lib/Chat/store/messageReducer.d.ts +37 -0
- package/lib/Chat/store/messageReducer.js +82 -0
- package/lib/Chat/store/selectors.d.ts +9 -0
- package/lib/Chat/store/selectors.js +53 -0
- package/lib/Chat/store/store.d.ts +34 -0
- package/lib/Chat/store/store.js +119 -0
- package/lib/Chat/types.d.ts +77 -0
- package/lib/Chat/types.js +17 -0
- package/lib/Chat/utils/fetch.d.ts +11 -0
- package/lib/Chat/utils/fetch.js +72 -0
- package/lib/Conversation/App.d.ts +13 -0
- package/lib/Conversation/App.js +53 -0
- package/lib/Conversation/ChatList/MessageItem/Content.d.ts +8 -0
- package/lib/Conversation/ChatList/MessageItem/Content.js +104 -0
- package/lib/Conversation/ChatList/MessageItem/Toolbar.d.ts +10 -0
- package/lib/Conversation/ChatList/MessageItem/Toolbar.js +110 -0
- package/lib/Conversation/ChatList/MessageItem/index.d.ts +9 -0
- package/lib/Conversation/ChatList/MessageItem/index.js +164 -0
- package/lib/Conversation/ChatList/index.d.ts +14 -0
- package/lib/Conversation/ChatList/index.js +61 -0
- package/lib/Conversation/InputArea/ActionBar.d.ts +4 -0
- package/lib/Conversation/InputArea/ActionBar.js +97 -0
- package/lib/Conversation/InputArea/index.d.ts +4 -0
- package/lib/Conversation/InputArea/index.js +149 -0
- package/lib/Conversation/StoreUpdater.d.ts +7 -0
- package/lib/Conversation/StoreUpdater.js +54 -0
- package/lib/Conversation/index.d.ts +8 -0
- package/lib/Conversation/index.js +45 -0
- package/lib/EditableMessageList/index.d.ts +9 -0
- package/lib/EditableMessageList/index.js +124 -0
- package/lib/EditableText/index.d.ts +1 -1
- package/lib/EditableText/index.js +1 -1
- package/lib/{EditableText → components}/ControlInput.js +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/package.json +7 -2
- /package/es/{EditableText → components}/ControlInput.d.ts +0 -0
- /package/es/{EditableText → components}/ControlInput.js +0 -0
- /package/lib/{EditableText → components}/ControlInput.d.ts +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Conversation/InputArea/ActionBar.tsx
|
|
30
|
+
var ActionBar_exports = {};
|
|
31
|
+
__export(ActionBar_exports, {
|
|
32
|
+
ActionBar: () => ActionBar,
|
|
33
|
+
default: () => ActionBar_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(ActionBar_exports);
|
|
36
|
+
var import_antd_style = require("antd-style");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_react_layout_kit = require("react-layout-kit");
|
|
39
|
+
var import_shallow = require("zustand/shallow");
|
|
40
|
+
var import_ActionIcon = __toESM(require("../../ActionIcon"));
|
|
41
|
+
var import_antd = require("antd");
|
|
42
|
+
var import_lucide_react = require("lucide-react");
|
|
43
|
+
var import_store = require("../../Chat/store");
|
|
44
|
+
var useStyles = (0, import_antd_style.createStyles)(({ css, token }) => ({
|
|
45
|
+
extra: css`
|
|
46
|
+
color: ${token.colorTextTertiary};
|
|
47
|
+
`
|
|
48
|
+
}));
|
|
49
|
+
var ActionBar = () => {
|
|
50
|
+
const [totalToken, agentToken, messagesToken, dispatchMessage] = (0, import_store.useStore)(
|
|
51
|
+
(s) => [
|
|
52
|
+
import_store.chatSelectors.totalTokenCount(s),
|
|
53
|
+
import_store.chatSelectors.agentTokenCount(s),
|
|
54
|
+
import_store.chatSelectors.messagesTokenCount(s),
|
|
55
|
+
s.dispatchMessage
|
|
56
|
+
],
|
|
57
|
+
import_shallow.shallow
|
|
58
|
+
);
|
|
59
|
+
const { styles, theme } = useStyles();
|
|
60
|
+
return totalToken > 0 ? /* @__PURE__ */ React.createElement(import_antd.ConfigProvider, { theme: { token: { colorText: theme.colorTextSecondary } } }, /* @__PURE__ */ React.createElement(
|
|
61
|
+
import_react_layout_kit.Flexbox,
|
|
62
|
+
{
|
|
63
|
+
align: "center",
|
|
64
|
+
direction: "horizontal-reverse",
|
|
65
|
+
paddingInline: 12,
|
|
66
|
+
className: styles.extra,
|
|
67
|
+
gap: 8
|
|
68
|
+
},
|
|
69
|
+
/* @__PURE__ */ React.createElement(
|
|
70
|
+
import_antd.Popconfirm,
|
|
71
|
+
{
|
|
72
|
+
title: "你即将要清空会话,清空后将无法找回。是否清空当前会话?",
|
|
73
|
+
okButtonProps: { danger: true },
|
|
74
|
+
okText: "清空会话",
|
|
75
|
+
onConfirm: () => {
|
|
76
|
+
dispatchMessage({ type: "resetMessages" });
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
/* @__PURE__ */ React.createElement(import_ActionIcon.default, { title: "清空当前会话", size: "small", icon: import_lucide_react.EraserIcon })
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ React.createElement(
|
|
82
|
+
import_antd.Tooltip,
|
|
83
|
+
{
|
|
84
|
+
title: [
|
|
85
|
+
agentToken > 0 ? `角色定义: ${agentToken}` : null,
|
|
86
|
+
messagesToken > 0 ? `会话: ${messagesToken}` : null
|
|
87
|
+
].filter(Boolean).join(" | ")
|
|
88
|
+
},
|
|
89
|
+
/* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { gap: 4 }, " Tokens: ", totalToken)
|
|
90
|
+
)
|
|
91
|
+
)) : null;
|
|
92
|
+
};
|
|
93
|
+
var ActionBar_default = (0, import_react.memo)(ActionBar);
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
ActionBar
|
|
97
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Conversation/InputArea/index.tsx
|
|
30
|
+
var InputArea_exports = {};
|
|
31
|
+
__export(InputArea_exports, {
|
|
32
|
+
InputArea: () => InputArea,
|
|
33
|
+
default: () => InputArea_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(InputArea_exports);
|
|
36
|
+
var import_icons = require("@ant-design/icons");
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_antd_style = require("antd-style");
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_react_layout_kit = require("react-layout-kit");
|
|
41
|
+
var import_shallow = require("zustand/shallow");
|
|
42
|
+
var import_store = require("../../Chat/store");
|
|
43
|
+
var import_ActionBar = __toESM(require("./ActionBar"));
|
|
44
|
+
var useStyles = (0, import_antd_style.createStyles)(({ css, responsive, token }) => ({
|
|
45
|
+
container: css`
|
|
46
|
+
position: sticky;
|
|
47
|
+
z-index: ${token.zIndexPopupBase};
|
|
48
|
+
bottom: 0;
|
|
49
|
+
|
|
50
|
+
width: ${token.contentWidth}px;
|
|
51
|
+
padding-top: 12px;
|
|
52
|
+
padding-bottom: 24px;
|
|
53
|
+
|
|
54
|
+
background-image: linear-gradient(to top, ${token.colorBgLayout} 88%, transparent 100%);
|
|
55
|
+
|
|
56
|
+
${responsive.mobile} {
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
boxShadow: css`
|
|
61
|
+
position: relative;
|
|
62
|
+
border-radius: 8px;
|
|
63
|
+
box-shadow: ${token.boxShadowSecondary};
|
|
64
|
+
`,
|
|
65
|
+
input: css`
|
|
66
|
+
width: 100%;
|
|
67
|
+
border-radius: 8px;
|
|
68
|
+
`,
|
|
69
|
+
btn: css`
|
|
70
|
+
position: absolute;
|
|
71
|
+
z-index: 10;
|
|
72
|
+
right: 8px;
|
|
73
|
+
bottom: 8px;
|
|
74
|
+
|
|
75
|
+
color: ${token.colorTextTertiary};
|
|
76
|
+
&:hover {
|
|
77
|
+
color: ${token.colorTextSecondary};
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
extra: css`
|
|
81
|
+
color: ${token.colorTextTertiary};
|
|
82
|
+
`
|
|
83
|
+
}));
|
|
84
|
+
var InputArea = ({}) => {
|
|
85
|
+
const [message, sendMessage, isLoading, disabled] = (0, import_store.useStore)(
|
|
86
|
+
(s) => [s.message, s.sendMessage, s.loading, import_store.chatSelectors.disableInput(s)],
|
|
87
|
+
import_shallow.shallow
|
|
88
|
+
);
|
|
89
|
+
const isChineseInput = (0, import_react.useRef)(false);
|
|
90
|
+
const { styles, theme } = useStyles();
|
|
91
|
+
const { mobile } = (0, import_antd_style.useResponsive)();
|
|
92
|
+
const storeApi = (0, import_store.useStoreApi)();
|
|
93
|
+
return /* @__PURE__ */ React.createElement(
|
|
94
|
+
import_antd.ConfigProvider,
|
|
95
|
+
{
|
|
96
|
+
theme: {
|
|
97
|
+
token: {
|
|
98
|
+
borderRadius: 4,
|
|
99
|
+
fontSize: 16,
|
|
100
|
+
colorBgContainer: theme.colorBgElevated,
|
|
101
|
+
controlHeightLG: 48,
|
|
102
|
+
colorBorder: "transparent",
|
|
103
|
+
colorPrimaryHover: "transparent"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
/* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { gap: 8, className: styles.container }, /* @__PURE__ */ React.createElement(import_ActionBar.default, null), /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { horizontal: true, gap: 8, align: "center", className: styles.boxShadow }, /* @__PURE__ */ React.createElement(
|
|
108
|
+
import_antd.Input.TextArea,
|
|
109
|
+
{
|
|
110
|
+
size: "large",
|
|
111
|
+
value: message,
|
|
112
|
+
placeholder: "请输入内容...",
|
|
113
|
+
onChange: (e) => {
|
|
114
|
+
storeApi.setState({ message: e.target.value });
|
|
115
|
+
},
|
|
116
|
+
disabled,
|
|
117
|
+
autoSize: { maxRows: 8 },
|
|
118
|
+
onCompositionStart: () => {
|
|
119
|
+
isChineseInput.current = true;
|
|
120
|
+
},
|
|
121
|
+
onCompositionEnd: () => {
|
|
122
|
+
isChineseInput.current = false;
|
|
123
|
+
},
|
|
124
|
+
className: styles.input,
|
|
125
|
+
onPressEnter: (e) => {
|
|
126
|
+
if (!isLoading && !e.shiftKey && !isChineseInput.current) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
sendMessage();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
), mobile ? null : /* @__PURE__ */ React.createElement(
|
|
133
|
+
import_antd.Button,
|
|
134
|
+
{
|
|
135
|
+
disabled,
|
|
136
|
+
loading: isLoading,
|
|
137
|
+
type: "text",
|
|
138
|
+
className: styles.btn,
|
|
139
|
+
onClick: sendMessage,
|
|
140
|
+
icon: /* @__PURE__ */ React.createElement(import_icons.SendOutlined, null)
|
|
141
|
+
}
|
|
142
|
+
)))
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
var InputArea_default = (0, import_react.memo)(InputArea);
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
InputArea
|
|
149
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { InternalChatContext } from '../Chat/types';
|
|
3
|
+
import { ChatStore } from '../Chat/store';
|
|
4
|
+
export interface StoreUpdaterProps extends Partial<InternalChatContext>, Pick<ChatStore, 'onMessagesChange' | 'onAgentChange' | 'onResponseFinished' | 'onResponseStart'> {
|
|
5
|
+
}
|
|
6
|
+
declare const StoreUpdater: FC<StoreUpdaterProps>;
|
|
7
|
+
export default StoreUpdater;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Conversation/StoreUpdater.tsx
|
|
20
|
+
var StoreUpdater_exports = {};
|
|
21
|
+
__export(StoreUpdater_exports, {
|
|
22
|
+
default: () => StoreUpdater_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(StoreUpdater_exports);
|
|
25
|
+
var import_zustand_utils = require("zustand-utils");
|
|
26
|
+
var import_store = require("../Chat/store");
|
|
27
|
+
var StoreUpdater = ({
|
|
28
|
+
updateAt,
|
|
29
|
+
createAt,
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
agent,
|
|
33
|
+
messages,
|
|
34
|
+
onAgentChange,
|
|
35
|
+
onMessagesChange,
|
|
36
|
+
onResponseFinished,
|
|
37
|
+
onResponseStart
|
|
38
|
+
}) => {
|
|
39
|
+
const useStoreUpdater = (0, import_zustand_utils.createStoreUpdater)((0, import_store.useStoreApi)());
|
|
40
|
+
useStoreUpdater("agent", agent);
|
|
41
|
+
useStoreUpdater("onAgentChange", onAgentChange);
|
|
42
|
+
useStoreUpdater("messages", messages);
|
|
43
|
+
useStoreUpdater("onMessagesChange", onMessagesChange);
|
|
44
|
+
useStoreUpdater("onResponseFinished", onResponseFinished);
|
|
45
|
+
useStoreUpdater("onResponseStart", onResponseStart);
|
|
46
|
+
useStoreUpdater("title", title);
|
|
47
|
+
useStoreUpdater("description", description);
|
|
48
|
+
useStoreUpdater("createAt", createAt);
|
|
49
|
+
useStoreUpdater("updateAt", updateAt);
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
var StoreUpdater_default = StoreUpdater;
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AppProps } from './App';
|
|
3
|
+
import { StoreUpdaterProps } from './StoreUpdater';
|
|
4
|
+
export interface ConversationProps extends StoreUpdaterProps, AppProps {
|
|
5
|
+
devtools?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const Conversation: import("react").NamedExoticComponent<ConversationProps>;
|
|
8
|
+
export default Conversation;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Conversation/index.tsx
|
|
30
|
+
var Conversation_exports = {};
|
|
31
|
+
__export(Conversation_exports, {
|
|
32
|
+
default: () => Conversation_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Conversation_exports);
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_store = require("../Chat/store");
|
|
37
|
+
var import_App = __toESM(require("./App"));
|
|
38
|
+
var import_StoreUpdater = __toESM(require("./StoreUpdater"));
|
|
39
|
+
var Conversation = (0, import_react.memo)(({ readonly, devtools, includeSystem, ...res }) => {
|
|
40
|
+
const ref = (0, import_react.useRef)(() => (0, import_store.createChatStore)(devtools));
|
|
41
|
+
return /* @__PURE__ */ React.createElement(import_store.Provider, { createStore: ref.current }, /* @__PURE__ */ React.createElement(import_App.default, { includeSystem, readonly }), /* @__PURE__ */ React.createElement(import_StoreUpdater.default, { ...res }));
|
|
42
|
+
});
|
|
43
|
+
var Conversation_default = Conversation;
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatMessage } from "../Chat";
|
|
3
|
+
export interface EditableMessageListProps {
|
|
4
|
+
dataSources: ChatMessage[];
|
|
5
|
+
onChange?: (chatMessages: ChatMessage[]) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const EditableMessageList: import("react").NamedExoticComponent<EditableMessageListProps>;
|
|
9
|
+
export default EditableMessageList;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/EditableMessageList/index.tsx
|
|
30
|
+
var EditableMessageList_exports = {};
|
|
31
|
+
__export(EditableMessageList_exports, {
|
|
32
|
+
EditableMessageList: () => EditableMessageList,
|
|
33
|
+
default: () => EditableMessageList_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(EditableMessageList_exports);
|
|
36
|
+
var import_icons = require("@ant-design/icons");
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_react_layout_kit = require("react-layout-kit");
|
|
41
|
+
var import_ActionIcon = __toESM(require("../ActionIcon"));
|
|
42
|
+
var import_Chat = require("../Chat");
|
|
43
|
+
var import_ControlInput = require("../components/ControlInput");
|
|
44
|
+
var import_lucide_react = require("lucide-react");
|
|
45
|
+
var EditableMessageList = (0, import_react.memo)(
|
|
46
|
+
({ disabled, dataSources, onChange }) => {
|
|
47
|
+
const [chatMessages, dispatch] = (0, import_react.useReducer)(import_Chat.messagesReducer, dataSources);
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (!(0, import_fast_deep_equal.default)(dataSources, chatMessages)) {
|
|
50
|
+
onChange == null ? void 0 : onChange(chatMessages);
|
|
51
|
+
}
|
|
52
|
+
}, [chatMessages]);
|
|
53
|
+
return !dataSources ? null : /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { gap: 12 }, chatMessages.map((item, index) => /* @__PURE__ */ React.createElement(
|
|
54
|
+
import_react_layout_kit.Flexbox,
|
|
55
|
+
{
|
|
56
|
+
horizontal: true,
|
|
57
|
+
gap: 8,
|
|
58
|
+
width: "100%",
|
|
59
|
+
align: "center",
|
|
60
|
+
key: `${index}-${item.content}`
|
|
61
|
+
},
|
|
62
|
+
/* @__PURE__ */ React.createElement(
|
|
63
|
+
import_antd.Select,
|
|
64
|
+
{
|
|
65
|
+
value: item.role,
|
|
66
|
+
style: { width: 120 },
|
|
67
|
+
dropdownStyle: { zIndex: 100 },
|
|
68
|
+
disabled,
|
|
69
|
+
onChange: (value) => {
|
|
70
|
+
dispatch({ type: "updateMessageRole", index, role: value });
|
|
71
|
+
},
|
|
72
|
+
options: [
|
|
73
|
+
{ value: "system", label: "系统" },
|
|
74
|
+
{ value: "user", label: "输入" },
|
|
75
|
+
{ value: "assistant", label: "输出" }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ React.createElement(
|
|
80
|
+
import_ControlInput.ControlInput,
|
|
81
|
+
{
|
|
82
|
+
disabled,
|
|
83
|
+
value: item.content,
|
|
84
|
+
onChange: (e) => {
|
|
85
|
+
dispatch({ type: "updateMessage", index, message: e });
|
|
86
|
+
},
|
|
87
|
+
placeholder: item.role === "user" ? "请填入输入的样例内容" : "请填入输出的样例"
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ React.createElement(
|
|
91
|
+
import_ActionIcon.default,
|
|
92
|
+
{
|
|
93
|
+
icon: import_lucide_react.TrashIcon,
|
|
94
|
+
title: "删除",
|
|
95
|
+
size: "small",
|
|
96
|
+
onClick: () => {
|
|
97
|
+
dispatch({ type: "deleteMessage", index });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
)), /* @__PURE__ */ React.createElement(
|
|
102
|
+
import_antd.Button,
|
|
103
|
+
{
|
|
104
|
+
block: true,
|
|
105
|
+
disabled,
|
|
106
|
+
icon: /* @__PURE__ */ React.createElement(import_icons.PlusOutlined, null),
|
|
107
|
+
onClick: () => {
|
|
108
|
+
const lastMeg = chatMessages.at(-1);
|
|
109
|
+
dispatch({
|
|
110
|
+
type: "addMessage",
|
|
111
|
+
message: { role: (lastMeg == null ? void 0 : lastMeg.role) === "user" ? "assistant" : "user", content: "" }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"添加一项"
|
|
116
|
+
));
|
|
117
|
+
},
|
|
118
|
+
import_fast_deep_equal.default
|
|
119
|
+
);
|
|
120
|
+
var EditableMessageList_default = EditableMessageList;
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
EditableMessageList
|
|
124
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ControlInputProps } from
|
|
2
|
+
import { ControlInputProps } from "../components/ControlInput";
|
|
3
3
|
export declare type EditableTextProps = ControlInputProps;
|
|
4
4
|
declare const EditableText: import("react").NamedExoticComponent<ControlInputProps>;
|
|
5
5
|
export default EditableText;
|
|
@@ -26,7 +26,7 @@ var import_icons = require("@ant-design/icons");
|
|
|
26
26
|
var import_antd = require("antd");
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_react_layout_kit = require("react-layout-kit");
|
|
29
|
-
var import_ControlInput = require("
|
|
29
|
+
var import_ControlInput = require("../components/ControlInput");
|
|
30
30
|
var EditableText = (0, import_react.memo)(({ value, onChange }) => {
|
|
31
31
|
const [edited, setEdited] = (0, import_react.useState)(false);
|
|
32
32
|
return edited ? /* @__PURE__ */ React.createElement(
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/
|
|
19
|
+
// src/components/ControlInput.tsx
|
|
20
20
|
var ControlInput_exports = {};
|
|
21
21
|
__export(ControlInput_exports, {
|
|
22
22
|
ControlInput: () => ControlInput
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from './ActionIcon';
|
|
2
2
|
export { default as Avatar, type AvatarProps } from './Avatar';
|
|
3
|
+
export type { ChatMessage } from './Chat';
|
|
3
4
|
export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
|
|
5
|
+
export { default as Conversation, type ConversationProps } from './Conversation';
|
|
4
6
|
export { default as CopyButton, type CopyButtonProps } from './CopyButton';
|
|
5
7
|
export { default as DraggablePanel, type DraggablePanelProps } from './DraggablePanel';
|
|
6
8
|
export { default as EditableMessage, type EditableMessageProps } from './EditableMessage';
|
|
9
|
+
export { default as EditableMessageList, type EditableMessageListProps, } from './EditableMessageList';
|
|
7
10
|
export { default as EditableText, type EditableTextProps } from './EditableText';
|
|
8
11
|
export { default as Highlighter, SyntaxHighlighter, type HighlighterProps, type SyntaxHighlighterProps, } from './Highlighter';
|
|
9
12
|
export { default as Icon, type IconProps, type IconSize } from './Icon';
|
package/lib/index.js
CHANGED
|
@@ -32,9 +32,11 @@ __export(src_exports, {
|
|
|
32
32
|
ActionIcon: () => import_ActionIcon.default,
|
|
33
33
|
Avatar: () => import_Avatar.default,
|
|
34
34
|
ContextMenu: () => import_ContextMenu.default,
|
|
35
|
+
Conversation: () => import_Conversation.default,
|
|
35
36
|
CopyButton: () => import_CopyButton.default,
|
|
36
37
|
DraggablePanel: () => import_DraggablePanel.default,
|
|
37
38
|
EditableMessage: () => import_EditableMessage.default,
|
|
39
|
+
EditableMessageList: () => import_EditableMessageList.default,
|
|
38
40
|
EditableText: () => import_EditableText.default,
|
|
39
41
|
Highlighter: () => import_Highlighter.default,
|
|
40
42
|
Icon: () => import_Icon.default,
|
|
@@ -60,9 +62,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
60
62
|
var import_ActionIcon = __toESM(require("./ActionIcon"));
|
|
61
63
|
var import_Avatar = __toESM(require("./Avatar"));
|
|
62
64
|
var import_ContextMenu = __toESM(require("./ContextMenu"));
|
|
65
|
+
var import_Conversation = __toESM(require("./Conversation"));
|
|
63
66
|
var import_CopyButton = __toESM(require("./CopyButton"));
|
|
64
67
|
var import_DraggablePanel = __toESM(require("./DraggablePanel"));
|
|
65
68
|
var import_EditableMessage = __toESM(require("./EditableMessage"));
|
|
69
|
+
var import_EditableMessageList = __toESM(require("./EditableMessageList"));
|
|
66
70
|
var import_EditableText = __toESM(require("./EditableText"));
|
|
67
71
|
var import_Highlighter = __toESM(require("./Highlighter"));
|
|
68
72
|
var import_Icon = __toESM(require("./Icon"));
|
|
@@ -85,9 +89,11 @@ var import_Tooltip = __toESM(require("./Tooltip"));
|
|
|
85
89
|
ActionIcon,
|
|
86
90
|
Avatar,
|
|
87
91
|
ContextMenu,
|
|
92
|
+
Conversation,
|
|
88
93
|
CopyButton,
|
|
89
94
|
DraggablePanel,
|
|
90
95
|
EditableMessage,
|
|
96
|
+
EditableMessageList,
|
|
91
97
|
EditableText,
|
|
92
98
|
Highlighter,
|
|
93
99
|
Icon,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building chatbot web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -65,12 +65,15 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@ant-design/icons": "^5",
|
|
67
67
|
"@babel/runtime": "^7",
|
|
68
|
+
"@dqbd/tiktoken": "^1",
|
|
68
69
|
"@floating-ui/react": "^0.24",
|
|
69
70
|
"ahooks": "^3",
|
|
70
71
|
"antd-style": "^3",
|
|
71
72
|
"chroma-js": "^2",
|
|
72
73
|
"copy-to-clipboard": "^3",
|
|
73
74
|
"dayjs": "^1",
|
|
75
|
+
"fast-deep-equal": "^3",
|
|
76
|
+
"immer": "^10",
|
|
74
77
|
"leva": "^0.9.34",
|
|
75
78
|
"lodash": "^4",
|
|
76
79
|
"lucide-react": "latest",
|
|
@@ -83,8 +86,10 @@
|
|
|
83
86
|
"remark-gfm": "^3.0.1",
|
|
84
87
|
"shiki-es": "^0.2",
|
|
85
88
|
"styled-components": "^6.0.0-rc.1",
|
|
89
|
+
"ts-md5": "^1",
|
|
86
90
|
"use-merge-value": "^1",
|
|
87
|
-
"zustand": "^4"
|
|
91
|
+
"zustand": "^4",
|
|
92
|
+
"zustand-utils": "^1"
|
|
88
93
|
},
|
|
89
94
|
"devDependencies": {
|
|
90
95
|
"@ant-design/colors": "^7",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|