@lobehub/chat 1.62.5 → 1.62.7
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/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/environment-variables/model-provider.mdx +17 -0
- package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +16 -0
- package/docs/self-hosting/platform/sealos.mdx +8 -8
- package/docs/self-hosting/platform/sealos.zh-CN.mdx +7 -7
- package/docs/self-hosting/server-database/sealos.mdx +84 -5
- package/docs/self-hosting/server-database/sealos.zh-CN.mdx +105 -5
- package/docs/self-hosting/start.zh-CN.mdx +2 -1
- package/locales/ar/plugin.json +4 -0
- package/locales/bg-BG/plugin.json +4 -0
- package/locales/de-DE/plugin.json +4 -0
- package/locales/en-US/plugin.json +4 -0
- package/locales/es-ES/plugin.json +4 -0
- package/locales/fa-IR/plugin.json +4 -0
- package/locales/fr-FR/plugin.json +4 -0
- package/locales/it-IT/plugin.json +4 -0
- package/locales/ja-JP/plugin.json +4 -0
- package/locales/ko-KR/plugin.json +4 -0
- package/locales/nl-NL/plugin.json +4 -0
- package/locales/pl-PL/plugin.json +4 -0
- package/locales/pt-BR/plugin.json +4 -0
- package/locales/ru-RU/plugin.json +4 -0
- package/locales/tr-TR/plugin.json +4 -0
- package/locales/vi-VN/plugin.json +4 -0
- package/locales/zh-CN/plugin.json +5 -1
- package/locales/zh-TW/plugin.json +4 -0
- package/package.json +1 -1
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +1 -1
- package/src/config/aiModels/volcengine.ts +249 -2
- package/src/database/server/models/aiProvider.ts +22 -9
- package/src/database/server/models/topic.ts +2 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/Debug.tsx +43 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/Loader.tsx +58 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx +151 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Render/Arguments.tsx +165 -0
- package/src/features/Conversation/Messages/Assistant/{ToolCallItem/Tool.tsx → Tool/Render/CustomRender.tsx} +34 -35
- package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +39 -0
- package/src/features/Conversation/Messages/Assistant/Tool/index.tsx +70 -0
- package/src/features/Conversation/Messages/Assistant/index.tsx +19 -27
- package/src/features/InitClientDB/PGliteIcon.tsx +2 -2
- package/src/features/PluginsUI/Render/index.tsx +2 -11
- package/src/locales/default/plugin.ts +4 -0
- package/src/styles/loading.ts +27 -0
- package/src/tools/dalle/Render/GalleyGrid.tsx +60 -0
- package/src/tools/dalle/Render/index.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/Inspector/index.tsx +0 -166
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/Inspector/style.ts +0 -35
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/index.tsx +0 -89
- package/src/features/Conversation/Messages/Assistant/ToolCallItem/style.ts +0 -35
- package/src/features/Conversation/Messages/components/Arguments.tsx +0 -22
- /package/src/features/Conversation/Messages/Assistant/{ToolCallItem → Tool}/Inspector/PluginResultJSON.tsx +0 -0
- /package/src/features/Conversation/Messages/Assistant/{ToolCallItem → Tool}/Inspector/Settings.tsx +0 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
import { useResponsive } from 'antd-style';
|
2
|
+
import { ReactNode, memo, useMemo } from 'react';
|
3
|
+
import { Flexbox } from 'react-layout-kit';
|
4
|
+
|
5
|
+
import Grid from '@/components/GalleyGrid/Grid';
|
6
|
+
|
7
|
+
const MAX_SIZE_DESKTOP = 640;
|
8
|
+
const MAX_SIZE_MOBILE = 280;
|
9
|
+
|
10
|
+
interface GalleyGridProps<T = any> {
|
11
|
+
items: T[];
|
12
|
+
renderItem: (props: T) => ReactNode;
|
13
|
+
}
|
14
|
+
|
15
|
+
const GalleyGrid = memo<GalleyGridProps>(({ items, renderItem: Render }) => {
|
16
|
+
const { mobile } = useResponsive();
|
17
|
+
|
18
|
+
const { firstRow, lastRow } = useMemo(() => {
|
19
|
+
if (items.length === 4) {
|
20
|
+
return {
|
21
|
+
firstRow: items.slice(0, 2),
|
22
|
+
lastRow: items.slice(2, 4),
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
const firstCol = items.length % 3 === 0 ? 3 : items.length % 3;
|
27
|
+
|
28
|
+
return {
|
29
|
+
firstRow: items.slice(0, firstCol),
|
30
|
+
lastRow: items.slice(firstCol, items.length),
|
31
|
+
};
|
32
|
+
}, [items]);
|
33
|
+
|
34
|
+
const { gap, max } = useMemo(
|
35
|
+
() => ({
|
36
|
+
gap: mobile ? 4 : 6,
|
37
|
+
max: (mobile ? MAX_SIZE_MOBILE : MAX_SIZE_DESKTOP) * firstRow.length,
|
38
|
+
}),
|
39
|
+
[mobile],
|
40
|
+
);
|
41
|
+
|
42
|
+
return (
|
43
|
+
<Flexbox gap={gap}>
|
44
|
+
<Grid col={firstRow.length} gap={gap} max={max}>
|
45
|
+
{firstRow.map((i, index) => (
|
46
|
+
<Render {...i} index={index} key={index} />
|
47
|
+
))}
|
48
|
+
</Grid>
|
49
|
+
{lastRow.length > 0 && (
|
50
|
+
<Grid col={lastRow.length > 2 ? 3 : lastRow.length} gap={gap} max={max}>
|
51
|
+
{lastRow.map((i, index) => (
|
52
|
+
<Render {...i} index={index} key={index} />
|
53
|
+
))}
|
54
|
+
</Grid>
|
55
|
+
)}
|
56
|
+
</Flexbox>
|
57
|
+
);
|
58
|
+
});
|
59
|
+
|
60
|
+
export default GalleyGrid;
|
@@ -3,11 +3,11 @@ import { Download } from 'lucide-react';
|
|
3
3
|
import { memo, useRef } from 'react';
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
5
5
|
|
6
|
-
import GalleyGrid from '@/components/GalleyGrid';
|
7
6
|
import { fileService } from '@/services/file';
|
8
7
|
import { BuiltinRenderProps } from '@/types/tool';
|
9
8
|
import { DallEImageItem } from '@/types/tool/dalle';
|
10
9
|
|
10
|
+
import GalleyGrid from './GalleyGrid';
|
11
11
|
import ImageItem from './Item';
|
12
12
|
|
13
13
|
const DallE = memo<BuiltinRenderProps<DallEImageItem[]>>(({ content, messageId }) => {
|
@@ -1,166 +0,0 @@
|
|
1
|
-
import { Loading3QuartersOutlined } from '@ant-design/icons';
|
2
|
-
import { ActionIcon, Highlighter, Icon, Tag } from '@lobehub/ui';
|
3
|
-
import { Tabs, Typography } from 'antd';
|
4
|
-
import isEqual from 'fast-deep-equal';
|
5
|
-
import {
|
6
|
-
BetweenVerticalStart,
|
7
|
-
LucideBug,
|
8
|
-
LucideBugOff,
|
9
|
-
LucideChevronDown,
|
10
|
-
LucideChevronRight,
|
11
|
-
} from 'lucide-react';
|
12
|
-
import { memo, useState } from 'react';
|
13
|
-
import { useTranslation } from 'react-i18next';
|
14
|
-
import { Flexbox } from 'react-layout-kit';
|
15
|
-
|
16
|
-
import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
|
17
|
-
import PluginAvatar from '@/features/PluginAvatar';
|
18
|
-
import { useIsMobile } from '@/hooks/useIsMobile';
|
19
|
-
import { useChatStore } from '@/store/chat';
|
20
|
-
import { chatPortalSelectors } from '@/store/chat/selectors';
|
21
|
-
import { pluginHelpers, useToolStore } from '@/store/tool';
|
22
|
-
import { toolSelectors } from '@/store/tool/selectors';
|
23
|
-
import { ChatPluginPayload } from '@/types/message';
|
24
|
-
|
25
|
-
import PluginResult from './PluginResultJSON';
|
26
|
-
import Settings from './Settings';
|
27
|
-
import { useStyles } from './style';
|
28
|
-
|
29
|
-
export interface InspectorProps {
|
30
|
-
arguments?: string;
|
31
|
-
content: string;
|
32
|
-
id: string;
|
33
|
-
identifier?: string;
|
34
|
-
loading?: boolean;
|
35
|
-
payload?: ChatPluginPayload;
|
36
|
-
setShow?: (showRender: boolean) => void;
|
37
|
-
showPortal?: boolean;
|
38
|
-
showRender?: boolean;
|
39
|
-
}
|
40
|
-
|
41
|
-
const Inspector = memo<InspectorProps>(
|
42
|
-
({
|
43
|
-
arguments: requestArgs = '{}',
|
44
|
-
payload,
|
45
|
-
showRender,
|
46
|
-
loading,
|
47
|
-
setShow,
|
48
|
-
content,
|
49
|
-
identifier = 'unknown',
|
50
|
-
id,
|
51
|
-
showPortal = true,
|
52
|
-
}) => {
|
53
|
-
const { t } = useTranslation(['plugin', 'portal']);
|
54
|
-
const { styles } = useStyles();
|
55
|
-
const [open, setOpen] = useState(false);
|
56
|
-
const [isMessageToolUIOpen, openToolUI, togglePortal] = useChatStore((s) => [
|
57
|
-
chatPortalSelectors.isPluginUIOpen(id)(s),
|
58
|
-
s.openToolUI,
|
59
|
-
s.togglePortal,
|
60
|
-
]);
|
61
|
-
|
62
|
-
const isMobile = useIsMobile();
|
63
|
-
const pluginMeta = useToolStore(toolSelectors.getMetaById(identifier), isEqual);
|
64
|
-
|
65
|
-
const showRightAction = useToolStore(toolSelectors.isToolHasUI(identifier));
|
66
|
-
|
67
|
-
const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
|
68
|
-
|
69
|
-
let args, params;
|
70
|
-
try {
|
71
|
-
args = JSON.stringify(payload, null, 2);
|
72
|
-
params = JSON.stringify(JSON.parse(requestArgs), null, 2);
|
73
|
-
} catch {
|
74
|
-
args = '';
|
75
|
-
params = '';
|
76
|
-
}
|
77
|
-
|
78
|
-
return (
|
79
|
-
<Flexbox gap={8}>
|
80
|
-
<Flexbox align={'center'} distribution={'space-between'} gap={24} horizontal>
|
81
|
-
<Flexbox
|
82
|
-
align={'center'}
|
83
|
-
className={styles.container}
|
84
|
-
gap={isMobile ? 16 : 8}
|
85
|
-
horizontal
|
86
|
-
onClick={() => {
|
87
|
-
setShow?.(!showRender);
|
88
|
-
}}
|
89
|
-
>
|
90
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
91
|
-
{loading ? (
|
92
|
-
<div>
|
93
|
-
<Loading3QuartersOutlined spin />
|
94
|
-
</div>
|
95
|
-
) : (
|
96
|
-
<PluginAvatar identifier={identifier} size={isMobile ? 36 : undefined} />
|
97
|
-
)}
|
98
|
-
{isMobile ? (
|
99
|
-
<Flexbox>
|
100
|
-
<div>{pluginTitle}</div>
|
101
|
-
<Typography.Text className={styles.apiName} type={'secondary'}>
|
102
|
-
{payload?.apiName}
|
103
|
-
</Typography.Text>
|
104
|
-
</Flexbox>
|
105
|
-
) : (
|
106
|
-
<>
|
107
|
-
<div>{pluginTitle}</div>
|
108
|
-
<Tag>{payload?.apiName}</Tag>
|
109
|
-
</>
|
110
|
-
)}
|
111
|
-
</Flexbox>
|
112
|
-
{showRightAction && <Icon icon={showRender ? LucideChevronDown : LucideChevronRight} />}
|
113
|
-
</Flexbox>
|
114
|
-
|
115
|
-
<Flexbox horizontal>
|
116
|
-
{!isMobile && showRightAction && showPortal && (
|
117
|
-
<ActionIcon
|
118
|
-
icon={BetweenVerticalStart}
|
119
|
-
onClick={() => {
|
120
|
-
if (!isMessageToolUIOpen) openToolUI(id, identifier);
|
121
|
-
else {
|
122
|
-
togglePortal(false);
|
123
|
-
}
|
124
|
-
}}
|
125
|
-
size={DESKTOP_HEADER_ICON_SIZE}
|
126
|
-
title={t('title', { ns: 'portal' })}
|
127
|
-
/>
|
128
|
-
)}
|
129
|
-
<ActionIcon
|
130
|
-
icon={open ? LucideBugOff : LucideBug}
|
131
|
-
onClick={() => {
|
132
|
-
setOpen(!open);
|
133
|
-
}}
|
134
|
-
title={t(open ? 'debug.off' : 'debug.on')}
|
135
|
-
/>
|
136
|
-
<Settings id={identifier} />
|
137
|
-
</Flexbox>
|
138
|
-
</Flexbox>
|
139
|
-
{open && (
|
140
|
-
<Tabs
|
141
|
-
items={[
|
142
|
-
{
|
143
|
-
children: <Highlighter language={'json'}>{args}</Highlighter>,
|
144
|
-
key: 'function_call',
|
145
|
-
label: t('debug.function_call'),
|
146
|
-
},
|
147
|
-
{
|
148
|
-
children: <Highlighter language={'json'}>{params}</Highlighter>,
|
149
|
-
key: 'arguments',
|
150
|
-
label: t('debug.arguments'),
|
151
|
-
},
|
152
|
-
{
|
153
|
-
children: <PluginResult content={content} />,
|
154
|
-
key: 'response',
|
155
|
-
label: t('debug.response'),
|
156
|
-
},
|
157
|
-
]}
|
158
|
-
style={{ display: 'grid', maxWidth: 800, minWidth: 400 }}
|
159
|
-
/>
|
160
|
-
)}
|
161
|
-
</Flexbox>
|
162
|
-
);
|
163
|
-
},
|
164
|
-
);
|
165
|
-
|
166
|
-
export default Inspector;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { createStyles } from 'antd-style';
|
2
|
-
|
3
|
-
export const useStyles = createStyles(({ css, token }) => ({
|
4
|
-
apiName: css`
|
5
|
-
overflow: hidden;
|
6
|
-
display: -webkit-box;
|
7
|
-
-webkit-box-orient: vertical;
|
8
|
-
-webkit-line-clamp: 1;
|
9
|
-
|
10
|
-
font-size: 12px;
|
11
|
-
text-overflow: ellipsis;
|
12
|
-
`,
|
13
|
-
container: css`
|
14
|
-
cursor: pointer;
|
15
|
-
|
16
|
-
width: fit-content;
|
17
|
-
padding-block: 6px;
|
18
|
-
padding-inline: 8px;
|
19
|
-
padding-inline-end: 12px;
|
20
|
-
border: 1px solid ${token.colorBorder};
|
21
|
-
border-radius: 8px;
|
22
|
-
|
23
|
-
color: ${token.colorText};
|
24
|
-
|
25
|
-
&:hover {
|
26
|
-
background: ${token.colorFillTertiary};
|
27
|
-
}
|
28
|
-
`,
|
29
|
-
plugin: css`
|
30
|
-
display: flex;
|
31
|
-
gap: 4px;
|
32
|
-
align-items: center;
|
33
|
-
width: fit-content;
|
34
|
-
`,
|
35
|
-
}));
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import { Icon, Tag } from '@lobehub/ui';
|
2
|
-
import { Typography } from 'antd';
|
3
|
-
import isEqual from 'fast-deep-equal';
|
4
|
-
import { Loader2 } from 'lucide-react';
|
5
|
-
import { CSSProperties, memo, useState } from 'react';
|
6
|
-
import { useTranslation } from 'react-i18next';
|
7
|
-
import { Flexbox } from 'react-layout-kit';
|
8
|
-
|
9
|
-
import PluginAvatar from '@/features/PluginAvatar';
|
10
|
-
import { useIsMobile } from '@/hooks/useIsMobile';
|
11
|
-
import { useChatStore } from '@/store/chat';
|
12
|
-
import { chatSelectors } from '@/store/chat/selectors';
|
13
|
-
import { pluginHelpers, useToolStore } from '@/store/tool';
|
14
|
-
import { toolSelectors } from '@/store/tool/selectors';
|
15
|
-
|
16
|
-
import Arguments from '../../components/Arguments';
|
17
|
-
import ToolMessage from './Tool';
|
18
|
-
import { useStyles } from './style';
|
19
|
-
|
20
|
-
export interface InspectorProps {
|
21
|
-
apiName: string;
|
22
|
-
arguments?: string;
|
23
|
-
id: string;
|
24
|
-
identifier: string;
|
25
|
-
index: number;
|
26
|
-
messageId: string;
|
27
|
-
showPortal?: boolean;
|
28
|
-
style?: CSSProperties;
|
29
|
-
}
|
30
|
-
|
31
|
-
const CallItem = memo<InspectorProps>(
|
32
|
-
({ arguments: requestArgs, apiName, messageId, id, index, identifier, style, showPortal }) => {
|
33
|
-
const { t } = useTranslation('plugin');
|
34
|
-
const { styles } = useStyles();
|
35
|
-
|
36
|
-
const [open, setOpen] = useState(false);
|
37
|
-
const loading = useChatStore(chatSelectors.isToolCallStreaming(messageId, index));
|
38
|
-
const toolMessage = useChatStore(chatSelectors.getMessageByToolCallId(id));
|
39
|
-
const isMobile = useIsMobile();
|
40
|
-
|
41
|
-
const pluginMeta = useToolStore(toolSelectors.getMetaById(identifier), isEqual);
|
42
|
-
|
43
|
-
const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
|
44
|
-
|
45
|
-
// when tool calling stop streaming, we should show the tool message
|
46
|
-
return !loading && toolMessage ? (
|
47
|
-
<ToolMessage {...toolMessage} showPortal={showPortal} />
|
48
|
-
) : (
|
49
|
-
<Flexbox gap={8} style={style}>
|
50
|
-
<Flexbox
|
51
|
-
align={'center'}
|
52
|
-
className={styles.container}
|
53
|
-
distribution={'space-between'}
|
54
|
-
gap={8}
|
55
|
-
horizontal
|
56
|
-
onClick={() => {
|
57
|
-
setOpen(!open);
|
58
|
-
}}
|
59
|
-
>
|
60
|
-
<Flexbox align={'center'} gap={8} horizontal>
|
61
|
-
{loading ? (
|
62
|
-
<div>
|
63
|
-
<Icon icon={Loader2} spin />
|
64
|
-
</div>
|
65
|
-
) : (
|
66
|
-
<PluginAvatar identifier={identifier} size={isMobile ? 36 : undefined} />
|
67
|
-
)}
|
68
|
-
{isMobile ? (
|
69
|
-
<Flexbox>
|
70
|
-
<div>{pluginTitle}</div>
|
71
|
-
<Typography.Text className={styles.apiName} type={'secondary'}>
|
72
|
-
{apiName}
|
73
|
-
</Typography.Text>
|
74
|
-
</Flexbox>
|
75
|
-
) : (
|
76
|
-
<>
|
77
|
-
<div>{pluginTitle}</div>
|
78
|
-
<Tag>{apiName}</Tag>
|
79
|
-
</>
|
80
|
-
)}
|
81
|
-
</Flexbox>
|
82
|
-
</Flexbox>
|
83
|
-
{loading && <Arguments arguments={requestArgs} />}
|
84
|
-
</Flexbox>
|
85
|
-
);
|
86
|
-
},
|
87
|
-
);
|
88
|
-
|
89
|
-
export default CallItem;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { createStyles } from 'antd-style';
|
2
|
-
|
3
|
-
export const useStyles = createStyles(({ css, token }) => ({
|
4
|
-
apiName: css`
|
5
|
-
overflow: hidden;
|
6
|
-
display: -webkit-box;
|
7
|
-
-webkit-box-orient: vertical;
|
8
|
-
-webkit-line-clamp: 1;
|
9
|
-
|
10
|
-
font-size: 12px;
|
11
|
-
text-overflow: ellipsis;
|
12
|
-
`,
|
13
|
-
container: css`
|
14
|
-
cursor: pointer;
|
15
|
-
|
16
|
-
width: fit-content;
|
17
|
-
padding-block: 6px;
|
18
|
-
padding-inline: 8px;
|
19
|
-
padding-inline-end: 12px;
|
20
|
-
border: 1px solid ${token.colorBorder};
|
21
|
-
border-radius: 8px;
|
22
|
-
|
23
|
-
color: ${token.colorText};
|
24
|
-
|
25
|
-
&:hover {
|
26
|
-
background: ${token.colorFillTertiary};
|
27
|
-
}
|
28
|
-
`,
|
29
|
-
plugin: css`
|
30
|
-
display: flex;
|
31
|
-
gap: 4px;
|
32
|
-
align-items: center;
|
33
|
-
width: fit-content;
|
34
|
-
`,
|
35
|
-
}));
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { Highlighter } from '@lobehub/ui';
|
2
|
-
import { memo } from 'react';
|
3
|
-
|
4
|
-
import { useYamlArguments } from '@/hooks/useYamlArguments';
|
5
|
-
|
6
|
-
export interface ArgumentsProps {
|
7
|
-
arguments?: string;
|
8
|
-
}
|
9
|
-
|
10
|
-
const Arguments = memo<ArgumentsProps>(({ arguments: args = '' }) => {
|
11
|
-
const yaml = useYamlArguments(args);
|
12
|
-
|
13
|
-
return (
|
14
|
-
!!yaml && (
|
15
|
-
<Highlighter language={'yaml'} showLanguage={false}>
|
16
|
-
{yaml}
|
17
|
-
</Highlighter>
|
18
|
-
)
|
19
|
-
);
|
20
|
-
});
|
21
|
-
|
22
|
-
export default Arguments;
|
File without changes
|
/package/src/features/Conversation/Messages/Assistant/{ToolCallItem → Tool}/Inspector/Settings.tsx
RENAMED
File without changes
|