@lobehub/chat 0.61.0 → 0.62.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 CHANGED
@@ -2,6 +2,73 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.62.1](https://github.com/lobehub/lobe-chat/compare/v0.62.0...v0.62.1)
6
+
7
+ <sup>Released on **2023-08-26**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix plugin settings error.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix plugin settings error, closes [#117](https://github.com/lobehub/lobe-chat/issues/117) ([064d90e](https://github.com/lobehub/lobe-chat/commit/064d90e))
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
+
30
+ ## [Version 0.62.0](https://github.com/lobehub/lobe-chat/compare/v0.61.0...v0.62.0)
31
+
32
+ <sup>Released on **2023-08-26**</sup>
33
+
34
+ #### ✨ Features
35
+
36
+ - **misc**: 支持超过 4k 的会话使用 16k 总结标题.
37
+
38
+ #### 🐛 Bug Fixes
39
+
40
+ - **misc**: Fix plugin settings error.
41
+
42
+ #### 💄 Styles
43
+
44
+ - **misc**: 优化清理会话的操作路径, 优化默认角色的配置.
45
+
46
+ <br/>
47
+
48
+ <details>
49
+ <summary><kbd>Improvements and Fixes</kbd></summary>
50
+
51
+ #### What's improved
52
+
53
+ - **misc**: 支持超过 4k 的会话使用 16k 总结标题 ([5764cfb](https://github.com/lobehub/lobe-chat/commit/5764cfb))
54
+
55
+ #### What's fixed
56
+
57
+ - **misc**: Fix plugin settings error ([008c2e3](https://github.com/lobehub/lobe-chat/commit/008c2e3))
58
+
59
+ #### Styles
60
+
61
+ - **misc**: 优化清理会话的操作路径 ([6b7218e](https://github.com/lobehub/lobe-chat/commit/6b7218e))
62
+ - **misc**: 优化默认角色的配置 ([a07d7a8](https://github.com/lobehub/lobe-chat/commit/a07d7a8))
63
+
64
+ </details>
65
+
66
+ <div align="right">
67
+
68
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
69
+
70
+ </div>
71
+
5
72
  ## [Version 0.61.0](https://github.com/lobehub/lobe-chat/compare/v0.60.4...v0.61.0)
6
73
 
7
74
  <sup>Released on **2023-08-26**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.61.0",
3
+ "version": "0.62.1",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -63,10 +63,9 @@
63
63
  "dependencies": {
64
64
  "@ant-design/colors": "^7",
65
65
  "@ant-design/icons": "^5",
66
- "@cfworker/json-schema": "^1.12.7",
67
66
  "@emoji-mart/data": "^1",
68
67
  "@emoji-mart/react": "^1",
69
- "@icons-pack/react-simple-icons": "^8",
68
+ "@icons-pack/react-simple-icons": "^9",
70
69
  "@lobehub/chat-plugin-sdk": "latest",
71
70
  "@lobehub/chat-plugins-gateway": "latest",
72
71
  "@lobehub/ui": "latest",
@@ -22,6 +22,7 @@ export const DEFAULT_BASE_SETTINGS: GlobalBaseSettings = {
22
22
 
23
23
  export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
24
24
  displayMode: 'chat',
25
+ historyCount: 1,
25
26
  model: LanguageModel.GPT3_5,
26
27
  params: {
27
28
  frequency_penalty: 0,
@@ -113,7 +113,7 @@ const AgentPlugin = memo<AgentPluginProps>(({ config, updateConfig }) => {
113
113
  if (!item) return null;
114
114
  const manifest = pluginManifestMap[identifier];
115
115
 
116
- if (!manifest.settings) return null;
116
+ if (!manifest?.settings) return null;
117
117
 
118
118
  return {
119
119
  children: transformPluginSettings(manifest.settings).map((item) => ({
@@ -16,6 +16,7 @@ const ActionsRight = memo(() => {
16
16
  okButtonProps={{ danger: true }}
17
17
  okText={t('ok', { ns: 'common' })}
18
18
  onConfirm={() => clearMessage()}
19
+ placement={'topRight'}
19
20
  title={t('confirmClearCurrentMessages', { ns: 'common' })}
20
21
  >
21
22
  <ActionIcon
@@ -1,9 +1,9 @@
1
+ import { chatHelpers } from '@/store/session/helpers';
2
+ import { LanguageModel } from '@/types/llm';
1
3
  import { OpenAIChatMessage, OpenAIStreamPayload } from '@/types/openai';
2
4
 
3
- export const promptSummaryTitle = (
4
- messages: OpenAIChatMessage[],
5
- ): Partial<OpenAIStreamPayload> => ({
6
- messages: [
5
+ export const promptSummaryTitle = (messages: OpenAIChatMessage[]): Partial<OpenAIStreamPayload> => {
6
+ const finalMessages: OpenAIChatMessage[] = [
7
7
  {
8
8
  content:
9
9
  '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,不需要包含标点符号',
@@ -15,5 +15,16 @@ export const promptSummaryTitle = (
15
15
  请总结上述对话为10个字以内的标题,不需要包含标点符号`,
16
16
  role: 'user',
17
17
  },
18
- ],
19
- });
18
+ ];
19
+ // 如果超过 4k,则使用 GPT3.5 16K 模型
20
+ const tokens = chatHelpers.getMessagesTokenCount(finalMessages);
21
+ let model: LanguageModel | undefined = undefined;
22
+ if (tokens > 4000) {
23
+ model = LanguageModel.GPT3_5_16K;
24
+ }
25
+
26
+ return {
27
+ messages: finalMessages,
28
+ model,
29
+ };
30
+ };
@@ -0,0 +1 @@
1
+ export * from './slices/chat/helpers';
@@ -0,0 +1,10 @@
1
+ import { encode } from 'gpt-tokenizer';
2
+
3
+ import { OpenAIChatMessage } from '@/types/openai';
4
+
5
+ export const getMessagesTokenCount = (messages: OpenAIChatMessage[]) =>
6
+ encode(messages.map((m) => m.content).join('')).length;
7
+
8
+ export const chatHelpers = {
9
+ getMessagesTokenCount,
10
+ };