@lobehub/chat 1.0.0 → 1.1.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/.husky/commit-msg +0 -0
- package/CHANGELOG.md +25 -0
- package/locales/en_US/common.json +1 -0
- package/locales/zh_CN/common.json +2 -1
- package/locales/zh_CN/setting.json +52 -53
- package/package.json +5 -3
- package/scripts/genDefaultLocale.ts +18 -0
- package/scripts/genResources.ts +51 -0
- package/scripts/toc.ts +7 -0
- package/src/locales/resources/index.ts +8 -2
- package/src/types/locale.ts +1 -7
- package/tsconfig.json +6 -1
- package/scripts/genDefaultLocale.mjs +0 -12
- package/scripts/toc.mjs +0 -40
package/.husky/commit-msg
CHANGED
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 1.1.0](https://github.com/lobehub/lobe-chat/compare/v1.0.0...v1.1.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-07-18**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Add i18n auto flow `pnpm run i18n`.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Add i18n auto flow `pnpm run i18n` ([e18fc57](https://github.com/lobehub/lobe-chat/commit/e18fc57))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## Version 1.0.0
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-07-18**</sup>
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"agentTagPlaceholder": "Please enter a tag",
|
|
14
14
|
"archive": "Archive",
|
|
15
15
|
"autoGenerate": "Auto Generate",
|
|
16
|
+
"autoGenerateTooltip": "Description of the autocomplete assistant based on prompts",
|
|
16
17
|
"cancel": "Cancel",
|
|
17
18
|
"close": "Close",
|
|
18
19
|
"confirmRemoveSessionItemAlert": "You are about to remove this agent. Once removed, it cannot be recovered. Please confirm your action.",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"agentTagPlaceholder": "请输入标签",
|
|
14
14
|
"archive": "归档",
|
|
15
15
|
"autoGenerate": "自动补全",
|
|
16
|
+
"autoGenerateTooltip": "基于提示词自动补全助手描述",
|
|
16
17
|
"cancel": "取消",
|
|
17
18
|
"close": "关闭",
|
|
18
19
|
"confirmRemoveSessionItemAlert": "即将删除该助手,删除后该将无法找回,请确认你的操作",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"newAgent": "新建助手",
|
|
30
31
|
"noDescription": "暂无描述",
|
|
31
32
|
"ok": "确定",
|
|
32
|
-
"profile": "
|
|
33
|
+
"profile": "助手身份",
|
|
33
34
|
"reset": "重置",
|
|
34
35
|
"searchAgentPlaceholder": "搜索助手和对话...",
|
|
35
36
|
"sessionSetting": "会话设置",
|
|
@@ -1,98 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"danger": {
|
|
3
|
+
"clear": {
|
|
4
|
+
"action": "立即清除",
|
|
5
|
+
"confirm": "确认清除所有聊天、设置数据?",
|
|
6
|
+
"desc": "清除所有聊天、设置数据",
|
|
7
|
+
"title": "清除所有数据"
|
|
8
|
+
},
|
|
3
9
|
"reset": {
|
|
4
|
-
"title": "重置所有设置",
|
|
5
|
-
"desc": "重置所有设置项回默认值",
|
|
6
10
|
"action": "立即重置",
|
|
7
11
|
"confirm": "确认重置所有设置?",
|
|
8
|
-
"currentVersion": "当前版本"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"title": "清除所有数据",
|
|
12
|
-
"desc": "清除所有聊天、设置数据",
|
|
13
|
-
"action": "立即清除",
|
|
14
|
-
"confirm": "确认清除所有聊天、设置数据?"
|
|
12
|
+
"currentVersion": "当前版本",
|
|
13
|
+
"desc": "重置所有设置项回默认值",
|
|
14
|
+
"title": "重置所有设置"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
|
|
18
17
|
"header": "设置",
|
|
19
18
|
"settingChat": {
|
|
20
|
-
"title": "聊天设置",
|
|
21
|
-
"inputTemplate": {
|
|
22
|
-
"title": "用户输入预处理",
|
|
23
|
-
"desc": "用户最新的一条消息会填充到此模板"
|
|
24
|
-
},
|
|
25
19
|
"compressThreshold": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
20
|
+
"desc": "当未压缩的历史消息超过该值时,将进行压缩",
|
|
21
|
+
"title": "历史消息长度压缩阈值"
|
|
28
22
|
},
|
|
29
23
|
"historyCount": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
24
|
+
"desc": "每次请求携带的历史消息数",
|
|
25
|
+
"title": "附带历史消息数"
|
|
26
|
+
},
|
|
27
|
+
"inputTemplate": {
|
|
28
|
+
"desc": "用户最新的一条消息会填充到此模板",
|
|
29
|
+
"title": "用户输入预处理"
|
|
32
30
|
},
|
|
33
31
|
"maxTokens": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
32
|
+
"desc": "单次交互所用的最大 Token 数",
|
|
33
|
+
"title": "单次回复限制 (max_tokens)"
|
|
36
34
|
},
|
|
37
35
|
"sendKey": {
|
|
38
36
|
"title": "发送键"
|
|
39
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"title": "聊天设置"
|
|
40
39
|
},
|
|
41
40
|
"settingModel": {
|
|
42
|
-
"
|
|
41
|
+
"frequencyPenalty": {
|
|
42
|
+
"desc": "值越大,越有可能降低重复字词",
|
|
43
|
+
"title": "频率惩罚度 (frequency_penalty)"
|
|
44
|
+
},
|
|
43
45
|
"model": {
|
|
44
46
|
"title": "模型"
|
|
45
47
|
},
|
|
48
|
+
"presencePenalty": {
|
|
49
|
+
"desc": "值越大,越有可能扩展到新话题",
|
|
50
|
+
"title": "话题新鲜度 (presence_penalty)"
|
|
51
|
+
},
|
|
46
52
|
"temperature": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
53
|
+
"desc": "值越大,回复越随机",
|
|
54
|
+
"title": "随机性 (temperature)"
|
|
49
55
|
},
|
|
56
|
+
"title": "模型设置",
|
|
50
57
|
"topP": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
},
|
|
54
|
-
"presencePenalty": {
|
|
55
|
-
"title": "话题新鲜度 (presence_penalty)",
|
|
56
|
-
"desc": "值越大,越有可能扩展到新话题"
|
|
57
|
-
},
|
|
58
|
-
"frequencyPenalty": {
|
|
59
|
-
"title": "频率惩罚度 (frequency_penalty)",
|
|
60
|
-
"desc": "值越大,越有可能降低重复字词"
|
|
58
|
+
"desc": "与随机性类似,但不要和随机性一起更改",
|
|
59
|
+
"title": "核采样 (top_p)"
|
|
61
60
|
}
|
|
62
61
|
},
|
|
63
62
|
"settingOpenAI": {
|
|
63
|
+
"endpoint": {
|
|
64
|
+
"desc": "除默认地址外,必须包含 http(s)://",
|
|
65
|
+
"title": "接口地址"
|
|
66
|
+
},
|
|
64
67
|
"title": "OpenAI 设置",
|
|
65
68
|
"token": {
|
|
66
|
-
"title": "API Key",
|
|
67
69
|
"desc": "使用自己的 Key 可绕过密码访问限制",
|
|
68
|
-
"placeholder": "OpenAI API Key"
|
|
69
|
-
|
|
70
|
-
"endpoint": {
|
|
71
|
-
"title": "接口地址",
|
|
72
|
-
"desc": "除默认地址外,必须包含 http(s)://"
|
|
70
|
+
"placeholder": "OpenAI API Key",
|
|
71
|
+
"title": "API Key"
|
|
73
72
|
}
|
|
74
73
|
},
|
|
75
74
|
"settingSystem": {
|
|
76
|
-
"title": "系统设置",
|
|
77
75
|
"accessCode": {
|
|
78
|
-
"title": "访问密码",
|
|
79
76
|
"desc": "管理员已开启加密访问",
|
|
80
|
-
"placeholder": "请输入访问密码"
|
|
81
|
-
|
|
77
|
+
"placeholder": "请输入访问密码",
|
|
78
|
+
"title": "访问密码"
|
|
79
|
+
},
|
|
80
|
+
"title": "系统设置"
|
|
82
81
|
},
|
|
83
82
|
"settingTheme": {
|
|
84
|
-
"title": "主题设置",
|
|
85
83
|
"avatar": {
|
|
86
|
-
"
|
|
87
|
-
"
|
|
84
|
+
"desc": "支持 URL / Base64 / Emoji 表情符号",
|
|
85
|
+
"title": "头像"
|
|
88
86
|
},
|
|
89
87
|
"fontSize": {
|
|
90
|
-
"
|
|
91
|
-
"
|
|
88
|
+
"desc": "聊天内容的字体大小",
|
|
89
|
+
"title": "字体大小"
|
|
92
90
|
},
|
|
93
91
|
"lang": {
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
}
|
|
92
|
+
"all": "所有语言",
|
|
93
|
+
"name": "语言设置"
|
|
94
|
+
},
|
|
95
|
+
"title": "主题设置"
|
|
97
96
|
}
|
|
98
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "next build",
|
|
25
25
|
"dev": "next dev -p 3010",
|
|
26
|
-
"i18n": "lobe-i18n",
|
|
26
|
+
"i18n": "npm run i18n:toc && lobe-i18n",
|
|
27
|
+
"i18n:toc": "ts-node --project ./tsconfig.json scripts/toc.ts",
|
|
27
28
|
"lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
|
|
28
29
|
"lint:md": "remark . --quiet --frail --output",
|
|
29
30
|
"lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
|
|
@@ -35,7 +36,6 @@
|
|
|
35
36
|
"test": "vitest --passWithNoTests",
|
|
36
37
|
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
37
38
|
"test:update": "vitest -u",
|
|
38
|
-
"toc": "node scripts/toc.mjs",
|
|
39
39
|
"type-check": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"lint-staged": {
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"@umijs/lint": "^4",
|
|
108
108
|
"@vitest/coverage-v8": "latest",
|
|
109
109
|
"commitlint": "^17",
|
|
110
|
+
"consola": "^3",
|
|
110
111
|
"eslint": "^8",
|
|
111
112
|
"husky": "^8",
|
|
112
113
|
"i18next-browser-languagedetector": "^7",
|
|
@@ -122,6 +123,7 @@
|
|
|
122
123
|
"semantic-release": "^21",
|
|
123
124
|
"semantic-release-config-gitmoji": "^1",
|
|
124
125
|
"stylelint": "^15",
|
|
126
|
+
"ts-node": "^10",
|
|
125
127
|
"typescript": "^5",
|
|
126
128
|
"vitest": "latest"
|
|
127
129
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { consola } from 'consola';
|
|
2
|
+
import { colors } from 'consola/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import i18nConfig from '../.i18nrc';
|
|
7
|
+
|
|
8
|
+
export const genDefaultLocale = (input: string) => {
|
|
9
|
+
consola.info(`Default locale is ${i18nConfig.entryLocale}...`);
|
|
10
|
+
const resources = require(`../${input}/${i18nConfig.entryLocale}`);
|
|
11
|
+
const data = Object.entries(resources.default);
|
|
12
|
+
consola.start(`Generate default locale json, found ${data.length} namespaces...`);
|
|
13
|
+
for (const [ns, value] of data) {
|
|
14
|
+
const filepath = resolve(i18nConfig.output, i18nConfig.entryLocale, `${ns}.json`);
|
|
15
|
+
fs.writeFileSync(filepath, JSON.stringify(value, null, 2));
|
|
16
|
+
consola.success(colors.bgWhiteBright(colors.black(` ${ns} `)), colors.gray(filepath));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { consola } from 'consola';
|
|
2
|
+
import { colors } from 'consola/utils';
|
|
3
|
+
import { tocForResources } from 'i18next-resources-for-ts';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
|
|
7
|
+
import i18nConfig from '../.i18nrc.js';
|
|
8
|
+
|
|
9
|
+
const locales = [i18nConfig.entryLocale, ...i18nConfig.outputLocales];
|
|
10
|
+
export const genResources = (output: string) => {
|
|
11
|
+
let index = '';
|
|
12
|
+
let indexObj = '';
|
|
13
|
+
consola.start(`Generate locale resources and types, found ${locales.length} locales...`);
|
|
14
|
+
for (const locale of locales) {
|
|
15
|
+
const files = fs
|
|
16
|
+
.readdirSync(resolve(i18nConfig.output, locale))
|
|
17
|
+
.filter((name) => name.includes('.json'));
|
|
18
|
+
index += `import ${locale} from "./${locale}";\n`;
|
|
19
|
+
indexObj += ` "${locale.replace('_', '-')}": ${locale},\n`;
|
|
20
|
+
const ns = [];
|
|
21
|
+
for (const file of files) {
|
|
22
|
+
ns.push({
|
|
23
|
+
name: file.replace('.json', ''),
|
|
24
|
+
path: resolve(i18nConfig.output, locale, file),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
let toc = tocForResources(ns, resolve(output)).replaceAll('\\', '/');
|
|
28
|
+
if (locale === i18nConfig.entryLocale) {
|
|
29
|
+
toc = toc.replaceAll('.json', '').replaceAll('../../../locales/zh_CN', '../default');
|
|
30
|
+
}
|
|
31
|
+
const filepath = resolve(output, `${locale}.ts`);
|
|
32
|
+
fs.writeFileSync(filepath, toc);
|
|
33
|
+
consola.success(colors.bgBlue(colors.black(` ${locale} `)), colors.gray(filepath));
|
|
34
|
+
}
|
|
35
|
+
const indexFilepath = resolve(output, `index.ts`);
|
|
36
|
+
fs.writeFileSync(
|
|
37
|
+
indexFilepath,
|
|
38
|
+
`${index}
|
|
39
|
+
const resources = {
|
|
40
|
+
${indexObj}} as const;
|
|
41
|
+
export default resources;
|
|
42
|
+
export const defaultResources = ${i18nConfig.entryLocale};
|
|
43
|
+
export type Resources = typeof resources;
|
|
44
|
+
export type DefaultResources = typeof defaultResources;
|
|
45
|
+
export type Namespaces = keyof DefaultResources;
|
|
46
|
+
export type Locales = keyof Resources;
|
|
47
|
+
`,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
consola.success(colors.bgGreen(colors.black(` INDEX `)), colors.gray(indexFilepath));
|
|
51
|
+
};
|
package/scripts/toc.ts
ADDED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import en_US from './en_US';
|
|
2
2
|
import zh_CN from './zh_CN';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const resources = {
|
|
5
5
|
'en-US': en_US,
|
|
6
6
|
'zh-CN': zh_CN,
|
|
7
|
-
};
|
|
7
|
+
} as const;
|
|
8
|
+
export default resources;
|
|
9
|
+
export const defaultResources = zh_CN;
|
|
10
|
+
export type Resources = typeof resources;
|
|
11
|
+
export type DefaultResources = typeof defaultResources;
|
|
12
|
+
export type Namespaces = keyof DefaultResources;
|
|
13
|
+
export type Locales = keyof Resources;
|
package/src/types/locale.ts
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import defaultResources from '@/locales/resources/zh_CN';
|
|
3
|
-
|
|
4
|
-
export type Resources = typeof resources;
|
|
5
|
-
export type DefaultResources = typeof defaultResources;
|
|
6
|
-
export type Namespaces = keyof DefaultResources;
|
|
7
|
-
export type Locales = keyof Resources;
|
|
1
|
+
export type * from '@/locales/resources';
|
package/tsconfig.json
CHANGED
|
@@ -22,5 +22,10 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"exclude": ["node_modules"],
|
|
25
|
-
"include": ["next-env.d.ts", "**/*.ts", "**/*.d.ts", "**/*.tsx"]
|
|
25
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.d.ts", "**/*.tsx"],
|
|
26
|
+
"ts-node": {
|
|
27
|
+
"compilerOptions": {
|
|
28
|
+
"module": "commonjs"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
26
31
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import i18nConfig from '../.i18nrc.js';
|
|
5
|
-
import resources from '../src/locales/resources/zh_CN.ts';
|
|
6
|
-
|
|
7
|
-
for (const [ns, value] of Object.entries(resources)) {
|
|
8
|
-
fs.writeFileSync(
|
|
9
|
-
resolve(i18nConfig.output, i18nConfig.entryLocale, `${ns}.json`),
|
|
10
|
-
JSON.stringify(value, null, 2),
|
|
11
|
-
);
|
|
12
|
-
}
|
package/scripts/toc.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { tocForResources } from 'i18next-resources-for-ts';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
|
|
5
|
-
import i18nConfig from '../.i18nrc.js';
|
|
6
|
-
|
|
7
|
-
const locales = [i18nConfig.entryLocale, ...i18nConfig.outputLocales];
|
|
8
|
-
|
|
9
|
-
const RES_OUTPUT = 'src/locales/resources';
|
|
10
|
-
|
|
11
|
-
let index = '';
|
|
12
|
-
let indexObj = '';
|
|
13
|
-
locales.forEach((locale) => {
|
|
14
|
-
const files = fs
|
|
15
|
-
.readdirSync(resolve(i18nConfig.output, locale))
|
|
16
|
-
.filter((name) => name.includes('.json'));
|
|
17
|
-
index += `import ${locale} from "./${locale}";\n`;
|
|
18
|
-
indexObj += ` "${locale.replace('_', '-')}": ${locale},\n`;
|
|
19
|
-
const ns = [];
|
|
20
|
-
files.forEach((file) => {
|
|
21
|
-
ns.push({
|
|
22
|
-
name: file.replace('.json', ''),
|
|
23
|
-
path: resolve(i18nConfig.output, locale, file),
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
let toc = tocForResources(ns, resolve(RES_OUTPUT)).replaceAll('\\', '/');
|
|
27
|
-
if (locale === i18nConfig.entryLocale) {
|
|
28
|
-
toc = toc.replaceAll('.json', '').replaceAll('../../../locales/zh_CN', '../default');
|
|
29
|
-
}
|
|
30
|
-
fs.writeFileSync(resolve(RES_OUTPUT, `${locale}.ts`), toc);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
fs.writeFileSync(
|
|
34
|
-
resolve(RES_OUTPUT, `index.ts`),
|
|
35
|
-
`${index}
|
|
36
|
-
|
|
37
|
-
export default {
|
|
38
|
-
${indexObj}};
|
|
39
|
-
`,
|
|
40
|
-
);
|