@lobehub/chat 0.68.0 → 0.68.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/CHANGELOG.md +26 -0
- package/package.json +2 -2
- package/src/features/AgentSetting/AgentPlugin/LocalPluginItem.tsx +4 -3
- package/src/features/AgentSetting/AgentPlugin/MarketList.tsx +67 -22
- package/src/features/AgentSetting/store/reducers/config.ts +2 -2
- package/src/features/AgentSetting/store/reducers/meta.ts +2 -2
- package/src/locales/default/plugin.ts +1 -0
- package/src/locales/default/setting.ts +1 -1
- package/src/store/session/slices/agentConfig/selectors.ts +2 -2
- package/src/utils/merge.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.68.1](https://github.com/lobehub/lobe-chat/compare/v0.68.0...v0.68.1)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-09-03**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: 修正数组合并逻辑, 修正被移除插件无法看到的问题.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: 修正数组合并逻辑 ([e36e621](https://github.com/lobehub/lobe-chat/commit/e36e621))
|
|
21
|
+
- **misc**: 修正被移除插件无法看到的问题 ([c17eb56](https://github.com/lobehub/lobe-chat/commit/c17eb56))
|
|
22
|
+
|
|
23
|
+
</details>
|
|
24
|
+
|
|
25
|
+
<div align="right">
|
|
26
|
+
|
|
27
|
+
[](#readme-top)
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
|
|
5
31
|
## [Version 0.68.0](https://github.com/lobehub/lobe-chat/compare/v0.67.0...v0.68.0)
|
|
6
32
|
|
|
7
33
|
<sup>Released on **2023-09-03**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.1",
|
|
4
4
|
"description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@emoji-mart/data": "^1",
|
|
67
67
|
"@emoji-mart/react": "^1",
|
|
68
68
|
"@icons-pack/react-simple-icons": "^9",
|
|
69
|
-
"@lobehub/chat-plugin-sdk": "^1.15.
|
|
69
|
+
"@lobehub/chat-plugin-sdk": "^1.15.1",
|
|
70
70
|
"@lobehub/chat-plugins-gateway": "^1.5.0",
|
|
71
71
|
"@lobehub/ui": "latest",
|
|
72
72
|
"@vercel/analytics": "^1",
|
|
@@ -14,8 +14,8 @@ const MarketList = memo<{ id: string }>(({ id }) => {
|
|
|
14
14
|
|
|
15
15
|
const [showModal, setModal] = useState(false);
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
17
|
+
const [toggleAgentPlugin, hasPlugin] = useStore((s) => [s.toggleAgentPlugin, !!s.config.plugins]);
|
|
18
|
+
const plugins = useStore((s) => s.config.plugins || []);
|
|
19
19
|
|
|
20
20
|
const [useFetchPluginList, fetchPluginManifest, deleteCustomPlugin, updateCustomPlugin] =
|
|
21
21
|
usePluginStore((s) => [
|
|
@@ -36,6 +36,7 @@ const MarketList = memo<{ id: string }>(({ id }) => {
|
|
|
36
36
|
mode={'edit'}
|
|
37
37
|
onDelete={() => {
|
|
38
38
|
deleteCustomPlugin(id);
|
|
39
|
+
toggleAgentPlugin(id);
|
|
39
40
|
}}
|
|
40
41
|
onOpenChange={setModal}
|
|
41
42
|
onSave={(value) => {
|
|
@@ -53,7 +54,7 @@ const MarketList = memo<{ id: string }>(({ id }) => {
|
|
|
53
54
|
}
|
|
54
55
|
loading={pluginManifestLoading[id]}
|
|
55
56
|
onChange={(checked) => {
|
|
56
|
-
|
|
57
|
+
toggleAgentPlugin(id);
|
|
57
58
|
if (checked) {
|
|
58
59
|
fetchPluginManifest(id);
|
|
59
60
|
}
|
|
@@ -2,14 +2,14 @@ import { Avatar, Form, Icon, Tooltip } from '@lobehub/ui';
|
|
|
2
2
|
import { Button, Skeleton, Switch, Tag } from 'antd';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import isEqual from 'fast-deep-equal';
|
|
5
|
-
import { LucideBlocks, LucideStore } from 'lucide-react';
|
|
5
|
+
import { LucideBlocks, LucideStore, LucideTrash2 } from 'lucide-react';
|
|
6
6
|
import { memo, useState } from 'react';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
import DevModal from 'src/features/PluginDevModal';
|
|
10
10
|
|
|
11
11
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
12
|
-
import { pluginHelpers, usePluginStore } from '@/store/plugin';
|
|
12
|
+
import { pluginHelpers, pluginSelectors, usePluginStore } from '@/store/plugin';
|
|
13
13
|
|
|
14
14
|
import { useStore } from '../store';
|
|
15
15
|
import LocalPluginItem from './LocalPluginItem';
|
|
@@ -37,11 +37,7 @@ const MarketList = memo(() => {
|
|
|
37
37
|
|
|
38
38
|
const [showModal, setModal] = useState(false);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
// setModal(true);
|
|
42
|
-
// }, []);
|
|
43
|
-
|
|
44
|
-
const [plugins, hasPlugin, toggleAgentPlugin] = useStore((s) => [
|
|
40
|
+
const [userEnabledPlugins, hasPlugin, toggleAgentPlugin] = useStore((s) => [
|
|
45
41
|
s.config.plugins || [],
|
|
46
42
|
!!s.config.plugins,
|
|
47
43
|
s.toggleAgentPlugin,
|
|
@@ -57,6 +53,7 @@ const MarketList = memo(() => {
|
|
|
57
53
|
const pluginManifestLoading = usePluginStore((s) => s.pluginManifestLoading, isEqual);
|
|
58
54
|
const pluginList = usePluginStore((s) => s.pluginList, isEqual);
|
|
59
55
|
const customPluginList = usePluginStore((s) => s.customPluginList, isEqual);
|
|
56
|
+
const totalList = usePluginStore(pluginSelectors.pluginList, isEqual);
|
|
60
57
|
|
|
61
58
|
useFetchPluginList();
|
|
62
59
|
|
|
@@ -100,7 +97,9 @@ const MarketList = memo(() => {
|
|
|
100
97
|
<Switch
|
|
101
98
|
checked={
|
|
102
99
|
// 如果在加载中,说明激活了
|
|
103
|
-
pluginManifestLoading[identifier] || !hasPlugin
|
|
100
|
+
pluginManifestLoading[identifier] || !hasPlugin
|
|
101
|
+
? false
|
|
102
|
+
: userEnabledPlugins.includes(identifier)
|
|
104
103
|
}
|
|
105
104
|
loading={pluginManifestLoading[identifier]}
|
|
106
105
|
onChange={(checked) => {
|
|
@@ -132,6 +131,35 @@ const MarketList = memo(() => {
|
|
|
132
131
|
tag: identifier,
|
|
133
132
|
}));
|
|
134
133
|
|
|
134
|
+
// =========== Deprecated Plugin List =========== //
|
|
135
|
+
|
|
136
|
+
// 基于 userEnabledPlugins 和完整的 totalList,检查出不在 totalList 中的插件
|
|
137
|
+
const deprecatedList = userEnabledPlugins
|
|
138
|
+
.filter((pluginId) => totalList.findIndex((p) => p.identifier === pluginId) < 0)
|
|
139
|
+
.map((id) => ({
|
|
140
|
+
avatar: <Avatar avatar={'♻️'} />,
|
|
141
|
+
children: (
|
|
142
|
+
<Switch
|
|
143
|
+
checked={true}
|
|
144
|
+
onChange={(checked) => {
|
|
145
|
+
togglePlugin(id, checked);
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
),
|
|
149
|
+
label: (
|
|
150
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
|
151
|
+
{id}
|
|
152
|
+
<Tag bordered={false} color={'red'}>
|
|
153
|
+
{t('list.item.deprecated.title', { ns: 'plugin' })}
|
|
154
|
+
</Tag>
|
|
155
|
+
</Flexbox>
|
|
156
|
+
),
|
|
157
|
+
minWidth: undefined,
|
|
158
|
+
tag: id,
|
|
159
|
+
}));
|
|
160
|
+
|
|
161
|
+
const hasDeprecated = deprecatedList.length > 0;
|
|
162
|
+
|
|
135
163
|
return (
|
|
136
164
|
<>
|
|
137
165
|
<DevModal
|
|
@@ -148,27 +176,44 @@ const MarketList = memo(() => {
|
|
|
148
176
|
<Form
|
|
149
177
|
items={[
|
|
150
178
|
{
|
|
151
|
-
children: isEmpty ? loadingList : [...customList, ...list],
|
|
179
|
+
children: isEmpty ? loadingList : [...deprecatedList, ...customList, ...list],
|
|
152
180
|
extra: (
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
181
|
+
<Flexbox gap={8} horizontal>
|
|
182
|
+
{hasDeprecated ? (
|
|
183
|
+
<Tooltip title={t('settingPlugin.clearDeprecated')}>
|
|
184
|
+
<Button
|
|
185
|
+
icon={<Icon icon={LucideTrash2} />}
|
|
186
|
+
onClick={(e) => {
|
|
187
|
+
e.stopPropagation();
|
|
188
|
+
for (const i of deprecatedList) {
|
|
189
|
+
togglePlugin(i.tag as string, false);
|
|
190
|
+
}
|
|
191
|
+
}}
|
|
192
|
+
size={'small'}
|
|
193
|
+
type={'text'}
|
|
194
|
+
></Button>
|
|
195
|
+
</Tooltip>
|
|
196
|
+
) : null}
|
|
197
|
+
<Tooltip title={t('settingPlugin.addTooltip')}>
|
|
198
|
+
<Button
|
|
199
|
+
icon={<Icon icon={LucideBlocks} />}
|
|
200
|
+
onClick={(e) => {
|
|
201
|
+
e.stopPropagation();
|
|
202
|
+
setModal(true);
|
|
203
|
+
}}
|
|
204
|
+
size={'small'}
|
|
205
|
+
>
|
|
206
|
+
{t('settingPlugin.add')}
|
|
207
|
+
</Button>
|
|
208
|
+
</Tooltip>
|
|
209
|
+
</Flexbox>
|
|
165
210
|
),
|
|
166
211
|
icon: LucideStore,
|
|
167
212
|
title: t('settingPlugin.title'),
|
|
168
213
|
},
|
|
169
214
|
]}
|
|
170
215
|
{...FORM_STYLE}
|
|
171
|
-
/>
|
|
216
|
+
/>
|
|
172
217
|
</>
|
|
173
218
|
);
|
|
174
219
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
|
-
import { merge } from 'lodash-es';
|
|
3
2
|
|
|
4
3
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
|
5
4
|
import { LobeAgentConfig } from '@/types/session';
|
|
5
|
+
import { merge } from '@/utils/merge';
|
|
6
6
|
|
|
7
7
|
export type ConfigDispatch =
|
|
8
8
|
| { config: Partial<any>; type: 'update' }
|
|
@@ -13,7 +13,7 @@ export const configReducer = (state: LobeAgentConfig, payload: ConfigDispatch):
|
|
|
13
13
|
switch (payload.type) {
|
|
14
14
|
case 'update': {
|
|
15
15
|
return produce(state, (draftState) => {
|
|
16
|
-
return merge(
|
|
16
|
+
return merge(draftState, payload.config);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
|
-
import { merge } from 'lodash-es';
|
|
3
2
|
|
|
4
3
|
import { DEFAULT_AGENT_META } from '@/const/meta';
|
|
5
4
|
import { MetaData } from '@/types/meta';
|
|
5
|
+
import { merge } from '@/utils/merge';
|
|
6
6
|
|
|
7
7
|
export type MetaDataDispatch = { type: 'update'; value: Partial<MetaData> } | { type: 'reset' };
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ export const metaDataReducer = (state: MetaData, payload: MetaDataDispatch): Met
|
|
|
10
10
|
switch (payload.type) {
|
|
11
11
|
case 'update': {
|
|
12
12
|
return produce(state, (draftState) => {
|
|
13
|
-
return merge(
|
|
13
|
+
return merge(draftState, payload.value);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t } from 'i18next';
|
|
2
|
-
import { merge } from 'lodash-es';
|
|
3
2
|
|
|
4
3
|
import { DEFAULT_AVATAR, DEFAULT_BACKGROUND_COLOR } from '@/const/meta';
|
|
5
4
|
import { SessionStore } from '@/store/session';
|
|
6
5
|
import { LanguageModel } from '@/types/llm';
|
|
7
6
|
import { MetaData } from '@/types/meta';
|
|
7
|
+
import { merge } from '@/utils/merge';
|
|
8
8
|
|
|
9
9
|
import { sessionSelectors } from '../session/selectors';
|
|
10
10
|
import { initialLobeAgentConfig } from './initialState';
|
|
@@ -19,7 +19,7 @@ const currentAgentTitle = (s: SessionStore) => currentAgentMeta(s)?.title || t('
|
|
|
19
19
|
|
|
20
20
|
const currentAgentConfig = (s: SessionStore) => {
|
|
21
21
|
const session = sessionSelectors.currentSession(s);
|
|
22
|
-
return merge(
|
|
22
|
+
return merge(initialLobeAgentConfig, session?.config);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const currentAgentSystemRole = (s: SessionStore) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { merge as _merge, mergeWith } from 'lodash-es';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 用于合并对象,如果是数组则直接替换
|
|
5
|
+
* @param target
|
|
6
|
+
* @param source
|
|
7
|
+
*/
|
|
8
|
+
export const merge: typeof _merge = <T = object>(target: T, source: T) =>
|
|
9
|
+
mergeWith({}, target, source, (obj, src) => {
|
|
10
|
+
if (Array.isArray(obj)) return src;
|
|
11
|
+
});
|