@lobehub/chat 0.17.0 → 0.18.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,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.18.0](https://github.com/lobehub/lobe-chat/compare/v0.17.0...v0.18.0)
6
+
7
+ <sup>Released on **2023-07-24**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: 实现会话展示模式切换,并优化默认创建角色的配置.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: 实现会话展示模式切换,并优化默认创建角色的配置 ([27ae82f](https://github.com/lobehub/lobe-chat/commit/27ae82f))
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.17.0](https://github.com/lobehub/lobe-chat/compare/v0.16.1...v0.17.0)
6
31
 
7
32
  <sup>Released on **2023-07-24**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -63,7 +63,7 @@
63
63
  "@commitlint/cli": "^17",
64
64
  "@emoji-mart/data": "^1",
65
65
  "@emoji-mart/react": "^1",
66
- "@lobehub/ui": "^1",
66
+ "@lobehub/ui": "latest",
67
67
  "@vercel/analytics": "^1",
68
68
  "ahooks": "^3",
69
69
  "ai": "^2",
@@ -48,7 +48,7 @@ export default {
48
48
  chatStyleType: {
49
49
  title: '聊天窗口样式',
50
50
  type: {
51
- bubble: '气泡模式',
51
+ chat: '对话模式',
52
52
  docs: '文档模式',
53
53
  },
54
54
  },
@@ -3,7 +3,7 @@ import isEqual from 'fast-deep-equal';
3
3
  import { ReactNode, memo } from 'react';
4
4
  import { shallow } from 'zustand/shallow';
5
5
 
6
- import { chatSelectors, useSessionStore } from '@/store/session';
6
+ import { agentSelectors, chatSelectors, useSessionStore } from '@/store/session';
7
7
  import { isFunctionMessage } from '@/utils/message';
8
8
 
9
9
  import FunctionMessage from './FunctionMessage';
@@ -11,8 +11,13 @@ import MessageExtra from './MessageExtra';
11
11
 
12
12
  const List = () => {
13
13
  const data = useSessionStore(chatSelectors.currentChats, isEqual);
14
- const [deleteMessage, resendMessage, dispatchMessage] = useSessionStore(
15
- (s) => [s.deleteMessage, s.resendMessage, s.dispatchMessage],
14
+ const [displayMode, deleteMessage, resendMessage, dispatchMessage] = useSessionStore(
15
+ (s) => [
16
+ agentSelectors.currentAgentConfigSafe(s).displayMode,
17
+ s.deleteMessage,
18
+ s.resendMessage,
19
+ s.dispatchMessage,
20
+ ],
16
21
  shallow,
17
22
  );
18
23
 
@@ -45,6 +50,7 @@ const List = () => {
45
50
  renderMessage={renderMessage}
46
51
  renderMessageExtra={MessageExtra}
47
52
  style={{ marginTop: 24 }}
53
+ type={displayMode}
48
54
  />
49
55
  );
50
56
  };
@@ -1,5 +1,6 @@
1
1
  import { Form, ItemGroup } from '@lobehub/ui';
2
- import { Input, Segmented, Select, Switch } from 'antd';
2
+ import { ConfigProvider, Input, Segmented, Select, Switch } from 'antd';
3
+ import { useTheme } from 'antd-style';
3
4
  import isEqual from 'fast-deep-equal';
4
5
  import { debounce } from 'lodash-es';
5
6
  import { BrainCog, MessagesSquare } from 'lucide-react';
@@ -21,6 +22,7 @@ type SettingItemGroup = ItemGroup & {
21
22
 
22
23
  const AgentConfig = () => {
23
24
  const { t } = useTranslation('setting');
25
+ const theme = useTheme();
24
26
 
25
27
  const config = useSessionStore(agentSelectors.currentAgentConfigSafe, isEqual);
26
28
 
@@ -33,7 +35,7 @@ const AgentConfig = () => {
33
35
  children: (
34
36
  <Segmented
35
37
  options={[
36
- { label: t('settingChat.chatStyleType.type.bubble'), value: 'chat' },
38
+ { label: t('settingChat.chatStyleType.type.chat'), value: 'chat' },
37
39
  { label: t('settingChat.chatStyleType.type.docs'), value: 'docs' },
38
40
  ]}
39
41
  />
@@ -151,12 +153,22 @@ const AgentConfig = () => {
151
153
  );
152
154
 
153
155
  return (
154
- <Form
155
- initialValues={config}
156
- items={[chat, model]}
157
- onValuesChange={debounce(updateAgentConfig, 100)}
158
- {...FORM_STYLE}
159
- />
156
+ <ConfigProvider
157
+ theme={{
158
+ components: {
159
+ Segmented: {
160
+ colorBgLayout: theme.isDarkMode ? '#111' : '#f1f1f1',
161
+ },
162
+ },
163
+ }}
164
+ >
165
+ <Form
166
+ initialValues={config}
167
+ items={[chat, model]}
168
+ onValuesChange={debounce(updateAgentConfig, 100)}
169
+ {...FORM_STYLE}
170
+ />
171
+ </ConfigProvider>
160
172
  );
161
173
  };
162
174
 
@@ -1,5 +1,6 @@
1
1
  import { merge } from 'lodash-es';
2
2
 
3
+ import { initialLobeAgentConfig } from '@/store/session';
3
4
  import type { OpenAIStreamPayload } from '@/types/openai';
4
5
 
5
6
  import { URLS } from './url';
@@ -13,12 +14,9 @@ export const fetchChatModel = (
13
14
  ) => {
14
15
  const payload = merge(
15
16
  {
16
- frequency_penalty: 0,
17
- model: 'gpt-3.5-turbo',
18
- presence_penalty: 0,
17
+ model: initialLobeAgentConfig.model,
19
18
  stream: true,
20
- temperature: 0.6,
21
- top_p: 1,
19
+ ...initialLobeAgentConfig.params,
22
20
  },
23
21
  params,
24
22
  );
@@ -32,4 +32,5 @@ export const useSessionStore = create<SessionStore>()(
32
32
  );
33
33
 
34
34
  export * from './selectors';
35
+ export { initialLobeAgentConfig } from './slices/agentConfig';
35
36
  export type { SessionStore } from './store';
@@ -11,8 +11,15 @@ export interface AgentConfigState {
11
11
  }
12
12
 
13
13
  export const initialLobeAgentConfig: LobeAgentConfig = {
14
+ displayMode: 'chat',
14
15
  model: LanguageModel.GPT3_5,
15
- params: { temperature: 0.6 },
16
+ params: {
17
+ frequency_penalty: 0,
18
+ presence_penalty: 0,
19
+ temperature: 0.6,
20
+ top_p: 1,
21
+ },
22
+ plugins: [],
16
23
  systemRole: '',
17
24
  };
18
25
 
package/src/types/llm.ts CHANGED
@@ -18,6 +18,7 @@ export enum LanguageModel {
18
18
  export interface LLMParams {
19
19
  /**
20
20
  * 控制生成文本中的惩罚系数,用于减少重复性
21
+ * @default 0
21
22
  */
22
23
  frequency_penalty?: number;
23
24
  /**
@@ -26,6 +27,7 @@ export interface LLMParams {
26
27
  max_tokens?: number;
27
28
  /**
28
29
  * 控制生成文本中的惩罚系数,用于减少主题的变化
30
+ * @default 0
29
31
  */
30
32
  presence_penalty?: number;
31
33
  /**
@@ -35,6 +37,7 @@ export interface LLMParams {
35
37
  temperature?: number;
36
38
  /**
37
39
  * 控制生成文本中最高概率的单个 token
40
+ * @default 1
38
41
  */
39
42
  top_p?: number;
40
43
  }