@lobehub/chat 0.111.3 → 0.111.5
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/.i18nrc.js +7 -5
- package/CHANGELOG.md +50 -0
- package/README.md +2 -2
- package/README.zh-CN.md +3 -3
- package/docs/Deployment/Analytics.md +20 -0
- package/docs/{Analytics.zh-CN.md → Deployment/Analytics.zh-CN.md} +5 -0
- package/docs/{Docker-Deployment.md → Deployment/Docker-Deployment.md} +7 -0
- package/docs/{Docker-Deployment.zh-CN.md → Deployment/Docker-Deployment.zh-CN.md} +7 -0
- package/docs/{Environment-Variable.md → Deployment/Environment-Variable.md} +1 -1
- package/docs/{Environment-Variable.zh-CN.md → Deployment/Environment-Variable.zh-CN.md} +1 -1
- package/docs/Development/Architecture.md +47 -0
- package/docs/{Development-Guide → Development}/Architecture.zh-CN.md +11 -1
- package/docs/Development/Chat-API.md +136 -0
- package/docs/{Development-Guide → Development}/Chat-API.zh-CN.md +10 -1
- package/docs/Development/Data-Store-Selectors.md +68 -0
- package/docs/{Development-Guide/Data-Store/Selectors.zh-CN.md → Development/Data-Store-Selectors.zh-CN.md} +1 -1
- package/docs/Development/Feature-Development.md +126 -0
- package/docs/{Development-Guide → Development}/Feature-Development.zh-CN.md +9 -1
- package/docs/Development/Folder-Structure.md +40 -0
- package/docs/Development/Resources.md +19 -0
- package/docs/Development/Steup-Development.md +69 -0
- package/docs/{Development-Guide → Development}/Steup-Development.zh-CN.md +8 -1
- package/docs/Development/Test.md +87 -0
- package/docs/{Development-Guide → Development}/Test.zh-CN.md +9 -1
- package/docs/Development/index.md +43 -0
- package/docs/{Development-Guide → Development}/index.zh-CN.md +6 -1
- package/docs/Home.md +32 -19
- package/docs/_Sidebar.md +29 -19
- package/locales/en_US/chat.json +1 -1
- package/package.json +8 -1
- package/scripts/docsWorkflow/const.ts +14 -0
- package/scripts/docsWorkflow/index.ts +73 -0
- package/scripts/docsWorkflow/toc.ts +60 -0
- package/scripts/docsWorkflow/utils.ts +38 -0
- package/src/chains/__tests__/summaryTitle.test.ts +2 -2
- package/src/chains/summaryTitle.ts +3 -4
- package/src/const/modelTokens.ts +3 -1
- package/src/store/global/selectors/__snapshots__/settings.test.ts.snap +16 -0
- package/src/types/llm.ts +2 -0
- /package/docs/{Deploy-with-Azure-OpenAI.md → Deployment/Deploy-with-Azure-OpenAI.md} +0 -0
- /package/docs/{Deploy-with-Azure-OpenAI.zh-CN.md → Deployment/Deploy-with-Azure-OpenAI.zh-CN.md} +0 -0
- /package/docs/{Upstream-Sync.md → Deployment/Upstream-Sync.md} +0 -0
- /package/docs/{Upstream-Sync.zh-CN.md → Deployment/Upstream-Sync.zh-CN.md} +0 -0
- /package/docs/{Development-Guide → Development}/Folder-Structure.zh-CN.md +0 -0
- /package/docs/{Development-Guide → Development}/Resources.zh-CN.md +0 -0
- /package/docs/{Lighthouse.md → Others/Lighthouse.md} +0 -0
- /package/docs/{Lighthouse.zh-CN.md → Others/Lighthouse.zh-CN.md} +0 -0
- /package/docs/{Plugin-Development.md → Plugins/Plugin-Development.md} +0 -0
- /package/docs/{Plugin-Development.zh-CN.md → Plugins/Plugin-Development.zh-CN.md} +0 -0
- /package/docs/{Usage-Agents.md → Usage/Usage-Agents.md} +0 -0
- /package/docs/{Usage-Agents.zh-CN.md → Usage/Usage-Agents.zh-CN.md} +0 -0
- /package/docs/{Usage-Topics.md → Usage/Usage-Topics.md} +0 -0
- /package/docs/{Usage-Topics.zh-CN.md → Usage/Usage-Topics.zh-CN.md} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
dir: 'Usage',
|
|
4
|
+
title: '🤯 LobeChat Usage',
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
dir: 'Deployment',
|
|
8
|
+
title: '🛳 Self Hosting',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
dir: 'Development',
|
|
12
|
+
title: '⌨️ Development',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
dir: 'Agents',
|
|
16
|
+
extra: [
|
|
17
|
+
{
|
|
18
|
+
links: {
|
|
19
|
+
cn: 'https://github.com/lobehub/lobe-chat-agents/blob/main/README.zh-CN.md',
|
|
20
|
+
en: 'https://github.com/lobehub/lobe-chat-agents',
|
|
21
|
+
},
|
|
22
|
+
titles: {
|
|
23
|
+
cn: '助手索引与提交',
|
|
24
|
+
en: 'Agent Index and Submit',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
title: '🤖 Agents',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
dir: 'Plugins',
|
|
32
|
+
extra: [
|
|
33
|
+
{
|
|
34
|
+
links: {
|
|
35
|
+
cn: 'https://chat-plugin-sdk.lobehub.com',
|
|
36
|
+
en: 'https://chat-plugin-sdk.lobehub.com',
|
|
37
|
+
},
|
|
38
|
+
titles: {
|
|
39
|
+
cn: '插件 SDK 文档',
|
|
40
|
+
en: 'Plugin SDK Docs',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
links: {
|
|
45
|
+
cn: 'https://github.com/lobehub/lobe-chat-plugins/blob/main/README.zh-CN.md',
|
|
46
|
+
en: 'https://github.com/lobehub/lobe-chat-plugins',
|
|
47
|
+
},
|
|
48
|
+
titles: {
|
|
49
|
+
cn: '插件索引与提交',
|
|
50
|
+
en: 'Plugin Index and Submit',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
title: '🧩 Plugins',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
dir: 'Others',
|
|
58
|
+
title: '📊 Others',
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import remarkGfm from 'remark-gfm';
|
|
3
|
+
import remarkParse from 'remark-parse';
|
|
4
|
+
import { unified } from 'unified';
|
|
5
|
+
import { visit } from 'unist-util-visit';
|
|
6
|
+
|
|
7
|
+
import { SPLIT } from './const';
|
|
8
|
+
|
|
9
|
+
export const updateDocs = (path: string, content: string) => {
|
|
10
|
+
const md = readFileSync(path, 'utf8');
|
|
11
|
+
const mds = md.split(SPLIT);
|
|
12
|
+
mds[1] = [' ', content, ' '].join('\n\n');
|
|
13
|
+
const result = mds.join(SPLIT);
|
|
14
|
+
writeFileSync(path, result, 'utf8');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const convertMarkdownToMdast = async (md: string) => {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
return unified().use(remarkParse).use(remarkGfm).parse(md.trim());
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getTitle = async (path: string) => {
|
|
23
|
+
const md = readFileSync(path, 'utf8');
|
|
24
|
+
const mdast: any = await convertMarkdownToMdast(md);
|
|
25
|
+
|
|
26
|
+
let title = '';
|
|
27
|
+
visit(mdast, 'heading', (node) => {
|
|
28
|
+
if (node.depth !== 1) return;
|
|
29
|
+
visit(node, 'text', (heading) => {
|
|
30
|
+
title += heading.value;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return title;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const genMdLink = (title: string, url: string) => {
|
|
37
|
+
return `[${title}](${url})`;
|
|
38
|
+
};
|
|
@@ -51,7 +51,7 @@ describe('chainSummaryTitle', () => {
|
|
|
51
51
|
role: 'user',
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
|
-
model: LanguageModel.
|
|
54
|
+
model: LanguageModel.GPT3_5_16K,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
// Verify that getMessagesTokenCount was called with the correct messages
|
|
@@ -97,7 +97,7 @@ describe('chainSummaryTitle', () => {
|
|
|
97
97
|
role: 'user',
|
|
98
98
|
},
|
|
99
99
|
],
|
|
100
|
-
|
|
100
|
+
model: 'gpt-3.5-turbo-16k',
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// Verify that getMessagesTokenCount was called with the correct messages
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ModelTokens } from '@/const/modelTokens';
|
|
2
1
|
import { chatHelpers } from '@/store/chat/helpers';
|
|
3
2
|
import { globalHelpers } from '@/store/global/helpers';
|
|
4
3
|
import { LanguageModel } from '@/types/llm';
|
|
@@ -21,11 +20,11 @@ export const chainSummaryTitle = async (
|
|
|
21
20
|
role: 'user',
|
|
22
21
|
},
|
|
23
22
|
];
|
|
24
|
-
// 如果超过
|
|
23
|
+
// 如果超过 4k,则使用 GPT3.5 16K 模型
|
|
25
24
|
const tokens = await chatHelpers.getMessagesTokenCount(finalMessages);
|
|
26
25
|
let model: LanguageModel | undefined = undefined;
|
|
27
|
-
if (tokens >
|
|
28
|
-
model = LanguageModel.
|
|
26
|
+
if (tokens > 4000) {
|
|
27
|
+
model = LanguageModel.GPT3_5_16K;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
return {
|
package/src/const/modelTokens.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { LanguageModel } from '@/types/llm';
|
|
|
2
2
|
|
|
3
3
|
// refs to: https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
|
|
4
4
|
export const ModelTokens: Record<LanguageModel, number> = {
|
|
5
|
-
[LanguageModel.GPT3_5]:
|
|
5
|
+
[LanguageModel.GPT3_5]: 4096,
|
|
6
|
+
[LanguageModel.GPT3_5_1106]: 16_385,
|
|
7
|
+
[LanguageModel.GPT3_5_16K]: 16_385,
|
|
6
8
|
[LanguageModel.GPT4]: 8196,
|
|
7
9
|
[LanguageModel.GPT4_PREVIEW]: 128_000,
|
|
8
10
|
[LanguageModel.GPT4_VISION_PREVIEW]: 128_000,
|
|
@@ -23,6 +23,14 @@ exports[`settingsSelectors > CUSTOM_MODELS > duplicate naming model 1`] = `
|
|
|
23
23
|
"displayName": "gpt-3.5-turbo",
|
|
24
24
|
"name": "gpt-3.5-turbo",
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
"displayName": "gpt-3.5-turbo-1106",
|
|
28
|
+
"name": "gpt-3.5-turbo-1106",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"displayName": "gpt-3.5-turbo-16k",
|
|
32
|
+
"name": "gpt-3.5-turbo-16k",
|
|
33
|
+
},
|
|
26
34
|
{
|
|
27
35
|
"displayName": "gpt-4",
|
|
28
36
|
"name": "gpt-4",
|
|
@@ -48,6 +56,14 @@ exports[`settingsSelectors > CUSTOM_MODELS > only add the model 1`] = `
|
|
|
48
56
|
"displayName": "gpt-3.5-turbo",
|
|
49
57
|
"name": "gpt-3.5-turbo",
|
|
50
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"displayName": "gpt-3.5-turbo-1106",
|
|
61
|
+
"name": "gpt-3.5-turbo-1106",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"displayName": "gpt-3.5-turbo-16k",
|
|
65
|
+
"name": "gpt-3.5-turbo-16k",
|
|
66
|
+
},
|
|
51
67
|
{
|
|
52
68
|
"displayName": "gpt-4",
|
|
53
69
|
"name": "gpt-4",
|
package/src/types/llm.ts
CHANGED
|
File without changes
|
/package/docs/{Deploy-with-Azure-OpenAI.zh-CN.md → Deployment/Deploy-with-Azure-OpenAI.zh-CN.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|