@lobehub/chat 0.160.6 → 0.160.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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.160.7](https://github.com/lobehub/lobe-chat/compare/v0.160.6...v0.160.7)
6
+
7
+ <sup>Released on **2024-05-21**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix duplicate model panel key.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix duplicate model panel key, closes [#2591](https://github.com/lobehub/lobe-chat/issues/2591) ([c733fcf](https://github.com/lobehub/lobe-chat/commit/c733fcf))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.160.6](https://github.com/lobehub/lobe-chat/compare/v0.160.5...v0.160.6)
6
31
 
7
32
  <sup>Released on **2024-05-21**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.160.6",
3
+ "version": "0.160.7",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -38,11 +38,14 @@ const useStyles = createStyles(({ css, prefixCls }) => ({
38
38
  `,
39
39
  }));
40
40
 
41
+ const menuKey = (provider: string, model: string) => `${provider}-${model}`;
42
+
41
43
  const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
42
44
  const { t } = useTranslation('components');
43
45
  const { styles, theme } = useStyles();
44
- const [model, updateAgentConfig] = useAgentStore((s) => [
46
+ const [model, provider, updateAgentConfig] = useAgentStore((s) => [
45
47
  agentSelectors.currentAgentModel(s),
48
+ agentSelectors.currentAgentModelProvider(s),
46
49
  s.updateAgentConfig,
47
50
  ]);
48
51
 
@@ -52,7 +55,7 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
52
55
  const items = useMemo<ItemType[]>(() => {
53
56
  const getModelItems = (provider: ModelProviderCard) => {
54
57
  const items = provider.chatModels.map((model) => ({
55
- key: model.id,
58
+ key: menuKey(provider.id, model.id),
56
59
  label: <ModelItemRender {...model} />,
57
60
  onClick: () => {
58
61
  updateAgentConfig({ model: model.id, provider: provider.id });
@@ -91,7 +94,7 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
91
94
  return (
92
95
  <Dropdown
93
96
  menu={{
94
- activeKey: model,
97
+ activeKey: menuKey(provider, model),
95
98
  className: styles.menu,
96
99
  items,
97
100
  style: {
@@ -157,7 +157,7 @@ describe('agentSelectors', () => {
157
157
  expect(provider).toBe(mockSessionStore.agentConfig.provider);
158
158
  });
159
159
 
160
- it('should return undefined if provider is not defined in the agent config', () => {
160
+ it('should fallback to openai if provider is not defined in the agent config', () => {
161
161
  const modifiedStore = {
162
162
  ...mockSessionStore,
163
163
  agentConfig: {
@@ -166,7 +166,7 @@ describe('agentSelectors', () => {
166
166
  },
167
167
  };
168
168
  const provider = agentSelectors.currentAgentModelProvider(modifiedStore);
169
- expect(provider).toBeUndefined();
169
+ expect(provider).toEqual('openai');
170
170
  });
171
171
  });
172
172
 
@@ -28,7 +28,7 @@ const currentAgentModel = (s: AgentStore): string => {
28
28
  const currentAgentModelProvider = (s: AgentStore) => {
29
29
  const config = currentAgentConfig(s);
30
30
 
31
- return config?.provider;
31
+ return config?.provider || 'openai';
32
32
  };
33
33
 
34
34
  const currentAgentPlugins = (s: AgentStore) => {