@lobehub/chat 1.138.1 → 1.138.3
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 +50 -0
- package/changelog/v1.json +18 -0
- package/docker-compose/local/docker-compose.yml +1 -1
- package/docker-compose/local/grafana/docker-compose.yml +1 -1
- package/docker-compose/production/grafana/docker-compose.yml +1 -1
- package/locales/ar/chat.json +1 -1
- package/locales/ar/common.json +1 -1
- package/locales/ar/models.json +35 -8
- package/locales/ar/plugin.json +1 -1
- package/locales/ar/welcome.json +1 -1
- package/locales/bg-BG/chat.json +1 -1
- package/locales/bg-BG/common.json +1 -1
- package/locales/bg-BG/models.json +35 -8
- package/locales/bg-BG/plugin.json +1 -1
- package/locales/bg-BG/welcome.json +1 -1
- package/locales/de-DE/chat.json +1 -1
- package/locales/de-DE/common.json +1 -1
- package/locales/de-DE/models.json +35 -8
- package/locales/de-DE/plugin.json +1 -1
- package/locales/de-DE/welcome.json +1 -1
- package/locales/en-US/chat.json +1 -1
- package/locales/en-US/common.json +1 -1
- package/locales/en-US/models.json +35 -8
- package/locales/en-US/plugin.json +1 -1
- package/locales/en-US/welcome.json +1 -1
- package/locales/es-ES/chat.json +1 -1
- package/locales/es-ES/common.json +1 -1
- package/locales/es-ES/models.json +35 -8
- package/locales/es-ES/plugin.json +1 -1
- package/locales/es-ES/welcome.json +1 -1
- package/locales/fa-IR/chat.json +1 -1
- package/locales/fa-IR/common.json +1 -1
- package/locales/fa-IR/models.json +35 -8
- package/locales/fa-IR/plugin.json +1 -1
- package/locales/fa-IR/welcome.json +1 -1
- package/locales/fr-FR/chat.json +1 -1
- package/locales/fr-FR/common.json +1 -1
- package/locales/fr-FR/models.json +35 -8
- package/locales/fr-FR/plugin.json +1 -1
- package/locales/fr-FR/welcome.json +1 -1
- package/locales/it-IT/chat.json +1 -1
- package/locales/it-IT/common.json +1 -1
- package/locales/it-IT/models.json +35 -8
- package/locales/it-IT/plugin.json +1 -1
- package/locales/it-IT/welcome.json +1 -1
- package/locales/ja-JP/chat.json +1 -1
- package/locales/ja-JP/common.json +1 -1
- package/locales/ja-JP/models.json +35 -8
- package/locales/ja-JP/plugin.json +1 -1
- package/locales/ja-JP/welcome.json +1 -1
- package/locales/ko-KR/chat.json +1 -1
- package/locales/ko-KR/common.json +1 -1
- package/locales/ko-KR/models.json +35 -8
- package/locales/ko-KR/plugin.json +1 -1
- package/locales/ko-KR/welcome.json +1 -1
- package/locales/nl-NL/chat.json +1 -1
- package/locales/nl-NL/common.json +1 -1
- package/locales/nl-NL/models.json +35 -8
- package/locales/nl-NL/plugin.json +1 -1
- package/locales/nl-NL/welcome.json +1 -1
- package/locales/pl-PL/chat.json +1 -1
- package/locales/pl-PL/common.json +1 -1
- package/locales/pl-PL/models.json +35 -8
- package/locales/pl-PL/plugin.json +1 -1
- package/locales/pl-PL/welcome.json +1 -1
- package/locales/pt-BR/chat.json +1 -1
- package/locales/pt-BR/common.json +1 -1
- package/locales/pt-BR/models.json +35 -8
- package/locales/pt-BR/plugin.json +1 -1
- package/locales/pt-BR/welcome.json +1 -1
- package/locales/ru-RU/chat.json +1 -1
- package/locales/ru-RU/common.json +1 -1
- package/locales/ru-RU/models.json +35 -8
- package/locales/ru-RU/plugin.json +1 -1
- package/locales/ru-RU/welcome.json +1 -1
- package/locales/tr-TR/chat.json +1 -1
- package/locales/tr-TR/common.json +1 -1
- package/locales/tr-TR/models.json +35 -8
- package/locales/tr-TR/plugin.json +1 -1
- package/locales/tr-TR/welcome.json +1 -1
- package/locales/vi-VN/chat.json +1 -1
- package/locales/vi-VN/common.json +1 -1
- package/locales/vi-VN/models.json +35 -8
- package/locales/vi-VN/plugin.json +1 -1
- package/locales/vi-VN/welcome.json +1 -1
- package/locales/zh-CN/common.json +1 -1
- package/locales/zh-CN/models.json +35 -8
- package/locales/zh-CN/plugin.json +1 -1
- package/locales/zh-CN/welcome.json +1 -1
- package/locales/zh-TW/chat.json +1 -1
- package/locales/zh-TW/common.json +1 -1
- package/locales/zh-TW/models.json +35 -8
- package/locales/zh-TW/plugin.json +1 -1
- package/locales/zh-TW/welcome.json +1 -1
- package/package.json +1 -1
- package/packages/const/src/branding.ts +2 -2
- package/packages/const/src/index.ts +1 -0
- package/packages/const/src/version.ts +1 -1
- package/packages/database/src/models/topic.ts +0 -1
- package/packages/database/src/repositories/aiInfra/index.ts +19 -13
- package/packages/obervability-otel/package.json +4 -4
- package/packages/prompts/CLAUDE.md +289 -43
- package/packages/prompts/package.json +2 -1
- package/packages/prompts/promptfoo/supervisor/productive/eval.yaml +51 -0
- package/packages/prompts/promptfoo/supervisor/productive/prompt.ts +18 -0
- package/packages/prompts/promptfoo/supervisor/productive/tests/basic-case.ts +54 -0
- package/packages/prompts/promptfoo/supervisor/productive/tests/role.ts +58 -0
- package/packages/prompts/promptfoo/supervisor/productive/tools.json +80 -0
- package/packages/prompts/src/contexts/index.ts +1 -0
- package/packages/prompts/src/contexts/supervisor/index.ts +2 -0
- package/packages/prompts/src/contexts/supervisor/makeDecision.ts +68 -0
- package/packages/prompts/src/contexts/supervisor/tools.ts +102 -0
- package/packages/prompts/src/index.ts +1 -0
- package/packages/types/src/aiChat.ts +9 -3
- package/src/app/[variants]/(auth)/next-auth/signin/AuthSignInBox.tsx +4 -4
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/{OpeningQuestions.tsx → AgentWelcome/OpeningQuestions.tsx} +2 -2
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/{InboxWelcome → AgentWelcome}/index.tsx +38 -17
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/index.tsx +2 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/page.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/page.tsx +1 -1
- package/src/config/modelProviders/lobehub.ts +1 -1
- package/src/locales/default/common.ts +1 -1
- package/src/locales/default/plugin.ts +1 -1
- package/src/locales/default/welcome.ts +1 -1
- package/src/server/ld.ts +1 -1
- package/src/server/routers/lambda/aiChat.ts +1 -1
- package/src/server/services/aiChat/index.test.ts +1 -1
- package/src/server/services/aiChat/index.ts +1 -1
- package/src/services/topic/client.ts +1 -1
- package/src/store/chat/slices/message/supervisor.test.ts +12 -5
- package/src/store/chat/slices/message/supervisor.ts +16 -129
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/InboxWelcome/AgentsSuggest.tsx +0 -114
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/InboxWelcome/QuestionSuggest.tsx +0 -104
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/WelcomeMessage.tsx +0 -65
- /package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/{InboxWelcome → AgentWelcome}/AddButton.tsx +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contextSupervisorMakeDecision } from '@lobechat/prompts';
|
|
2
2
|
import { ChatMessage, GroupMemberWithAgent } from '@lobechat/types';
|
|
3
3
|
|
|
4
4
|
import { aiChatService } from '@/services/aiChat';
|
|
@@ -61,7 +61,7 @@ export class GroupChatSupervisor {
|
|
|
61
61
|
* Make decision on who should speak next
|
|
62
62
|
*/
|
|
63
63
|
async makeDecision(context: SupervisorContext): Promise<SupervisorDecisionResult> {
|
|
64
|
-
const {
|
|
64
|
+
const { availableAgents } = context;
|
|
65
65
|
|
|
66
66
|
// If no agents available, stop conversation
|
|
67
67
|
if (availableAgents.length === 0) {
|
|
@@ -69,22 +69,7 @@ export class GroupChatSupervisor {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
try {
|
|
72
|
-
|
|
73
|
-
const conversationHistory = groupSupervisorPrompts(messages);
|
|
74
|
-
|
|
75
|
-
const supervisorPrompt = groupChatPrompts.buildSupervisorPrompt({
|
|
76
|
-
allowDM,
|
|
77
|
-
availableAgents: availableAgents
|
|
78
|
-
.filter((agent) => agent.id)
|
|
79
|
-
.map((agent) => ({ id: agent.id!, title: agent.title })),
|
|
80
|
-
conversationHistory,
|
|
81
|
-
scene: context.scene,
|
|
82
|
-
systemPrompt,
|
|
83
|
-
todoList,
|
|
84
|
-
userName,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const response = await this.callLLMForDecision(supervisorPrompt, context);
|
|
72
|
+
const response = await this.callLLMForDecision(context);
|
|
88
73
|
const result = this.parseSupervisorResponse(response, availableAgents, context);
|
|
89
74
|
|
|
90
75
|
console.log('Supervisor TODO list:', result.todos);
|
|
@@ -102,123 +87,25 @@ export class GroupChatSupervisor {
|
|
|
102
87
|
* Call LLM service to get supervisor decision
|
|
103
88
|
*/
|
|
104
89
|
private async callLLMForDecision(
|
|
105
|
-
prompt: string,
|
|
106
90
|
context: SupervisorContext,
|
|
107
91
|
): Promise<SupervisorToolCall[] | string> {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
name: 'trigger_agent',
|
|
119
|
-
parameters: {
|
|
120
|
-
properties: {
|
|
121
|
-
id: {
|
|
122
|
-
description: 'The agent id to trigger.',
|
|
123
|
-
type: 'string',
|
|
124
|
-
},
|
|
125
|
-
instruction: {
|
|
126
|
-
description:
|
|
127
|
-
'The instruction or message for the agent. No longer than 10 words. Always use English.',
|
|
128
|
-
type: 'string',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
required: ['id', 'instruction'],
|
|
132
|
-
type: 'object',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
description:
|
|
137
|
-
'Wait for user input. Use this when the conversation history looks likes fine for now, or agents are waiting for user input.',
|
|
138
|
-
name: 'wait_for_user_input',
|
|
139
|
-
parameters: {
|
|
140
|
-
properties: {
|
|
141
|
-
reason: {
|
|
142
|
-
description: 'Optional reason for pausing the conversation.',
|
|
143
|
-
type: 'string',
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
required: [],
|
|
147
|
-
type: 'object',
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
// Add DM tool if allowed
|
|
153
|
-
if (context.allowDM) {
|
|
154
|
-
tools.push({
|
|
155
|
-
description: 'Trigger an agent to DM another agent or user.',
|
|
156
|
-
name: 'trigger_agent_dm',
|
|
157
|
-
parameters: {
|
|
158
|
-
properties: {
|
|
159
|
-
id: {
|
|
160
|
-
description: 'The agent id to trigger.',
|
|
161
|
-
type: 'string',
|
|
162
|
-
},
|
|
163
|
-
instruction: {
|
|
164
|
-
description: 'The instruction or message for the agent.',
|
|
165
|
-
type: 'string',
|
|
166
|
-
},
|
|
167
|
-
target: {
|
|
168
|
-
description: 'The target agent id. Only used when need DM.',
|
|
169
|
-
type: 'string',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
required: ['id', 'instruction', 'target'],
|
|
173
|
-
type: 'object',
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Add todo tools if in productive scene
|
|
179
|
-
if (context.scene === 'productive') {
|
|
180
|
-
tools.push(
|
|
181
|
-
{
|
|
182
|
-
description: 'Create a new todo item',
|
|
183
|
-
name: 'create_todo',
|
|
184
|
-
parameters: {
|
|
185
|
-
properties: {
|
|
186
|
-
assignee: {
|
|
187
|
-
description: 'Who will do the todo. Can be agent id or empty.',
|
|
188
|
-
type: 'string',
|
|
189
|
-
},
|
|
190
|
-
content: {
|
|
191
|
-
description: 'The todo content or description.',
|
|
192
|
-
type: 'string',
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
required: ['content', 'assignee'],
|
|
196
|
-
type: 'object',
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
description: 'Finish a todo by index',
|
|
201
|
-
name: 'finish_todo',
|
|
202
|
-
parameters: {
|
|
203
|
-
properties: {
|
|
204
|
-
index: {
|
|
205
|
-
description: 'The index of the todo to finish.',
|
|
206
|
-
type: 'number',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
required: ['index'],
|
|
210
|
-
type: 'object',
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
);
|
|
214
|
-
}
|
|
92
|
+
const contexts = contextSupervisorMakeDecision({
|
|
93
|
+
allowDM: context.allowDM,
|
|
94
|
+
availableAgents: context.availableAgents
|
|
95
|
+
.filter((agent) => agent.id)
|
|
96
|
+
.map((agent) => ({ id: agent.id, title: agent.title })),
|
|
97
|
+
messages: context.messages,
|
|
98
|
+
scene: context.scene,
|
|
99
|
+
todoList: context.todoList,
|
|
100
|
+
userName: context.userName,
|
|
101
|
+
});
|
|
215
102
|
|
|
216
103
|
try {
|
|
217
104
|
const response = await aiChatService.generateJSON(
|
|
218
105
|
{
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
106
|
+
...(contexts as any),
|
|
107
|
+
model: context.model,
|
|
108
|
+
provider: context.provider,
|
|
222
109
|
},
|
|
223
110
|
context.abortController || new AbortController(),
|
|
224
111
|
);
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ActionIcon, Avatar, Block, Grid, Text } from '@lobehub/ui';
|
|
4
|
-
import { Skeleton } from 'antd';
|
|
5
|
-
import { createStyles } from 'antd-style';
|
|
6
|
-
import { RefreshCw } from 'lucide-react';
|
|
7
|
-
import Link from 'next/link';
|
|
8
|
-
import { memo, useState } from 'react';
|
|
9
|
-
import { useTranslation } from 'react-i18next';
|
|
10
|
-
import { Flexbox } from 'react-layout-kit';
|
|
11
|
-
import urlJoin from 'url-join';
|
|
12
|
-
|
|
13
|
-
import { useDiscoverStore } from '@/store/discover';
|
|
14
|
-
import { DiscoverAssistantItem } from '@/types/discover';
|
|
15
|
-
|
|
16
|
-
const useStyles = createStyles(({ css, token, responsive }) => ({
|
|
17
|
-
card: css`
|
|
18
|
-
position: relative;
|
|
19
|
-
|
|
20
|
-
overflow: hidden;
|
|
21
|
-
|
|
22
|
-
height: 100%;
|
|
23
|
-
min-height: 110px;
|
|
24
|
-
padding: 16px;
|
|
25
|
-
border-radius: ${token.borderRadiusLG}px;
|
|
26
|
-
|
|
27
|
-
background: ${token.colorBgContainer};
|
|
28
|
-
|
|
29
|
-
${responsive.mobile} {
|
|
30
|
-
min-height: 72px;
|
|
31
|
-
}
|
|
32
|
-
`,
|
|
33
|
-
cardDesc: css`
|
|
34
|
-
margin-block: 0 !important;
|
|
35
|
-
color: ${token.colorTextDescription};
|
|
36
|
-
`,
|
|
37
|
-
cardTitle: css`
|
|
38
|
-
margin-block: 0 !important;
|
|
39
|
-
font-size: 16px;
|
|
40
|
-
font-weight: bold;
|
|
41
|
-
`,
|
|
42
|
-
icon: css`
|
|
43
|
-
color: ${token.colorTextSecondary};
|
|
44
|
-
`,
|
|
45
|
-
title: css`
|
|
46
|
-
color: ${token.colorTextDescription};
|
|
47
|
-
`,
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const AgentsSuggest = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
51
|
-
const { t } = useTranslation('welcome');
|
|
52
|
-
const [page, setPage] = useState(1);
|
|
53
|
-
const useAssistantList = useDiscoverStore((s) => s.useAssistantList);
|
|
54
|
-
|
|
55
|
-
const { data: assistantList, isLoading } = useAssistantList({
|
|
56
|
-
page,
|
|
57
|
-
pageSize: mobile ? 2 : 4,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const { styles } = useStyles();
|
|
61
|
-
|
|
62
|
-
const loadingCards = Array.from({ length: mobile ? 2 : 4 }).map((_, index) => (
|
|
63
|
-
<Block className={styles.card} key={index}>
|
|
64
|
-
<Skeleton active avatar paragraph={{ rows: 2 }} title={false} />
|
|
65
|
-
</Block>
|
|
66
|
-
));
|
|
67
|
-
|
|
68
|
-
const handleRefresh = () => {
|
|
69
|
-
if (!assistantList) return;
|
|
70
|
-
setPage(page + 1);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// if no assistant data, just hide the component
|
|
74
|
-
if (!isLoading && !assistantList?.items?.length) return null;
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<Flexbox gap={8} width={'100%'}>
|
|
78
|
-
<Flexbox align={'center'} horizontal justify={'space-between'}>
|
|
79
|
-
<div className={styles.title}>{t('guide.agents.title')}</div>
|
|
80
|
-
<ActionIcon
|
|
81
|
-
icon={RefreshCw}
|
|
82
|
-
onClick={handleRefresh}
|
|
83
|
-
size={{ blockSize: 24, size: 14 }}
|
|
84
|
-
title={t('guide.agents.replaceBtn')}
|
|
85
|
-
/>
|
|
86
|
-
</Flexbox>
|
|
87
|
-
<Grid gap={8} rows={2}>
|
|
88
|
-
{isLoading || !assistantList
|
|
89
|
-
? loadingCards
|
|
90
|
-
: assistantList.items.map((item: DiscoverAssistantItem) => (
|
|
91
|
-
<Link
|
|
92
|
-
href={urlJoin('/discover/assistant', item.identifier)}
|
|
93
|
-
key={item.identifier}
|
|
94
|
-
prefetch={false}
|
|
95
|
-
>
|
|
96
|
-
<Block className={styles.card} clickable gap={12} horizontal variant={'outlined'}>
|
|
97
|
-
<Avatar avatar={item.avatar} style={{ flex: 'none' }} />
|
|
98
|
-
<Flexbox gap={2} style={{ overflow: 'hidden', width: '100%' }}>
|
|
99
|
-
<Text className={styles.cardTitle} ellipsis={{ rows: 1 }}>
|
|
100
|
-
{item.title}
|
|
101
|
-
</Text>
|
|
102
|
-
<Text className={styles.cardDesc} ellipsis={{ rows: mobile ? 1 : 2 }}>
|
|
103
|
-
{item.description}
|
|
104
|
-
</Text>
|
|
105
|
-
</Flexbox>
|
|
106
|
-
</Block>
|
|
107
|
-
</Link>
|
|
108
|
-
))}
|
|
109
|
-
</Grid>
|
|
110
|
-
</Flexbox>
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
export default AgentsSuggest;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ActionIcon, Block } from '@lobehub/ui';
|
|
4
|
-
import { createStyles } from 'antd-style';
|
|
5
|
-
import { shuffle } from 'lodash-es';
|
|
6
|
-
import { ArrowRight } from 'lucide-react';
|
|
7
|
-
import Link from 'next/link';
|
|
8
|
-
import { memo } from 'react';
|
|
9
|
-
import { useTranslation } from 'react-i18next';
|
|
10
|
-
import { Flexbox } from 'react-layout-kit';
|
|
11
|
-
|
|
12
|
-
import { BRANDING_NAME } from '@/const/branding';
|
|
13
|
-
import { USAGE_DOCUMENTS } from '@/const/url';
|
|
14
|
-
import { useChatStore } from '@/store/chat';
|
|
15
|
-
|
|
16
|
-
import { useSend } from '../../../ChatInput/useSend';
|
|
17
|
-
|
|
18
|
-
const useStyles = createStyles(({ css, token, responsive }) => ({
|
|
19
|
-
card: css`
|
|
20
|
-
padding-block: 12px;
|
|
21
|
-
padding-inline: 24px;
|
|
22
|
-
border-radius: 48px;
|
|
23
|
-
|
|
24
|
-
color: ${token.colorText};
|
|
25
|
-
|
|
26
|
-
background: ${token.colorBgContainer};
|
|
27
|
-
|
|
28
|
-
${responsive.mobile} {
|
|
29
|
-
padding-block: 8px;
|
|
30
|
-
padding-inline: 16px;
|
|
31
|
-
}
|
|
32
|
-
`,
|
|
33
|
-
icon: css`
|
|
34
|
-
color: ${token.colorTextSecondary};
|
|
35
|
-
`,
|
|
36
|
-
title: css`
|
|
37
|
-
color: ${token.colorTextDescription};
|
|
38
|
-
`,
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
const qa = shuffle([
|
|
42
|
-
'q01',
|
|
43
|
-
'q02',
|
|
44
|
-
'q03',
|
|
45
|
-
'q04',
|
|
46
|
-
'q05',
|
|
47
|
-
'q06',
|
|
48
|
-
'q07',
|
|
49
|
-
'q08',
|
|
50
|
-
'q09',
|
|
51
|
-
'q10',
|
|
52
|
-
'q11',
|
|
53
|
-
'q12',
|
|
54
|
-
'q13',
|
|
55
|
-
'q14',
|
|
56
|
-
'q15',
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
const QuestionSuggest = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
60
|
-
const [updateInputMessage] = useChatStore((s) => [s.updateInputMessage]);
|
|
61
|
-
|
|
62
|
-
const { t } = useTranslation('welcome');
|
|
63
|
-
const { styles } = useStyles();
|
|
64
|
-
const { send: sendMessage } = useSend();
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Flexbox gap={8} width={'100%'}>
|
|
68
|
-
<Flexbox align={'center'} horizontal justify={'space-between'}>
|
|
69
|
-
<div className={styles.title}>{t('guide.questions.title')}</div>
|
|
70
|
-
<Link href={USAGE_DOCUMENTS} target={'_blank'}>
|
|
71
|
-
<ActionIcon
|
|
72
|
-
icon={ArrowRight}
|
|
73
|
-
size={{ blockSize: 24, size: 16 }}
|
|
74
|
-
title={t('guide.questions.moreBtn')}
|
|
75
|
-
/>
|
|
76
|
-
</Link>
|
|
77
|
-
</Flexbox>
|
|
78
|
-
<Flexbox gap={8} horizontal wrap={'wrap'}>
|
|
79
|
-
{qa.slice(0, mobile ? 2 : 5).map((item) => {
|
|
80
|
-
const text = t(`guide.qa.${item}` as any, { appName: BRANDING_NAME });
|
|
81
|
-
return (
|
|
82
|
-
<Block
|
|
83
|
-
align={'center'}
|
|
84
|
-
className={styles.card}
|
|
85
|
-
clickable
|
|
86
|
-
gap={8}
|
|
87
|
-
horizontal
|
|
88
|
-
key={item}
|
|
89
|
-
onClick={() => {
|
|
90
|
-
updateInputMessage(text);
|
|
91
|
-
sendMessage({ isWelcomeQuestion: true });
|
|
92
|
-
}}
|
|
93
|
-
variant={'outlined'}
|
|
94
|
-
>
|
|
95
|
-
{t(text)}
|
|
96
|
-
</Block>
|
|
97
|
-
);
|
|
98
|
-
})}
|
|
99
|
-
</Flexbox>
|
|
100
|
-
</Flexbox>
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
export default QuestionSuggest;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import isEqual from 'fast-deep-equal';
|
|
2
|
-
import qs from 'query-string';
|
|
3
|
-
import React, { useMemo } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { Flexbox } from 'react-layout-kit';
|
|
6
|
-
|
|
7
|
-
import { ChatItem } from '@/features/ChatItem';
|
|
8
|
-
import { useAgentStore } from '@/store/agent';
|
|
9
|
-
import { agentChatConfigSelectors, agentSelectors } from '@/store/agent/selectors';
|
|
10
|
-
import { useChatStore } from '@/store/chat';
|
|
11
|
-
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
|
|
12
|
-
import { useSessionStore } from '@/store/session';
|
|
13
|
-
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
14
|
-
|
|
15
|
-
import OpeningQuestions from './OpeningQuestions';
|
|
16
|
-
|
|
17
|
-
const WelcomeMessage = () => {
|
|
18
|
-
const mobile = useServerConfigStore((s) => s.isMobile);
|
|
19
|
-
const { t } = useTranslation('chat');
|
|
20
|
-
const type = useAgentStore(agentChatConfigSelectors.displayMode);
|
|
21
|
-
const openingMessage = useAgentStore(agentSelectors.openingMessage);
|
|
22
|
-
const openingQuestions = useAgentStore(agentSelectors.openingQuestions);
|
|
23
|
-
|
|
24
|
-
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
|
25
|
-
const { isAgentEditable } = useServerConfigStore(featureFlagsSelectors);
|
|
26
|
-
const activeId = useChatStore((s) => s.activeId);
|
|
27
|
-
|
|
28
|
-
const agentSystemRoleMsg = t('agentDefaultMessageWithSystemRole', {
|
|
29
|
-
name: meta.title || t('defaultAgent'),
|
|
30
|
-
systemRole: meta.description,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const agentMsg = t(isAgentEditable ? 'agentDefaultMessage' : 'agentDefaultMessageWithoutEdit', {
|
|
34
|
-
name: meta.title || t('defaultAgent'),
|
|
35
|
-
url: qs.stringifyUrl({
|
|
36
|
-
query: mobile ? { session: activeId, showMobileWorkspace: mobile } : { session: activeId },
|
|
37
|
-
url: '/chat/settings',
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const message = useMemo(() => {
|
|
42
|
-
if (openingMessage) return openingMessage;
|
|
43
|
-
return !!meta.description ? agentSystemRoleMsg : agentMsg;
|
|
44
|
-
}, [openingMessage, agentSystemRoleMsg, agentMsg, meta.description]);
|
|
45
|
-
|
|
46
|
-
const chatItem = (
|
|
47
|
-
<ChatItem
|
|
48
|
-
avatar={meta}
|
|
49
|
-
editing={false}
|
|
50
|
-
message={message}
|
|
51
|
-
placement={'left'}
|
|
52
|
-
variant={type === 'chat' ? 'bubble' : 'docs'}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return openingQuestions.length > 0 ? (
|
|
57
|
-
<Flexbox>
|
|
58
|
-
{chatItem}
|
|
59
|
-
<OpeningQuestions mobile={mobile} questions={openingQuestions} />
|
|
60
|
-
</Flexbox>
|
|
61
|
-
) : (
|
|
62
|
-
chatItem
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
export default WelcomeMessage;
|