@lobehub/chat 0.61.0 → 0.62.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 +42 -0
- package/package.json +1 -2
- package/src/const/settings.ts +1 -0
- package/src/pages/chat/features/Conversation/ChatList/Error/Plugin/PluginSettings.tsx +1 -1
- package/src/pages/chat/features/Conversation/Input/ActionRight.tsx +1 -0
- package/src/prompts/chat.ts +17 -6
- package/src/store/session/helpers.ts +1 -0
- package/src/store/session/slices/chat/helpers.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.62.0](https://github.com/lobehub/lobe-chat/compare/v0.61.0...v0.62.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-08-26**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: 支持超过 4k 的会话使用 16k 总结标题.
|
|
12
|
+
|
|
13
|
+
#### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **misc**: Fix plugin settings error.
|
|
16
|
+
|
|
17
|
+
#### 💄 Styles
|
|
18
|
+
|
|
19
|
+
- **misc**: 优化清理会话的操作路径, 优化默认角色的配置.
|
|
20
|
+
|
|
21
|
+
<br/>
|
|
22
|
+
|
|
23
|
+
<details>
|
|
24
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
25
|
+
|
|
26
|
+
#### What's improved
|
|
27
|
+
|
|
28
|
+
- **misc**: 支持超过 4k 的会话使用 16k 总结标题 ([5764cfb](https://github.com/lobehub/lobe-chat/commit/5764cfb))
|
|
29
|
+
|
|
30
|
+
#### What's fixed
|
|
31
|
+
|
|
32
|
+
- **misc**: Fix plugin settings error ([008c2e3](https://github.com/lobehub/lobe-chat/commit/008c2e3))
|
|
33
|
+
|
|
34
|
+
#### Styles
|
|
35
|
+
|
|
36
|
+
- **misc**: 优化清理会话的操作路径 ([6b7218e](https://github.com/lobehub/lobe-chat/commit/6b7218e))
|
|
37
|
+
- **misc**: 优化默认角色的配置 ([a07d7a8](https://github.com/lobehub/lobe-chat/commit/a07d7a8))
|
|
38
|
+
|
|
39
|
+
</details>
|
|
40
|
+
|
|
41
|
+
<div align="right">
|
|
42
|
+
|
|
43
|
+
[](#readme-top)
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
5
47
|
## [Version 0.61.0](https://github.com/lobehub/lobe-chat/compare/v0.60.4...v0.61.0)
|
|
6
48
|
|
|
7
49
|
<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.
|
|
3
|
+
"version": "0.62.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,6 @@
|
|
|
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
68
|
"@icons-pack/react-simple-icons": "^8",
|
package/src/const/settings.ts
CHANGED
|
@@ -41,7 +41,7 @@ const PluginSettings = memo<PluginSettingsProps>(({ id, pluginIdentifier }) => {
|
|
|
41
41
|
</Flexbox>
|
|
42
42
|
<Flexbox className={styles.desc}>{t('pluginSettings.desc')}</Flexbox>
|
|
43
43
|
<Divider style={{ margin: '0 16px' }} />
|
|
44
|
-
{manifest
|
|
44
|
+
{manifest?.settings && (
|
|
45
45
|
<PluginSettingsConfig id={manifest.identifier} settings={manifest.settings} />
|
|
46
46
|
)}
|
|
47
47
|
<Button
|
package/src/prompts/chat.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
+
};
|