@lobehub/ui 1.20.1 → 1.21.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.
@@ -10,6 +10,6 @@ export var useStyles = createStyles(function (_ref, _ref2) {
10
10
  var backgroundColor = background !== null && background !== void 0 ? background : token.colorBgContainer;
11
11
  var color = readableColor(backgroundColor);
12
12
  return {
13
- avatar: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n font-size: ", "px;\n font-weight: 700;\n line-height: 1;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n\n > * {\n cursor: pointer;\n }\n "])), size * 0.5, color, backgroundColor, background ? 'transparent' : token.colorSplit)
13
+ avatar: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n background: ", ";\n border: 1px solid ", ";\n\n > .ant-avatar-string {\n font-size: ", "px;\n font-weight: 700;\n line-height: 1 !important;\n color: ", ";\n }\n\n > * {\n cursor: pointer;\n }\n "])), backgroundColor, background ? 'transparent' : token.colorSplit, size * 0.5, color)
14
14
  };
15
15
  });
@@ -0,0 +1,54 @@
1
+ /// <reference types="react" />
2
+ import { type AlertProps } from 'antd';
3
+ import type { DivProps } from "../types";
4
+ import { MetaData } from "../types/meta";
5
+ export interface ChatItemProps extends DivProps {
6
+ /**
7
+ * @description Whether to show alert and alert config
8
+ */
9
+ alert?: AlertProps;
10
+ /**
11
+ * @description Avatar config
12
+ */
13
+ avatar: MetaData;
14
+ /**
15
+ * @description Whether to add spacing between chat items
16
+ * @default true
17
+ */
18
+ borderSpacing?: boolean;
19
+ /**
20
+ * @description Whether to show a loading spinner
21
+ * @default false
22
+ */
23
+ loading?: boolean;
24
+ /**
25
+ * @description The message to be displayed
26
+ */
27
+ message?: string;
28
+ /**
29
+ * @description The placement of the chat item
30
+ * @default 'left'
31
+ */
32
+ placement?: 'left' | 'right';
33
+ /**
34
+ * @description Whether the chat item is primary
35
+ * @default false
36
+ */
37
+ primary?: boolean;
38
+ /**
39
+ * @description Whether to show name of the chat item
40
+ * @default false
41
+ */
42
+ showTitle?: boolean;
43
+ /**
44
+ * @description Time of chat message
45
+ */
46
+ time?: number;
47
+ /**
48
+ * @description The type of chat item
49
+ * @default 'block'
50
+ */
51
+ type?: 'block' | 'pure';
52
+ }
53
+ declare const ChatItem: import("react").NamedExoticComponent<ChatItemProps>;
54
+ export default ChatItem;
@@ -0,0 +1,87 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "title", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert", "showTitle", "time"];
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ import { Alert } from 'antd';
7
+ import { Loader2 } from 'lucide-react';
8
+ import { memo } from 'react';
9
+ import { Avatar, Icon, Markdown } from "./..";
10
+ import { formatTime } from "../utils/formatTime";
11
+ import { useStyles } from "./style";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ var AVATAR_SIZE = 40;
15
+ var ChatItem = /*#__PURE__*/memo(function (_ref) {
16
+ var className = _ref.className,
17
+ title = _ref.title,
18
+ primary = _ref.primary,
19
+ _ref$borderSpacing = _ref.borderSpacing,
20
+ borderSpacing = _ref$borderSpacing === void 0 ? true : _ref$borderSpacing,
21
+ loading = _ref.loading,
22
+ message = _ref.message,
23
+ _ref$placement = _ref.placement,
24
+ placement = _ref$placement === void 0 ? 'left' : _ref$placement,
25
+ _ref$type = _ref.type,
26
+ type = _ref$type === void 0 ? 'block' : _ref$type,
27
+ avatar = _ref.avatar,
28
+ alert = _ref.alert,
29
+ showTitle = _ref.showTitle,
30
+ time = _ref.time,
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ var _useStyles = useStyles({
33
+ placement: placement,
34
+ type: type,
35
+ title: title,
36
+ primary: primary,
37
+ avatarSize: AVATAR_SIZE,
38
+ showTitle: showTitle
39
+ }),
40
+ cx = _useStyles.cx,
41
+ styles = _useStyles.styles;
42
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
43
+ className: cx(styles.container, className)
44
+ }, props), {}, {
45
+ children: [/*#__PURE__*/_jsxs("div", {
46
+ className: styles.avatarContainer,
47
+ children: [/*#__PURE__*/_jsx(Avatar, {
48
+ avatar: avatar.avatar,
49
+ background: avatar.backgroundColor,
50
+ size: AVATAR_SIZE,
51
+ title: avatar.title
52
+ }), loading && /*#__PURE__*/_jsx("div", {
53
+ className: styles.loading,
54
+ children: /*#__PURE__*/_jsx(Icon, {
55
+ icon: Loader2,
56
+ size: {
57
+ fontSize: 12,
58
+ strokeWidth: 3
59
+ },
60
+ spin: true
61
+ })
62
+ })]
63
+ }), /*#__PURE__*/_jsxs("div", {
64
+ className: styles.messageContainer,
65
+ children: [/*#__PURE__*/_jsxs("div", {
66
+ className: cx(styles.name, 'chat-item-name'),
67
+ children: [showTitle ? avatar.title || 'untitled' : null, time && /*#__PURE__*/_jsx("span", {
68
+ className: cx(type === 'pure' && !showTitle && styles.time, 'chat-item-time'),
69
+ children: formatTime(time)
70
+ })]
71
+ }), alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
72
+ showIcon: true
73
+ }, alert)) : /*#__PURE__*/_jsx("div", {
74
+ className: styles.message,
75
+ children: /*#__PURE__*/_jsx(Markdown, {
76
+ children: String(message || '...')
77
+ })
78
+ })]
79
+ }), borderSpacing && /*#__PURE__*/_jsx("div", {
80
+ style: {
81
+ width: AVATAR_SIZE,
82
+ flex: 'none'
83
+ }
84
+ })]
85
+ }));
86
+ });
87
+ export default ChatItem;
@@ -0,0 +1,16 @@
1
+ export declare const useStyles: (props?: {
2
+ avatarSize: number;
3
+ placement?: "left" | "right" | undefined;
4
+ primary?: boolean | undefined;
5
+ showTitle?: boolean | undefined;
6
+ title?: string | undefined;
7
+ type?: "block" | "pure" | undefined;
8
+ } | undefined) => import("antd-style").ReturnStyles<{
9
+ container: string;
10
+ loading: import("antd-style").SerializedStyles;
11
+ avatarContainer: import("antd-style").SerializedStyles;
12
+ messageContainer: import("antd-style").SerializedStyles;
13
+ name: import("antd-style").SerializedStyles;
14
+ time: string;
15
+ message: string;
16
+ }>;
@@ -0,0 +1,28 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
+ var cx = _ref.cx,
6
+ css = _ref.css,
7
+ token = _ref.token,
8
+ stylish = _ref.stylish;
9
+ var placement = _ref2.placement,
10
+ type = _ref2.type,
11
+ title = _ref2.title,
12
+ primary = _ref2.primary,
13
+ avatarSize = _ref2.avatarSize,
14
+ showTitle = _ref2.showTitle;
15
+ var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px 12px;\n background-color: ", ";\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:active {\n background-color: ", ";\n }\n "])), primary ? token.colorFillSecondary : token.colorFillTertiary, token.borderRadiusLG, token.motionEaseOut, primary ? token.colorFill : token.colorFillSecondary);
16
+ var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])), title ? 0 : '6px');
17
+ var pureContainerStylish = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n "])), token.borderRadiusLG, token.motionEaseOut, token.colorFillTertiary, token.colorFillSecondary);
18
+ var typeStylish = type === 'block' ? blockStylish : pureStylish;
19
+ return {
20
+ container: cx(type === 'pure' && pureContainerStylish, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\n\n .chat-item-time {\n display: none;\n }\n\n &:hover {\n .chat-item-time {\n display: inline-block;\n }\n }\n "])), placement === 'left' ? 'row' : 'row-reverse')),
21
+ loading: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
22
+ avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
23
+ messageContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n\n .ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n }\n "]))),
24
+ name: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n display: flex;\n flex-direction: ", ";\n gap: 4px;\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', placement === 'left' ? 'row' : 'row-reverse', token.colorTextDescription, placement === 'left' ? 'left' : 'right'),
25
+ time: cx(stylish.blur, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: 4px 6px;\n\n line-height: 1;\n\n background: ", ";\n border-radius: ", "px;\n "])), token.colorFillQuaternary, token.borderRadius)),
26
+ message: cx(typeStylish, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n "]))))
27
+ };
28
+ });
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { ChatItemProps } from "../index";
3
+ import type { DivProps } from "../types";
4
+ import { ChatMessage } from "../types/chatMessage";
5
+ export interface ChatListProps extends DivProps {
6
+ /**
7
+ * @description Data of chat messages to be displayed
8
+ */
9
+ data: ChatMessage[];
10
+ /**
11
+ * @description Whether to show name of the chat item
12
+ * @default false
13
+ */
14
+ showTitle?: ChatItemProps['showTitle'];
15
+ /**
16
+ * @description Type of chat list
17
+ * @default 'chat'
18
+ */
19
+ type?: 'docs' | 'chat';
20
+ }
21
+ declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
22
+ export default ChatList;
@@ -0,0 +1,37 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "data", "type", "showTitle"];
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ import { memo } from 'react';
7
+ import { ChatItem } from "./..";
8
+ import { useStyles } from "./style";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ var ChatList = /*#__PURE__*/memo(function (_ref) {
11
+ var className = _ref.className,
12
+ data = _ref.data,
13
+ _ref$type = _ref.type,
14
+ type = _ref$type === void 0 ? 'chat' : _ref$type,
15
+ showTitle = _ref.showTitle,
16
+ props = _objectWithoutProperties(_ref, _excluded);
17
+ var _useStyles = useStyles(),
18
+ cx = _useStyles.cx,
19
+ styles = _useStyles.styles;
20
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
21
+ className: cx(styles.container, className)
22
+ }, props), {}, {
23
+ children: data.map(function (item) {
24
+ return /*#__PURE__*/_jsx(ChatItem, {
25
+ avatar: item.meta,
26
+ borderSpacing: type === 'chat',
27
+ message: item.content,
28
+ placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
29
+ primary: item.role === 'user',
30
+ showTitle: showTitle,
31
+ time: item.updateAt || item.createAt,
32
+ type: type === 'chat' ? 'block' : 'pure'
33
+ }, item.id);
34
+ })
35
+ }));
36
+ });
37
+ export default ChatList;
@@ -0,0 +1,3 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ container: import("antd-style").SerializedStyles;
3
+ }>;
@@ -0,0 +1,9 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n "])))
8
+ };
9
+ });
@@ -30,7 +30,7 @@ export interface HighlighterProps extends DivProps {
30
30
  * @description The type of the code block
31
31
  * @default 'block'
32
32
  */
33
- type?: 'ghost' | 'block' | 'prue';
33
+ type?: 'ghost' | 'block' | 'pure';
34
34
  }
