@lobehub/chat 0.20.0 → 0.21.0

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,39 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.21.0](https://github.com/lobehub/lobe-chat/compare/v0.20.0...v0.21.0)
6
+
7
+ <sup>Released on **2023-07-25**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Move component folder.
12
+
13
+ #### ✨ Features
14
+
15
+ - **misc**: 支持快捷配置模型、温度.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### Code refactoring
23
+
24
+ - **misc**: Move component folder ([fb85d16](https://github.com/lobehub/lobe-chat/commit/fb85d16))
25
+
26
+ #### What's improved
27
+
28
+ - **misc**: 支持快捷配置模型、温度, closes [#19](https://github.com/lobehub/lobe-chat/issues/19) ([31daee1](https://github.com/lobehub/lobe-chat/commit/31daee1))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
5
38
  ## [Version 0.20.0](https://github.com/lobehub/lobe-chat/compare/v0.19.0...v0.20.0)
6
39
 
7
40
  <sup>Released on **2023-07-25**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -20,6 +20,7 @@ const SliderWithInput = memo<SliderSingleProps>(
20
20
  onChange={handleOnchange}
21
21
  step={step}
22
22
  style={{ flex: 1 }}
23
+ tooltip={{ open: false }}
23
24
  value={typeof value === 'number' ? value : 0}
24
25
  {...props}
25
26
  />
@@ -102,6 +102,7 @@ export default {
102
102
  temperature: {
103
103
  desc: '值越大,回复越随机',
104
104
  title: '随机性',
105
+ titleWithValue: '随机性 {{value}}',
105
106
  },
106
107
  title: '模型设置',
107
108
  topP: {
@@ -1,21 +1,80 @@
1
1
  import { ActionIcon } from '@lobehub/ui';
2
- import { Popconfirm } from 'antd';
3
- import { BrainCog, Eraser, Thermometer, Timer } from 'lucide-react';
2
+ import { Dropdown, Popconfirm, Popover } from 'antd';
3
+ import { BrainCog, Eraser, Thermometer } from 'lucide-react';
4
4
  import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { shallow } from 'zustand/shallow';
7
7
 
8
- import { useSessionStore } from '@/store/session';
8
+ import SliderWithInput from '@/components/SliderWithInput';
9
+ import { agentSelectors, useSessionStore } from '@/store/session';
10
+ import { LanguageModel } from '@/types/llm';
9
11
 
10
12
  const InputActions = memo(() => {
11
13
  const { t } = useTranslation('setting');
12
- const [clearMessage] = useSessionStore((s) => [s.clearMessage], shallow);
14
+ const [clearMessage, updateAgentConfig] = useSessionStore(
15
+ (s) => [s.clearMessage, s.updateAgentConfig],
16
+ shallow,
17
+ );
18
+ const [model, temperature] = useSessionStore((s) => {
19
+ const config = agentSelectors.currentAgentConfigSafe(s);
20
+ return [
21
+ config.model,
22
+ config.params.temperature,
23
+ // config.historyCount
24
+ ];
25
+ }, shallow);
13
26
 
14
27
  return (
15
28
  <>
16
- <ActionIcon icon={BrainCog} title={t('settingModel.model.title')} />
17
- <ActionIcon icon={Thermometer} title={t('settingModel.temperature.title')} />
18
- <ActionIcon icon={Timer} title={t('settingChat.historyCount.title')} />
29
+ <Dropdown
30
+ menu={{
31
+ activeKey: model,
32
+ items: Object.values(LanguageModel).map((i) => ({ key: i, label: i })),
33
+ onClick: (e) => {
34
+ updateAgentConfig({ model: e.key as LanguageModel });
35
+ },
36
+ }}
37
+ trigger={['click']}
38
+ >
39
+ <ActionIcon icon={BrainCog} title={t('settingModel.model.title')} />
40
+ </Dropdown>
41
+ <Popover
42
+ content={
43
+ <SliderWithInput
44
+ max={1}
45
+ min={0}
46
+ onChange={(v) => {
47
+ updateAgentConfig({ params: { temperature: v } });
48
+ }}
49
+ step={0.1}
50
+ style={{ width: 120 }}
51
+ value={temperature}
52
+ />
53
+ }
54
+ trigger={'click'}
55
+ >
56
+ <ActionIcon
57
+ icon={Thermometer}
58
+ title={t('settingModel.temperature.titleWithValue', { value: temperature })}
59
+ />
60
+ </Popover>
61
+ {/*TODO 历史记录功能实现 */}
62
+ {/*<Popover*/}
63
+ {/* content={*/}
64
+ {/* <SliderWithInput*/}
65
+ {/* min={0}*/}
66
+ {/* onChange={(v) => {*/}
67
+ {/* updateAgentConfig({ historyCount: v });*/}
68
+ {/* }}*/}
69
+ {/* step={1}*/}
70
+ {/* style={{ width: 120 }}*/}
71
+ {/* value={historyCount}*/}
72
+ {/* />*/}
73
+ {/* }*/}
74
+ {/* trigger={'click'}*/}
75
+ {/*>*/}
76
+ {/* <ActionIcon icon={Timer} title={t('settingChat.historyCount.title')} />*/}
77
+ {/*</Popover>*/}
19
78
  <Popconfirm
20
79
  cancelText={t('cancel', { ns: 'common' })}
21
80
  okButtonProps={{ danger: true }}
@@ -6,10 +6,10 @@ import { debounce } from 'lodash-es';
6
6
  import { BrainCog, MessagesSquare } from 'lucide-react';
7
7
  import { useMemo } from 'react';
8
8
  import { useTranslation } from 'react-i18next';
9
+ import SliderWithInput from 'src/components/SliderWithInput';
9
10
  import { shallow } from 'zustand/shallow';
10
11
 
11
12
  import { FORM_STYLE } from '@/const/layoutTokens';
12
- import SliderWithInput from '@/features/SliderWithInput';
13
13
  import { agentSelectors, useSessionStore } from '@/store/session';
14
14
  import { LanguageModel } from '@/types/llm';
15
15
  import type { LobeAgentConfig } from '@/types/session';
@@ -5,11 +5,11 @@ import { debounce } from 'lodash-es';
5
5
  import { AppWindow, BrainCog, MessagesSquare, Palette, Webhook } from 'lucide-react';
6
6
  import { memo, useCallback, useMemo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
+ import SliderWithInput from 'src/components/SliderWithInput';
8
9
  import { shallow } from 'zustand/shallow';
9
10
 
10
11
  import { FORM_STYLE } from '@/const/layoutTokens';
11
12
  import AvatarWithUpload from '@/features/AvatarWithUpload';
12
- import SliderWithInput from '@/features/SliderWithInput';
13
13
  import { options } from '@/locales/options';
14
14
  import { settingsSelectors, useSettings } from '@/store/settings';
15
15
  import { DEFAULT_SETTINGS } from '@/store/settings/initialState';