@lobehub/chat 1.79.10 → 1.80.1

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/changelog/v1.json +27 -0
  3. package/docs/development/basic/feature-development.mdx +370 -619
  4. package/docs/development/basic/feature-development.zh-CN.mdx +368 -611
  5. package/docs/development/database-schema.dbml +2 -0
  6. package/locales/ar/setting.json +16 -0
  7. package/locales/bg-BG/setting.json +16 -0
  8. package/locales/de-DE/setting.json +16 -0
  9. package/locales/en-US/setting.json +16 -0
  10. package/locales/es-ES/setting.json +16 -0
  11. package/locales/fa-IR/setting.json +16 -0
  12. package/locales/fr-FR/setting.json +16 -0
  13. package/locales/it-IT/setting.json +16 -0
  14. package/locales/ja-JP/setting.json +16 -0
  15. package/locales/ko-KR/setting.json +16 -0
  16. package/locales/nl-NL/setting.json +16 -0
  17. package/locales/pl-PL/setting.json +16 -0
  18. package/locales/pt-BR/setting.json +16 -0
  19. package/locales/ru-RU/setting.json +16 -0
  20. package/locales/tr-TR/setting.json +16 -0
  21. package/locales/vi-VN/setting.json +16 -0
  22. package/locales/zh-CN/setting.json +16 -0
  23. package/locales/zh-TW/setting.json +16 -0
  24. package/package.json +1 -1
  25. package/scripts/generate-oidc-jwk.mjs +2 -1
  26. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/OpeningQuestions.tsx +78 -0
  27. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/WelcomeMessage.tsx +24 -4
  28. package/src/app/[variants]/(main)/chat/(workspace)/features/AgentSettings/CategoryContent/useCategory.tsx +6 -1
  29. package/src/app/[variants]/(main)/chat/(workspace)/features/AgentSettings/index.tsx +2 -0
  30. package/src/const/settings/agent.ts +1 -0
  31. package/src/database/_deprecated/schemas/session.ts +2 -0
  32. package/src/database/client/migrations.json +9 -0
  33. package/src/database/migrations/0021_add_agent_opening_settings.sql +2 -0
  34. package/src/database/migrations/meta/0021_snapshot.json +4988 -0
  35. package/src/database/migrations/meta/_journal.json +7 -0
  36. package/src/database/repositories/dataImporter/deprecated/__tests__/fixtures/messages.json +2 -0
  37. package/src/database/repositories/dataImporter/deprecated/__tests__/index.test.ts +19 -0
  38. package/src/database/schemas/agent.ts +3 -0
  39. package/src/features/AgentSetting/AgentOpening/OpeningMessage.tsx +80 -0
  40. package/src/features/AgentSetting/AgentOpening/OpeningQuestions.tsx +144 -0
  41. package/src/features/AgentSetting/AgentOpening/index.tsx +52 -0
  42. package/src/features/AgentSetting/store/selectors.ts +3 -0
  43. package/src/features/ChatInput/ActionBar/Upload/ClientMode.tsx +7 -6
  44. package/src/hooks/useModelSupportFiles.ts +15 -0
  45. package/src/libs/agent-runtime/stepfun/index.ts +7 -1
  46. package/src/libs/agent-runtime/zhipu/index.ts +17 -10
  47. package/src/locales/default/setting.ts +16 -0
  48. package/src/migrations/FromV5ToV6/types/v6.ts +2 -0
  49. package/src/server/routers/lambda/session.ts +8 -1
  50. package/src/services/import/client.test.ts +18 -0
  51. package/src/services/session/server.test.ts +2 -0
  52. package/src/store/agent/slices/chat/selectors/__snapshots__/agent.test.ts.snap +1 -0
  53. package/src/store/agent/slices/chat/selectors/agent.ts +7 -0
  54. package/src/store/aiInfra/slices/aiModel/selectors.ts +7 -0
  55. package/src/store/global/initialState.ts +1 -0
  56. package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +2 -0
  57. package/src/types/agent/index.ts +12 -0
@@ -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
- return (
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={!!meta.description ? agentSystemRoleMsg : agentMsg}
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 />}
@@ -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,
@@ -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
  ]
@@ -0,0 +1,2 @@
1
+ ALTER TABLE "agents" ADD COLUMN IF NOT EXISTS "opening_message" text;--> statement-breakpoint
2
+ ALTER TABLE "agents" ADD COLUMN IF NOT EXISTS "opening_questions" text[] DEFAULT '{}';