35
35
  export declare const Highlighter: import("react").NamedExoticComponent<HighlighterProps>;
36
36
  export default Highlighter;
@@ -1,4 +1,4 @@
1
- export declare const useStyles: (props?: "block" | "ghost" | "prue" | undefined) => import("antd-style").ReturnStyles<{
1
+ export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
2
2
  container: string;
3
3
  button: string;
4
4
  lang: string;
@@ -9,9 +9,9 @@ export var useStyles = createStyles(function (_ref, type) {
9
9
  var prefix = "".concat(prefixCls, "-highlighter");
10
10
  var buttonHoverCls = "".concat(prefix, "-hover-btn");
11
11
  var langHoverCls = "".concat(prefix, "-hover-lang");
12
- var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'prue' ? 'transparent' : token.colorFillTertiary);
12
+ var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'pure' ? 'transparent' : token.colorFillTertiary);
13
13
  return {
14
- container: cx(prefix, typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'prue' ? 0 : "16px 24px")),
14
+ container: cx(prefix, typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px 24px")),
15
15
  button: cx(buttonHoverCls, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 51;\n top: 8px;\n right: 8px;\n\n opacity: 0;\n "])))),
16
16
  lang: cx(langHoverCls, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 50;\n right: 8px;\n bottom: 8px;\n\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.colorTextPlaceholder))
17
17
  };
package/es/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from './ActionIcon';
2
2
  export { default as Avatar, type AvatarProps } from './Avatar';
3
3
  export type { ChatMessage, MessageRoleType } from './Chat';
4
+ export { default as ChatItem, type ChatItemProps } from './ChatItem';
5
+ export { default as ChatList, type ChatListProps } from './ChatList';
4
6
  export { default as ColorScales, type ColorScalesProps } from './ColorScales';
5
7
  export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
6
8
  export { default as Conversation, type ConversationProps } from './Conversation';
package/es/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export { default as ActionIcon } from "./ActionIcon";
2
2
  export { default as Avatar } from "./Avatar";
3
+ export { default as ChatItem } from "./ChatItem";
4
+ export { default as ChatList } from "./ChatList";
3
5
  export { default as ColorScales } from "./ColorScales";
4
6
  export { default as ContextMenu } from "./ContextMenu";
5
7
  export { default as Conversation } from "./Conversation";
@@ -6,6 +6,6 @@ export var generateCustomStylish = function generateCustomStylish(_ref) {
6
6
  isDarkMode = _ref.isDarkMode;
7
7
  return {
8
8
  blur: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n backdrop-filter: saturate(180%) blur(10px);\n "]))),
9
- markdown: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin: 20px auto;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n ul li {\n line-height: 1.8;\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius)
9
+ markdown: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block-start: 0;\n margin-block-end: 0;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 0.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n ul li {\n line-height: 1.8;\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius)
10
10
  };
11
11
  };
@@ -0,0 +1,33 @@
1
+ import { LLMRoleType } from './llm';
2
+ import { BaseDataModel } from './meta';
3
+ /**
4
+ * 聊天消息错误对象
5
+ */
6
+ export interface ChatMessageError {
7
+ /**
8
+ * 错误信息
9
+ */
10
+ message: string;
11
+ status: number;
12
+ type: 'general' | 'llm';
13
+ }
14
+ export interface ChatMessage extends BaseDataModel {
15
+ /**
16
+ * @title 内容
17
+ * @description 消息内容
18
+ */
19
+ content: string;
20
+ extra?: {
21
+ translate: {
22
+ target: string;
23
+ to: string;
24
+ };
25
+ } & Record<string, any>;
26
+ parentId?: string;
27
+ quotaId?: string;
28
+ /**
29
+ * 角色
30
+ * @description 消息发送者的角色
31
+ */
32
+ role: LLMRoleType;
33
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * LLM 模型
3
+ */
4
+ export declare enum LanguageModel {
5
+ /**
6
+ * GPT 3.5 Turbo
7
+ */
8
+ GPT3_5 = "gpt-3.5-turbo",
9
+ /**
10
+ * GPT 4
11
+ */
12
+ GPT4 = "gpt-4"
13
+ }
14
+ export interface LLMParams {
15
+ /**
16
+ * 控制生成文本中的惩罚系数,用于减少重复性
17
+ */
18
+ frequency_penalty?: number;
19
+ /**
20
+ * 生成文本的最大长度
21
+ */
22
+ max_tokens?: number;
23
+ /**
24
+ * 控制生成文本中的惩罚系数,用于减少主题的变化
25
+ */
26
+ presence_penalty?: number;
27
+ /**
28
+ * 生成文本的随机度量,用于控制文本的创造性和多样性
29
+ * @default 0.8
30
+ */
31
+ temperature: number;
32
+ /**
33
+ * 控制生成文本中最高概率的单个 token
34
+ */
35
+ top_p?: number;
36
+ }
37
+ export declare type LLMRoleType = 'user' | 'system' | 'assistant';
38
+ export interface LLMMessage {
39
+ content: string;
40
+ role: LLMRoleType;
41
+ }
42
+ export declare type LLMExample = LLMMessage[];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * LLM 模型
3
+ */
4
+ export var LanguageModel;
5
+
6
+ // 语言模型的设置参数
7
+ (function (LanguageModel) {
8
+ LanguageModel["GPT3_5"] = "gpt-3.5-turbo";
9
+ LanguageModel["GPT4"] = "gpt-4";
10
+ })(LanguageModel || (LanguageModel = {}));
@@ -0,0 +1,25 @@
1
+ export interface MetaData {
2
+ /**
3
+ * 角色头像
4
+ * @description 可选参数,如果不传则使用默认头像
5
+ */
6
+ avatar?: string;
7
+ /**
8
+ * 背景色
9
+ * @description 可选参数,如果不传则使用默认背景色
10
+ */
11
+ backgroundColor?: string;
12
+ description?: string;
13
+ tag?: string[];
14
+ /**
15
+ * 名称
16
+ * @description 可选参数,如果不传则使用默认名称
17
+ */
18
+ title?: string;
19
+ }
20
+ export interface BaseDataModel {
21
+ createAt?: number;
22
+ id: string;
23
+ meta: MetaData;
24
+ updateAt?: number;
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const formatTime: (time: number) => string;
@@ -0,0 +1,12 @@
1
+ import dayjs from 'dayjs';
2
+ export var formatTime = function formatTime(time) {
3
+ var now = dayjs();
4
+ var target = dayjs(time);
5
+ if (target.isSame(now, 'day')) {
6
+ return target.format('HH:mm');
7
+ } else if (target.isSame(now, 'year')) {
8
+ return target.format('MM-DD HH:mm');
9
+ } else {
10
+ return target.format('YYYY-MM-DD HH:mm');
11
+ }
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.20.1",
3
+ "version": "1.21.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",