@lobehub/chat 1.79.9 → 1.80.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 +77 -0
- package/changelog/v1.json +24 -0
- package/docs/development/basic/feature-development-new.mdx +465 -0
- package/docs/development/basic/feature-development-new.zh-CN.mdx +465 -0
- package/docs/development/database-schema.dbml +2 -0
- package/locales/ar/models.json +9 -0
- package/locales/ar/setting.json +16 -0
- package/locales/bg-BG/models.json +9 -0
- package/locales/bg-BG/setting.json +16 -0
- package/locales/de-DE/models.json +9 -0
- package/locales/de-DE/setting.json +16 -0
- package/locales/en-US/models.json +9 -0
- package/locales/en-US/setting.json +16 -0
- package/locales/es-ES/models.json +9 -0
- package/locales/es-ES/setting.json +16 -0
- package/locales/fa-IR/models.json +9 -0
- package/locales/fa-IR/setting.json +16 -0
- package/locales/fr-FR/models.json +9 -0
- package/locales/fr-FR/setting.json +16 -0
- package/locales/it-IT/models.json +9 -0
- package/locales/it-IT/setting.json +16 -0
- package/locales/ja-JP/models.json +9 -0
- package/locales/ja-JP/setting.json +16 -0
- package/locales/ko-KR/models.json +9 -0
- package/locales/ko-KR/setting.json +16 -0
- package/locales/nl-NL/models.json +9 -0
- package/locales/nl-NL/setting.json +16 -0
- package/locales/pl-PL/models.json +9 -0
- package/locales/pl-PL/setting.json +16 -0
- package/locales/pt-BR/models.json +9 -0
- package/locales/pt-BR/setting.json +16 -0
- package/locales/ru-RU/models.json +9 -0
- package/locales/ru-RU/setting.json +16 -0
- package/locales/tr-TR/models.json +9 -0
- package/locales/tr-TR/setting.json +16 -0
- package/locales/vi-VN/models.json +9 -0
- package/locales/vi-VN/setting.json +16 -0
- package/locales/zh-CN/models.json +9 -0
- package/locales/zh-CN/setting.json +16 -0
- package/locales/zh-TW/models.json +9 -0
- package/locales/zh-TW/setting.json +16 -0
- package/package.json +1 -1
- package/scripts/generate-oidc-jwk.mjs +2 -1
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/OpeningQuestions.tsx +78 -0
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/WelcomeMessage.tsx +24 -4
- package/src/app/[variants]/(main)/chat/(workspace)/features/AgentSettings/CategoryContent/useCategory.tsx +6 -1
- package/src/app/[variants]/(main)/chat/(workspace)/features/AgentSettings/index.tsx +2 -0
- package/src/config/modelProviders/openai.ts +17 -0
- package/src/const/settings/agent.ts +1 -0
- package/src/const/settings/llm.ts +1 -1
- package/src/database/_deprecated/schemas/session.ts +2 -0
- package/src/database/client/migrations.json +9 -0
- package/src/database/migrations/0021_add_agent_opening_settings.sql +2 -0
- package/src/database/migrations/meta/0021_snapshot.json +4988 -0
- package/src/database/migrations/meta/_journal.json +7 -0
- package/src/database/repositories/dataImporter/deprecated/__tests__/fixtures/messages.json +2 -0
- package/src/database/repositories/dataImporter/deprecated/__tests__/index.test.ts +19 -0
- package/src/database/schemas/agent.ts +3 -0
- package/src/features/AgentSetting/AgentOpening/OpeningMessage.tsx +80 -0
- package/src/features/AgentSetting/AgentOpening/OpeningQuestions.tsx +144 -0
- package/src/features/AgentSetting/AgentOpening/index.tsx +52 -0
- package/src/features/AgentSetting/store/selectors.ts +3 -0
- package/src/locales/default/setting.ts +16 -0
- package/src/migrations/FromV5ToV6/types/v6.ts +2 -0
- package/src/server/routers/lambda/session.ts +8 -1
- package/src/server/routers/tools/search.ts +1 -0
- package/src/services/chat.ts +1 -0
- package/src/services/import/client.test.ts +18 -0
- package/src/services/session/server.test.ts +2 -0
- package/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap +2 -1
- package/src/store/agent/slices/chat/selectors/agent.ts +7 -0
- package/src/store/global/initialState.ts +1 -0
- package/src/store/user/slices/modelList/selectors/modelProvider.test.ts +1 -0
- package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +10 -8
- package/src/types/agent/index.ts +12 -0
@@ -6,6 +6,7 @@
|
|
6
6
|
"chat": "聊天偏好",
|
7
7
|
"meta": "助手信息",
|
8
8
|
"modal": "模型设置",
|
9
|
+
"opening": "开场设置",
|
9
10
|
"plugin": "插件设置",
|
10
11
|
"prompt": "角色设定",
|
11
12
|
"tts": "语音服务"
|
@@ -253,6 +254,21 @@
|
|
253
254
|
"title": "思维开放度"
|
254
255
|
}
|
255
256
|
},
|
257
|
+
"settingOpening": {
|
258
|
+
"openingMessage": {
|
259
|
+
"desc": "打开会话时的开场消息,用来介绍助手的功能",
|
260
|
+
"placeholder": "你好,我是自定义助手。你可以立即与我开始对话,也可以前往助手设置完善我的信息。",
|
261
|
+
"title": "开场消息"
|
262
|
+
},
|
263
|
+
"openingQuestions": {
|
264
|
+
"desc": "会话开始时展示的引导性问题",
|
265
|
+
"empty": "暂无问题",
|
266
|
+
"placeholder": "请输入问题",
|
267
|
+
"repeat": "问题已存在",
|
268
|
+
"title": "开场问题"
|
269
|
+
},
|
270
|
+
"title": "开场设置"
|
271
|
+
},
|
256
272
|
"settingPlugin": {
|
257
273
|
"title": "插件列表"
|
258
274
|
},
|
@@ -1067,6 +1067,15 @@
|
|
1067
1067
|
"gpt-4-vision-preview": {
|
1068
1068
|
"description": "最新的GPT-4 Turbo模型具備視覺功能。現在,視覺請求可以使用JSON模式和函數調用。GPT-4 Turbo是一個增強版本,為多模態任務提供成本效益高的支持。它在準確性和效率之間找到平衡,適合需要進行實時交互的應用程序場景。"
|
1069
1069
|
},
|
1070
|
+
"gpt-4.1": {
|
1071
|
+
"description": "GPT-4.1 是我們用於複雜任務的旗艦模型。它非常適合跨領域解決問題。"
|
1072
|
+
},
|
1073
|
+
"gpt-4.1-mini": {
|
1074
|
+
"description": "GPT-4.1 mini 提供了智能、速度和成本之間的平衡,使其成為許多用例中具吸引力的模型。"
|
1075
|
+
},
|
1076
|
+
"gpt-4.1-nano": {
|
1077
|
+
"description": "GPT-4.1 mini 提供了智能、速度和成本之間的平衡,使其成為許多用例中具吸引力的模型。"
|
1078
|
+
},
|
1070
1079
|
"gpt-4.5-preview": {
|
1071
1080
|
"description": "GPT-4.5 的研究預覽版,它是我們迄今為止最大、最強大的 GPT 模型。它擁有廣泛的世界知識,並能更好地理解用戶意圖,使其在創造性任務和自主規劃方面表現出色。GPT-4.5 可接受文本和圖像輸入,並生成文本輸出(包括結構化輸出)。支持關鍵的開發者功能,如函數調用、批量 API 和串流輸出。在需要創造性、開放式思考和對話的任務(如寫作、學習或探索新想法)中,GPT-4.5 表現尤為出色。知識截止日期為 2023 年 10 月。"
|
1072
1081
|
},
|
@@ -6,6 +6,7 @@
|
|
6
6
|
"chat": "聊天偏好",
|
7
7
|
"meta": "助手資訊",
|
8
8
|
"modal": "模型設定",
|
9
|
+
"opening": "開場設定",
|
9
10
|
"plugin": "外掛程式設定",
|
10
11
|
"prompt": "角色設定",
|
11
12
|
"tts": "語音服務"
|
@@ -253,6 +254,21 @@
|
|
253
254
|
"title": "思維開放度"
|
254
255
|
}
|
255
256
|
},
|
257
|
+
"settingOpening": {
|
258
|
+
"openingMessage": {
|
259
|
+
"desc": "打開會話時的開場消息,用來介紹助手的功能",
|
260
|
+
"placeholder": "你好,我是 自訂助手,你可以立即與我開始對話,也可以前往 助手設定 完善我的資訊。",
|
261
|
+
"title": "開場消息"
|
262
|
+
},
|
263
|
+
"openingQuestions": {
|
264
|
+
"desc": "會話開始時展示的引導性問題",
|
265
|
+
"empty": "暫無問題",
|
266
|
+
"placeholder": "請輸入問題",
|
267
|
+
"repeat": "問題已存在",
|
268
|
+
"title": "開場問題"
|
269
|
+
},
|
270
|
+
"title": "開場設定"
|
271
|
+
},
|
256
272
|
"settingPlugin": {
|
257
273
|
"title": "插件列表"
|
258
274
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.80.0",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -8,8 +8,8 @@
|
|
8
8
|
*
|
9
9
|
* 将输出的单行 JSON 字符串设置为环境变量 OIDC_JWKS_KEY
|
10
10
|
*/
|
11
|
-
import crypto from 'node:crypto';
|
12
11
|
import { exportJWK, generateKeyPair } from 'jose';
|
12
|
+
import crypto from 'node:crypto';
|
13
13
|
|
14
14
|
// 生成密钥 ID
|
15
15
|
function generateKeyId() {
|
@@ -56,4 +56,5 @@ async function generateJwks() {
|
|
56
56
|
}
|
57
57
|
|
58
58
|
// 执行主函数
|
59
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
59
60
|
generateJwks();
|
@@ -0,0 +1,78 @@
|
|
1
|
+
'use client';
|
2
|
+
|
3
|
+
import { createStyles } from 'antd-style';
|
4
|
+
import { memo } from 'react';
|
5
|
+
import { useTranslation } from 'react-i18next';
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
7
|
+
|
8
|
+
import { useSendMessage } from '@/features/ChatInput/useSend';
|
9
|
+
import { useChatStore } from '@/store/chat';
|
10
|
+
|
11
|
+
const useStyles = createStyles(({ css, token, responsive }) => ({
|
12
|
+
card: css`
|
13
|
+
cursor: pointer;
|
14
|
+
|
15
|
+
padding-block: 12px;
|
16
|
+
padding-inline: 24px;
|
17
|
+
border-radius: 48px;
|
18
|
+
|
19
|
+
color: ${token.colorText};
|
20
|
+
|
21
|
+
background: ${token.colorBgContainer};
|
22
|
+
|
23
|
+
&:hover {
|
24
|
+
background: ${token.colorBgElevated};
|
25
|
+
}
|
26
|
+
|
27
|
+
${responsive.mobile} {
|
28
|
+
padding-block: 8px;
|
29
|
+
padding-inline: 16px;
|
30
|
+
}
|
31
|
+
`,
|
32
|
+
|
33
|
+
container: css`
|
34
|
+
padding-block: 0;
|
35
|
+
padding-inline: 20px;
|
36
|
+
`,
|
37
|
+
|
38
|
+
title: css`
|
39
|
+
color: ${token.colorTextDescription};
|
40
|
+
`,
|
41
|
+
}));
|
42
|
+
|
43
|
+
interface OpeningQuestionsProps {
|
44
|
+
mobile?: boolean;
|
45
|
+
questions: string[];
|
46
|
+
}
|
47
|
+
|
48
|
+
const OpeningQuestions = memo<OpeningQuestionsProps>(({ mobile, questions }) => {
|
49
|
+
const { t } = useTranslation('welcome');
|
50
|
+
const [updateInputMessage] = useChatStore((s) => [s.updateInputMessage]);
|
51
|
+
|
52
|
+
const { styles } = useStyles();
|
53
|
+
const { send: sendMessage } = useSendMessage();
|
54
|
+
|
55
|
+
return (
|
56
|
+
<div className={styles.container}>
|
57
|
+
<p className={styles.title}>{t('guide.questions.title')}</p>
|
58
|
+
<Flexbox gap={8} horizontal wrap={'wrap'}>
|
59
|
+
{questions.slice(0, mobile ? 2 : 5).map((question) => {
|
60
|
+
return (
|
61
|
+
<div
|
62
|
+
className={styles.card}
|
63
|
+
key={question}
|
64
|
+
onClick={() => {
|
65
|
+
updateInputMessage(question);
|
66
|
+
sendMessage({ isWelcomeQuestion: true });
|
67
|
+
}}
|
68
|
+
>
|
69
|
+
{question}
|
70
|
+
</div>
|
71
|
+
);
|
72
|
+
})}
|
73
|
+
</Flexbox>
|
74
|
+
</div>
|
75
|
+
);
|
76
|
+
});
|
77
|
+
|
78
|
+
export default OpeningQuestions;
|
@@ -1,18 +1,24 @@
|
|
1
1
|
import { ChatItem } from '@lobehub/ui';
|
2
2
|
import isEqual from 'fast-deep-equal';
|
3
|
-
import React from 'react';
|
3
|
+
import React, { useMemo } from 'react';
|
4
4
|
import { useTranslation } from 'react-i18next';
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
5
6
|
|
6
7
|
import { useAgentStore } from '@/store/agent';
|
7
|
-
import { agentChatConfigSelectors } from '@/store/agent/selectors';
|
8
|
+
import { agentChatConfigSelectors, agentSelectors } from '@/store/agent/selectors';
|
8
9
|
import { useChatStore } from '@/store/chat';
|
9
10
|
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
10
11
|
import { useSessionStore } from '@/store/session';
|
11
12
|
import { sessionMetaSelectors } from '@/store/session/selectors';
|
12
13
|
|
14
|
+
import OpeningQuestions from './OpeningQuestions';
|
15
|
+
|
13
16
|
const WelcomeMessage = () => {
|
17
|
+
const mobile = useServerConfigStore((s) => s.isMobile);
|
14
18
|
const { t } = useTranslation('chat');
|
15
19
|
const type = useAgentStore(agentChatConfigSelectors.displayMode);
|
20
|
+
const openingMessage = useAgentStore(agentSelectors.openingMessage);
|
21
|
+
const openingQuestions = useAgentStore(agentSelectors.openingQuestions);
|
16
22
|
|
17
23
|
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
18
24
|
const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
|
@@ -28,14 +34,28 @@ const WelcomeMessage = () => {
|
|
28
34
|
url: `/chat/settings?session=${activeId}`,
|
29
35
|
});
|
30
36
|
|
31
|
-
|
37
|
+
const message = useMemo(() => {
|
38
|
+
if (openingMessage) return openingMessage;
|
39
|
+
return !!meta.description ? agentSystemRoleMsg : agentMsg;
|
40
|
+
}, [openingMessage, agentSystemRoleMsg, agentMsg, meta.description]);
|
41
|
+
|
42
|
+
const chatItem = (
|
32
43
|
<ChatItem
|
33
44
|
avatar={meta}
|
34
45
|
editing={false}
|
35
|
-
message={
|
46
|
+
message={message}
|
36
47
|
placement={'left'}
|
37
48
|
type={type === 'chat' ? 'block' : 'pure'}
|
38
49
|
/>
|
39
50
|
);
|
51
|
+
|
52
|
+
return openingQuestions.length > 0 ? (
|
53
|
+
<Flexbox>
|
54
|
+
{chatItem}
|
55
|
+
<OpeningQuestions mobile={mobile} questions={openingQuestions} />
|
56
|
+
</Flexbox>
|
57
|
+
) : (
|
58
|
+
chatItem
|
59
|
+
);
|
40
60
|
};
|
41
61
|
export default WelcomeMessage;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Icon } from '@lobehub/ui';
|
2
2
|
import { MenuItemType } from 'antd/es/menu/interface';
|
3
|
-
import { Blocks, Bot, BrainCog, MessagesSquare, Mic2, UserCircle } from 'lucide-react';
|
3
|
+
import { Blocks, Bot, BrainCog, Handshake, MessagesSquare, Mic2, UserCircle } from 'lucide-react';
|
4
4
|
import { useMemo } from 'react';
|
5
5
|
import { useTranslation } from 'react-i18next';
|
6
6
|
|
@@ -32,6 +32,11 @@ export const useCategory = ({ mobile }: UseCategoryOptions = {}) => {
|
|
32
32
|
key: ChatSettingsTabs.Prompt,
|
33
33
|
label: t('agentTab.prompt'),
|
34
34
|
},
|
35
|
+
(!isInbox && {
|
36
|
+
icon: <Icon icon={Handshake} size={iconSize} />,
|
37
|
+
key: ChatSettingsTabs.Opening,
|
38
|
+
label: t('agentTab.opening'),
|
39
|
+
}) as MenuItemType,
|
35
40
|
{
|
36
41
|
icon: <Icon icon={MessagesSquare} size={iconSize} />,
|
37
42
|
key: ChatSettingsTabs.Chat,
|
@@ -12,6 +12,7 @@ import { INBOX_SESSION_ID } from '@/const/session';
|
|
12
12
|
import AgentChat from '@/features/AgentSetting/AgentChat';
|
13
13
|
import AgentMeta from '@/features/AgentSetting/AgentMeta';
|
14
14
|
import AgentModal from '@/features/AgentSetting/AgentModal';
|
15
|
+
import AgentOpening from '@/features/AgentSetting/AgentOpening';
|
15
16
|
import AgentPlugin from '@/features/AgentSetting/AgentPlugin';
|
16
17
|
import AgentPrompt from '@/features/AgentSetting/AgentPrompt';
|
17
18
|
import { AgentSettingsProvider } from '@/features/AgentSetting/AgentSettingsProvider';
|
@@ -104,6 +105,7 @@ const AgentSettings = memo(() => {
|
|
104
105
|
>
|
105
106
|
{tab === ChatSettingsTabs.Meta && <AgentMeta />}
|
106
107
|
{tab === ChatSettingsTabs.Prompt && <AgentPrompt />}
|
108
|
+
{tab === ChatSettingsTabs.Opening && <AgentOpening />}
|
107
109
|
{tab === ChatSettingsTabs.Chat && <AgentChat />}
|
108
110
|
{tab === ChatSettingsTabs.Modal && <AgentModal />}
|
109
111
|
{tab === ChatSettingsTabs.TTS && <AgentTTS />}
|
@@ -3,6 +3,23 @@ import { ModelProviderCard } from '@/types/llm';
|
|
3
3
|
// ref: https://platform.openai.com/docs/deprecations
|
4
4
|
const OpenAI: ModelProviderCard = {
|
5
5
|
chatModels: [
|
6
|
+
{
|
7
|
+
contextWindowTokens: 1_047_576,
|
8
|
+
description:
|
9
|
+
'GPT-4.1 mini 提供了智能、速度和成本之间的平衡,使其成为许多用例中有吸引力的模型。',
|
10
|
+
displayName: 'GPT-4.1 mini',
|
11
|
+
enabled: true,
|
12
|
+
functionCall: true,
|
13
|
+
id: 'gpt-4.1-mini',
|
14
|
+
maxOutput: 32_768,
|
15
|
+
pricing: {
|
16
|
+
cachedInput: 0.1,
|
17
|
+
input: 0.4,
|
18
|
+
output: 1.6,
|
19
|
+
},
|
20
|
+
releasedAt: '2025-04-14',
|
21
|
+
vision: true,
|
22
|
+
},
|
6
23
|
{
|
7
24
|
contextWindowTokens: 128_000,
|
8
25
|
description:
|
@@ -33,6 +33,7 @@ export const DEFAULT_AGENT_CHAT_CONFIG: LobeAgentChatConfig = {
|
|
33
33
|
export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
|
34
34
|
chatConfig: DEFAULT_AGENT_CHAT_CONFIG,
|
35
35
|
model: DEFAULT_MODEL,
|
36
|
+
openingQuestions: [],
|
36
37
|
params: {
|
37
38
|
frequency_penalty: 0,
|
38
39
|
presence_penalty: 0,
|
@@ -14,7 +14,7 @@ export const DEFAULT_LLM_CONFIG = genUserLLMConfig({
|
|
14
14
|
},
|
15
15
|
});
|
16
16
|
|
17
|
-
export const DEFAULT_MODEL = 'gpt-
|
17
|
+
export const DEFAULT_MODEL = 'gpt-4.1-mini';
|
18
18
|
|
19
19
|
export const DEFAULT_EMBEDDING_MODEL = 'text-embedding-3-small';
|
20
20
|
export const DEFAULT_EMBEDDING_PROVIDER = ModelProvider.OpenAI;
|
@@ -28,6 +28,8 @@ export const AgentSchema = z.object({
|
|
28
28
|
chatConfig: AgentChatConfigSchema,
|
29
29
|
fewShots: fewShotsSchema.optional(),
|
30
30
|
model: z.string().default(DEFAULT_MODEL),
|
31
|
+
openingMessage: z.string().optional(),
|
32
|
+
openingQuestions: z.array(z.string()).default([]).optional(),
|
31
33
|
params: z.object({
|
32
34
|
frequency_penalty: z.number().default(0).optional(),
|
33
35
|
max_tokens: z.number().optional(),
|
@@ -448,5 +448,14 @@
|
|
448
448
|
"bps": true,
|
449
449
|
"folderMillis": 1744458287757,
|
450
450
|
"hash": "f3a80b900906b54ba658208cd448610647fc03f1f4d51963509c07f4e53ef4de"
|
451
|
+
},
|
452
|
+
{
|
453
|
+
"sql": [
|
454
|
+
"ALTER TABLE \"agents\" ADD COLUMN IF NOT EXISTS \"opening_message\" text;",
|
455
|
+
"\nALTER TABLE \"agents\" ADD COLUMN IF NOT EXISTS \"opening_questions\" text[] DEFAULT '{}';"
|
456
|
+
],
|
457
|
+
"bps": true,
|
458
|
+
"folderMillis": 1744602998656,
|
459
|
+
"hash": "9a32c373461472a4afdb45e690c3009a0db0eaae81dcf6c8d05277a48f3a5e85"
|
451
460
|
}
|
452
461
|
]
|