@lobehub/chat 0.90.3 → 0.92.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/locales/en_US/chat.json +55 -0
  3. package/locales/en_US/common.json +17 -51
  4. package/locales/ja_JP/chat.json +55 -0
  5. package/locales/ja_JP/common.json +14 -48
  6. package/locales/ko_KR/chat.json +55 -0
  7. package/locales/ko_KR/common.json +25 -59
  8. package/locales/ru_RU/chat.json +55 -0
  9. package/locales/ru_RU/common.json +11 -45
  10. package/locales/zh_CN/chat.json +55 -0
  11. package/locales/zh_CN/common.json +11 -45
  12. package/locales/zh_TW/chat.json +55 -0
  13. package/locales/zh_TW/common.json +30 -64
  14. package/package.json +2 -1
  15. package/src/app/chat/(desktop)/features/ChatHeader.tsx +1 -1
  16. package/src/app/chat/(desktop)/features/SessionHeader.tsx +1 -1
  17. package/src/app/chat/(mobile)/features/ChatHeader.tsx +1 -1
  18. package/src/app/chat/(mobile)/features/TopicList.tsx +1 -1
  19. package/src/app/chat/features/ChatHeader/ShareButton/Inner.tsx +1 -1
  20. package/src/app/chat/features/ChatHeader/ShareButton/Preview.tsx +1 -1
  21. package/src/app/chat/features/ChatInputContent/ActionBar/ActionRight.tsx +13 -2
  22. package/src/app/chat/features/ChatInputContent/ActionBar/Token.tsx +1 -1
  23. package/src/app/chat/features/ChatInputContent/Footer/SaveTopic.tsx +11 -2
  24. package/src/app/chat/features/ChatInputContent/Footer/index.tsx +1 -1
  25. package/src/app/chat/features/ChatInputContent/index.tsx +1 -1
  26. package/src/app/chat/features/Conversation/ChatList/Actions/Assistant.tsx +22 -0
  27. package/src/app/chat/features/Conversation/ChatList/Actions/Error.tsx +15 -0
  28. package/src/app/chat/features/Conversation/ChatList/{Messages/System.tsx → Actions/Fallback.tsx} +1 -1
  29. package/src/app/chat/features/Conversation/ChatList/Actions/Function.tsx +14 -0
  30. package/src/app/chat/features/Conversation/ChatList/{Messages → Actions}/User.tsx +6 -1
  31. package/src/app/chat/features/Conversation/ChatList/Actions/customAction.ts +21 -0
  32. package/src/app/chat/features/Conversation/ChatList/Actions/index.ts +13 -0
  33. package/src/app/chat/features/Conversation/ChatList/Extras/Assistant.tsx +39 -0
  34. package/src/app/chat/features/Conversation/ChatList/Extras/Translate.tsx +75 -0
  35. package/src/app/chat/features/Conversation/ChatList/Extras/User.tsx +24 -0
  36. package/src/app/chat/features/Conversation/ChatList/Extras/index.ts +9 -0
  37. package/src/app/chat/features/Conversation/ChatList/Loading.tsx +53 -0
  38. package/src/app/chat/features/Conversation/ChatList/Messages/Assistant.tsx +5 -58
  39. package/src/app/chat/features/Conversation/ChatList/Messages/Default.tsx +7 -1
  40. package/src/app/chat/features/Conversation/ChatList/Messages/Function.tsx +4 -23
  41. package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +4 -17
  42. package/src/app/chat/features/Conversation/ChatList/Plugins/FunctionCall.tsx +0 -2
  43. package/src/app/chat/features/Conversation/ChatList/Plugins/PluginMessage.tsx +3 -4
  44. package/src/app/chat/features/Conversation/ChatList/index.tsx +34 -2
  45. package/src/app/chat/features/Conversation/index.tsx +1 -1
  46. package/src/app/chat/features/PageTitle/index.tsx +1 -3
  47. package/src/app/chat/features/SessionListContent/Inbox/index.tsx +1 -1
  48. package/src/app/chat/features/SessionListContent/List/AddButton.tsx +1 -1
  49. package/src/app/chat/features/SessionSearchBar/index.tsx +1 -1
  50. package/src/app/chat/features/TopicListContent/SystemRole/index.tsx +13 -2
  51. package/src/app/chat/features/TopicListContent/Topic/DefaultContent.tsx +1 -1
  52. package/src/app/chat/features/TopicListContent/Topic/TopicContent.tsx +11 -2
  53. package/src/app/chat/features/TopicListContent/Topic/index.tsx +1 -1
  54. package/src/app/chat/features/TopicListContent/TopicSearchBar/index.tsx +1 -1
  55. package/src/app/chat/settings/features/EditPage.tsx +1 -4
  56. package/src/app/home/index.tsx +2 -2
  57. package/src/app/market/index.tsx +1 -3
  58. package/src/app/metadata.ts +1 -3
  59. package/src/app/settings/agent/index.tsx +1 -3
  60. package/src/app/settings/common/index.tsx +1 -3
  61. package/src/app/settings/llm/index.tsx +1 -3
  62. package/src/chains/chat.ts +77 -0
  63. package/src/components/HotKeys/index.tsx +57 -0
  64. package/src/components/{PageTitle.tsx → PageTitle/index.tsx} +1 -1
  65. package/src/const/hotkeys.ts +4 -0
  66. package/src/features/AgentSetting/AgentPrompt/index.tsx +3 -3
  67. package/src/features/AgentSetting/store/action.ts +1 -1
  68. package/src/layout/ResponsiveLayout.client.tsx +4 -2
  69. package/src/locales/create.ts +2 -1
  70. package/src/locales/default/chat.ts +60 -0
  71. package/src/locales/default/common.ts +10 -45
  72. package/src/locales/options.ts +10 -0
  73. package/src/locales/resources/en_US.ts +2 -0
  74. package/src/locales/resources/index.ts +1 -1
  75. package/src/locales/resources/ja_JP.ts +2 -0
  76. package/src/locales/resources/ko_KR.ts +2 -0
  77. package/src/locales/resources/ru_RU.ts +2 -0
  78. package/src/locales/resources/zh_CN.ts +2 -0
  79. package/src/locales/resources/zh_TW.ts +2 -0
  80. package/src/store/global/selectors/settings.ts +4 -0
  81. package/src/store/session/slices/chat/actions/index.ts +7 -1
  82. package/src/store/session/slices/chat/actions/message.ts +2 -2
  83. package/src/store/session/slices/chat/actions/topic.ts +2 -2
  84. package/src/store/session/slices/chat/actions/translate.ts +87 -0
  85. package/src/store/session/slices/chat/selectors/chat.ts +23 -17
  86. package/src/store/session/slices/chat/selectors/index.ts +2 -2
  87. package/src/types/chatMessage.ts +5 -4
  88. package/src/types/translate.ts +4 -0
  89. package/src/prompts/chat.ts +0 -32
  90. package/src/utils/genSiteHeadTitle.ts +0 -1
  91. /package/src/{prompts → chains}/agent.ts +0 -0
  92. /package/src/components/{ResponsiveIndex.tsx → ResponsiveIndex/index.tsx} +0 -0
@@ -13,7 +13,7 @@ import { useStyles } from './style';
13
13
 
14
14
  const SystemRole = memo(() => {
15
15
  const [openModal, setOpenModal] = useState(false);
16
-
16
+ const [editing, setEditing] = useState(false);
17
17
  const { styles } = useStyles();
18
18
  const [systemRole, updateAgentConfig] = useSessionStore((s) => [
19
19
  agentSelectors.currentAgentSystemRole(s),
@@ -35,7 +35,16 @@ const SystemRole = memo(() => {
35
35
  }
36
36
  title={t('settingAgent.prompt.title', { ns: 'setting' })}
37
37
  />
38
- <Flexbox className={styles.promptBox} height={200}>
38
+ <Flexbox
39
+ className={styles.promptBox}
40
+ height={200}
41
+ onDoubleClick={(e) => {
42
+ if (e.altKey) {
43
+ setOpenModal(true);
44
+ setEditing(true);
45
+ }
46
+ }}
47
+ >
39
48
  {!init ? (
40
49
  <Skeleton
41
50
  active
@@ -47,9 +56,11 @@ const SystemRole = memo(() => {
47
56
  <>
48
57
  <EditableMessage
49
58
  classNames={{ markdown: styles.prompt }}
59
+ editing={editing}
50
60
  onChange={(e) => {
51
61
  updateAgentConfig({ systemRole: e });
52
62
  }}
63
+ onEditingChange={setEditing}
53
64
  onOpenChange={setOpenModal}
54
65
  openModal={openModal}
55
66
  placeholder={`${t('settingAgent.prompt.placeholder', { ns: 'setting' })}...`}
@@ -19,7 +19,7 @@ const DefaultContent = memo(() => {
19
19
  <Icon color={theme.colorTextDescription} icon={MessageSquareDashed} />
20
20
  </Flexbox>
21
21
  <Paragraph ellipsis={{ rows: 1 }} style={{ margin: 0 }}>
22
- {t('topic.defaultTitle')}
22
+ {t('topic.defaultTitle', { ns: 'chat' })}
23
23
  </Paragraph>
24
24
  <Tag>{t('temp')}</Tag>
25
25
  </Flexbox>
@@ -74,7 +74,7 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
74
74
  onOk: () => {
75
75
  removeTopic(id);
76
76
  },
77
- title: t('topic.confirmRemoveTopic'),
77
+ title: t('topic.confirmRemoveTopic', { ns: 'chat' }),
78
78
  });
79
79
  },
80
80
  },
@@ -83,7 +83,16 @@ const TopicContent = memo<TopicContentProps>(({ id, title, fav }) => {
83
83
  );
84
84
 
85
85
  return (
86
- <Flexbox align={'center'} gap={8} horizontal justify={'space-between'}>
86
+ <Flexbox
87
+ align={'center'}
88
+ gap={8}
89
+ horizontal
90
+ justify={'space-between'}
91
+ onDoubleClick={(e) => {
92
+ if (!id) return;
93
+ if (e.altKey) toggleEditing(true);
94
+ }}
95
+ >
87
96
  <ActionIcon
88
97
  color={fav ? theme.colorWarning : undefined}
89
98
  fill={fav ? theme.colorWarning : 'transparent'}
@@ -54,7 +54,7 @@ export const Topic = () => {
54
54
  <TopicItem
55
55
  active={!activeTopicId}
56
56
  fav={false}
57
- title={t('topic.defaultTitle', { ns: 'common' })}
57
+ title={t('topic.defaultTitle', { ns: 'chat' })}
58
58
  />
59
59
 
60
60
  {topicsData.map(({ id, favorite, title }) => (
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import { useSessionStore } from '@/store/session';
7
7
 
8
8
  const TopicSearchBar = memo(() => {
9
- const { t } = useTranslation('common');
9
+ const { t } = useTranslation('chat');
10
10
  const [keywords] = useSessionStore((s) => [s.topicSearchKeywords]);
11
11
  const { mobile } = useResponsive();
12
12
  return (
@@ -8,7 +8,6 @@ import PageTitle from '@/components/PageTitle';
8
8
  import AgentSetting from '@/features/AgentSetting';
9
9
  import { useSessionStore } from '@/store/session';
10
10
  import { agentSelectors } from '@/store/session/selectors';
11
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
12
11
 
13
12
  const EditPage = memo(() => {
14
13
  const { t } = useTranslation('setting');
@@ -20,11 +19,9 @@ const EditPage = memo(() => {
20
19
  agentSelectors.currentAgentTitle(s),
21
20
  ]);
22
21
 
23
- const pageTitle = genSiteHeadTitle(t('header.sessionWithName', { name: title }));
24
-
25
22
  return (
26
23
  <>
27
- <PageTitle title={pageTitle} />
24
+ <PageTitle title={t('header.sessionWithName', { name: title })} />
28
25
  <AgentSetting
29
26
  config={config}
30
27
  meta={meta}
@@ -5,9 +5,9 @@ import { useTranslation } from 'react-i18next';
5
5
  import FullscreenLoading from '@/components/FullscreenLoading';
6
6
 
7
7
  const Loading = () => {
8
- const { t } = useTranslation();
8
+ const { t } = useTranslation('common');
9
9
 
10
- return <FullscreenLoading title={t('appInitializing', { ns: 'common' })} />;
10
+ return <FullscreenLoading title={t('appInitializing')} />;
11
11
  };
12
12
 
13
13
  export default Loading;
@@ -5,13 +5,11 @@ import { useTranslation } from 'react-i18next';
5
5
 
6
6
  import PageTitle from '@/components/PageTitle';
7
7
  import { useMarketStore } from '@/store/market';
8
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
9
8
 
10
9
  import AgentSearchBar from './features/AgentSearchBar';
11
10
 
12
11
  const Market = memo(() => {
13
12
  const { t } = useTranslation('common');
14
- const pageTitle = genSiteHeadTitle(t('tab.market'));
15
13
 
16
14
  useEffect(() => {
17
15
  // refs: https://github.com/pmndrs/zustand/blob/main/docs/integrations/persisting-store-data.md#hashydrated
@@ -20,7 +18,7 @@ const Market = memo(() => {
20
18
 
21
19
  return (
22
20
  <>
23
- <PageTitle title={pageTitle} />
21
+ <PageTitle title={t('tab.market')} />
24
22
  <AgentSearchBar />
25
23
  </>
26
24
  );
@@ -1,10 +1,8 @@
1
1
  import { Metadata } from 'next';
2
2
 
3
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
4
-
5
3
  import pkg from '../../package.json';
6
4
 
7
- const title = genSiteHeadTitle();
5
+ const title = 'LobeChat';
8
6
  const { description, homepage } = pkg;
9
7
  const metadata: Metadata = {
10
8
  appleWebApp: {
@@ -6,17 +6,15 @@ import { useTranslation } from 'react-i18next';
6
6
  import PageTitle from '@/components/PageTitle';
7
7
  import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
8
8
  import { SettingsTabs } from '@/store/global/initialState';
9
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
10
9
 
11
10
  import Agent from './Agent';
12
11
 
13
12
  export default memo(() => {
14
13
  useSwitchSideBarOnInit(SettingsTabs.Agent);
15
14
  const { t } = useTranslation('setting');
16
- const pageTitle = genSiteHeadTitle(t('tab.agent'));
17
15
  return (
18
16
  <>
19
- <PageTitle title={pageTitle} />
17
+ <PageTitle title={t('tab.agent')} />
20
18
  <Agent />
21
19
  </>
22
20
  );
@@ -7,7 +7,6 @@ import PageTitle from '@/components/PageTitle';
7
7
  import { CURRENT_VERSION } from '@/const/version';
8
8
  import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
9
9
  import { SettingsTabs } from '@/store/global/initialState';
10
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
11
10
 
12
11
  import Footer from '../features/Footer';
13
12
  import Common from './Common';
@@ -15,11 +14,10 @@ import Common from './Common';
15
14
  export default memo(() => {
16
15
  useSwitchSideBarOnInit(SettingsTabs.Common);
17
16
  const { t } = useTranslation('setting');
18
- const pageTitle = genSiteHeadTitle(t('tab.common'));
19
17
 
20
18
  return (
21
19
  <>
22
- <PageTitle title={pageTitle} />
20
+ <PageTitle title={t('tab.common')} />
23
21
  <Common />
24
22
  <Footer>LobeChat v{CURRENT_VERSION}</Footer>
25
23
  </>
@@ -8,17 +8,15 @@ import Footer from '@/app/settings/features/Footer';
8
8
  import PageTitle from '@/components/PageTitle';
9
9
  import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
10
10
  import { SettingsTabs } from '@/store/global/initialState';
11
- import { genSiteHeadTitle } from '@/utils/genSiteHeadTitle';
12
11
 
13
12
  import LLM from './LLM';
14
13
 
15
14
  export default memo(() => {
16
15
  useSwitchSideBarOnInit(SettingsTabs.LLM);
17
16
  const { t } = useTranslation('setting');
18
- const pageTitle = genSiteHeadTitle(t('tab.llm'));
19
17
  return (
20
18
  <>
21
- <PageTitle title={pageTitle} />
19
+ <PageTitle title={t('tab.llm')} />
22
20
  <LLM />
23
21
  <Footer>
24
22
  <Trans i18nKey="llm.waitingForMore" ns={'setting'}>
@@ -0,0 +1,77 @@
1
+ import { chatHelpers } from '@/store/session/helpers';
2
+ import { LanguageModel } from '@/types/llm';
3
+ import { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat';
4
+
5
+ export const chainSummaryTitle = async (
6
+ messages: OpenAIChatMessage[],
7
+ ): Promise<Partial<OpenAIChatStreamPayload>> => {
8
+ const finalMessages: OpenAIChatMessage[] = [
9
+ {
10
+ content:
11
+ '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,不需要包含标点符号',
12
+ role: 'system',
13
+ },
14
+ {
15
+ content: `${messages.map((message) => `${message.role}: ${message.content}`).join('\n')}
16
+
17
+ 请总结上述对话为10个字以内的标题,不需要包含标点符号`,
18
+ role: 'user',
19
+ },
20
+ ];
21
+ // 如果超过 4k,则使用 GPT3.5 16K 模型
22
+ const tokens = await chatHelpers.getMessagesTokenCount(finalMessages);
23
+ let model: LanguageModel | undefined = undefined;
24
+ if (tokens > 4000) {
25
+ model = LanguageModel.GPT3_5_16K;
26
+ }
27
+
28
+ return {
29
+ messages: finalMessages,
30
+ model,
31
+ };
32
+ };
33
+
34
+ export const chainTranslate = (
35
+ content: string,
36
+ targetLang: string,
37
+ ): Partial<OpenAIChatStreamPayload> => ({
38
+ messages: [
39
+ {
40
+ content: '你是一名擅长翻译的助理,你需要将输入的语言翻译为目标语言',
41
+ role: 'system',
42
+ },
43
+ {
44
+ content: `请将以下内容 ${content},翻译为 ${targetLang} `,
45
+ role: 'user',
46
+ },
47
+ ],
48
+ });
49
+ export const chainLangDetect = (content: string): Partial<OpenAIChatStreamPayload> => ({
50
+ messages: [
51
+ {
52
+ content:
53
+ '你是一名精通全世界语言的语言专家,你需要识别用户输入的内容,以国际标准 locale 进行输出',
54
+ role: 'system',
55
+ },
56
+ {
57
+ content: '{你好}',
58
+ role: 'user',
59
+ },
60
+ {
61
+ content: 'zh-CN',
62
+ role: 'assistant',
63
+ },
64
+ {
65
+ content: '{hello}',
66
+ role: 'user',
67
+ },
68
+ {
69
+ content: 'en-US',
70
+ role: 'assistant',
71
+ },
72
+ {
73
+ content: `{${content}}`,
74
+ role: 'user',
75
+ },
76
+ ],
77
+ });
@@ -0,0 +1,57 @@
1
+ import { createStyles } from 'antd-style';
2
+ import { Fragment, memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+
5
+ const useStyles = createStyles(
6
+ ({ css, token }) => css`
7
+ font-size: 12px;
8
+
9
+ span {
10
+ font-weight: 600;
11
+ opacity: 0.5;
12
+ }
13
+
14
+ kbd {
15
+ padding: 3px 5px;
16
+
17
+ line-height: 1;
18
+ color: ${token.colorTextSecondary};
19
+
20
+ background: ${token.colorBgContainer};
21
+ border: 1px solid ${token.colorBorderSecondary};
22
+ border-bottom-color: ${token.colorBorder};
23
+ border-radius: ${token.borderRadius}px;
24
+ box-shadow: inset 0 -1px 0 ${token.colorBorder};
25
+ }
26
+ `,
27
+ );
28
+
29
+ export interface HotKeysProps {
30
+ desc?: string;
31
+ keys: string;
32
+ }
33
+
34
+ const HotKeys = memo<HotKeysProps>(({ keys, desc }) => {
35
+ const { styles } = useStyles();
36
+ const keysGroup = keys.split('+').filter(Boolean);
37
+ const content = (
38
+ <Flexbox align={'center'} className={styles} gap={2} horizontal>
39
+ {keysGroup.map((key, index) => (
40
+ <Fragment key={index}>
41
+ <kbd>{key.toUpperCase()}</kbd>
42
+ {index + 1 < keysGroup.length && <span>+</span>}
43
+ </Fragment>
44
+ ))}
45
+ </Flexbox>
46
+ );
47
+
48
+ if (!desc) return content;
49
+ return (
50
+ <Flexbox align={'center'} gap={8} horizontal>
51
+ {content}
52
+ {desc}
53
+ </Flexbox>
54
+ );
55
+ });
56
+
57
+ export default HotKeys;
@@ -2,7 +2,7 @@ import { memo, useEffect } from 'react';
2
2
 
3
3
  const PageTitle = memo<{ title: string }>(({ title }) => {
4
4
  useEffect(() => {
5
- document.title = title;
5
+ document.title = title ? `${title} · LobeChat` : 'LobeChat';
6
6
  }, [title]);
7
7
 
8
8
  return null;
@@ -0,0 +1,4 @@
1
+ export const PREFIX_KEY = 'alt';
2
+ export const SAVE_TOPIC_KEY = 'n';
3
+ export const CLEAN_MESSAGE_KEY = 'backspace';
4
+ export const REGENERATE_KEY = 'r';
@@ -42,9 +42,9 @@ const AgentPrompt = memo(() => {
42
42
  maxValue={ModelTokens[model as LanguageModel]}
43
43
  shape={'square'}
44
44
  text={{
45
- overload: t('tokenTag.overload', { ns: 'common' }),
46
- remained: t('tokenTag.remained', { ns: 'common' }),
47
- used: t('tokenTag.used', { ns: 'common' }),
45
+ overload: t('tokenTag.overload', { ns: 'chat' }),
46
+ remained: t('tokenTag.remained', { ns: 'chat' }),
47
+ used: t('tokenTag.used', { ns: 'chat' }),
48
48
  }}
49
49
  value={systemTokenCount}
50
50
  />
@@ -1,6 +1,6 @@
1
1
  import { StateCreator } from 'zustand/vanilla';
2
2
 
3
- import { promptPickEmoji, promptSummaryAgentName, promptSummaryDescription } from '@/prompts/agent';
3
+ import { promptPickEmoji, promptSummaryAgentName, promptSummaryDescription } from '@/chains/agent';
4
4
  import { MetaData } from '@/types/meta';
5
5
  import { LobeAgentConfig } from '@/types/session';
6
6
  import { fetchPresetTaskResult } from '@/utils/fetch';
@@ -15,10 +15,12 @@ const ResponsiveLayout = ({ children, Desktop, Mobile }: ServerResponsiveLayoutP
15
15
  const { t } = useTranslation();
16
16
  const mobile = useIsMobile();
17
17
 
18
- return (
18
+ return mobile ? (
19
19
  <Suspense fallback={<FullscreenLoading title={t('layoutInitializing', { ns: 'common' })} />}>
20
- {mobile ? <Mobile>{children}</Mobile> : <Desktop>{children}</Desktop>}
20
+ <Mobile>{children}</Mobile>
21
21
  </Suspense>
22
+ ) : (
23
+ <Desktop>{children}</Desktop>
22
24
  );
23
25
  };
24
26
 
@@ -4,10 +4,11 @@ import { initReactI18next } from 'react-i18next';
4
4
 
5
5
  import { getClientConfig } from '@/config/client';
6
6
  import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
7
- import resources from '@/locales/resources';
8
7
  import type { Namespaces } from '@/types/locale';
9
8
  import { isOnServerSide } from '@/utils/env';
10
9
 
10
+ import { resources } from './options';
11
+
11
12
  const { I18N_DEBUG, I18N_DEBUG_BROWSER, I18N_DEBUG_SERVER } = getClientConfig();
12
13
  const debugMode = I18N_DEBUG ?? isOnServerSide ? I18N_DEBUG_SERVER : I18N_DEBUG_BROWSER;
13
14
 
@@ -0,0 +1,60 @@
1
+ export default {
2
+ agentDefaultMessage:
3
+ '你好,我是 **{{name}}**,你可以立即与我开始对话,也可以前往 [助手设置](/chat/settings#session={{id}}) 完善我的信息。',
4
+ agentDefaultMessageWithSystemRole: '你好,我是 **{{name}}**,{{systemRole}},让我们开始对话吧!',
5
+ backToBottom: '查看最新消息',
6
+ clearCurrentMessages: '清空当前会话消息',
7
+ confirmClearCurrentMessages: '即将清空当前会话消息,清空后将无法找回,请确认你的操作',
8
+ confirmRemoveSessionItemAlert: '即将删除该助手,删除后该将无法找回,请确认你的操作',
9
+ defaultAgent: '自定义助手',
10
+ defaultSession: '自定义助手',
11
+ historyRange: '历史范围',
12
+ inbox: {
13
+ defaultMessage:
14
+ '你好,我是你的智能助手,你可以问我任何问题,我会尽力回答你。如果需要获得更加专业或定制的助手,可以点击`+`创建自定义助手',
15
+ desc: '开启大脑集群,激发思维火花。你的智能助理,在这里与你交流一切',
16
+ title: '随便聊聊',
17
+ },
18
+ newAgent: '新建助手',
19
+ noDescription: '暂无描述',
20
+
21
+ regenerate: '重新生成',
22
+
23
+ roleAndArchive: '角色与记录',
24
+ searchAgentPlaceholder: '搜索助手和对话...',
25
+ send: '发送',
26
+ sendPlaceholder: '输入聊天内容...',
27
+ shareModal: {
28
+ download: '下载截图',
29
+ imageType: '图片格式',
30
+ screenshot: '截图',
31
+ settings: '导出设置',
32
+ shareToShareGPT: '生成 ShareGPT 分享链接',
33
+ withBackground: '包含背景图片',
34
+ withFooter: '包含页脚',
35
+ withPluginInfo: '包含插件信息',
36
+ withSystemRole: '包含助手角色设定',
37
+ },
38
+ stop: '停止',
39
+
40
+ temp: '临时',
41
+ tokenDetail: '角色设定: {{systemRoleToken}} · 历史消息: {{chatsToken}}',
42
+ tokenTag: {
43
+ overload: '超过限制',
44
+ remained: '剩余',
45
+ used: '使用',
46
+ },
47
+ topic: {
48
+ confirmRemoveTopic: '即将删除该话题,删除后将不可恢复,请谨慎操作。',
49
+ defaultTitle: '默认话题',
50
+ saveCurrentMessages: '将当前会话保存为话题',
51
+ searchPlaceholder: '搜索话题...',
52
+ title: '话题',
53
+ },
54
+ translate: {
55
+ clear: '删除翻译',
56
+ },
57
+ translateTo: '翻译',
58
+ updateAgent: '更新助理信息',
59
+ warp: '换行',
60
+ };
@@ -1,9 +1,6 @@
1
1
  export default {
2
2
  about: '关于',
3
3
  advanceSettings: '高级设置',
4
- agentDefaultMessage:
5
- '你好,我是 **{{name}}**,你可以立即与我开始对话,也可以前往 [助手设置](/chat/settings#session={{id}}) 完善我的信息。',
6
- agentDefaultMessageWithSystemRole: '你好,我是 **{{name}}**,{{systemRole}},让我们开始对话吧!',
7
4
  agentMaxToken: '会话最大长度',
8
5
  agentModel: '模型',
9
6
  agentProfile: '助手信息',
@@ -11,12 +8,9 @@ export default {
11
8
  archive: '归档',
12
9
  autoGenerate: '自动补全',
13
10
  autoGenerateTooltip: '基于提示词自动补全助手描述',
14
- backToBottom: '查看最新消息',
15
11
  cancel: '取消',
16
12
  changelog: '更新日志',
17
- clearCurrentMessages: '清空当前会话消息',
18
13
  close: '关闭',
19
- confirmClearCurrentMessages: '即将清空当前会话消息,清空后将无法找回,请确认你的操作',
20
14
  confirmRemoveSessionItemAlert: '即将删除该助手,删除后该将无法找回,请确认你的操作',
21
15
  copy: '复制',
22
16
  copySuccess: '复制成功',
@@ -37,18 +31,17 @@ export default {
37
31
  historyRange: '历史范围',
38
32
  import: '导入配置',
39
33
 
40
- inbox: {
41
- defaultMessage:
42
- '你好,我是你的智能助手,你可以问我任何问题,我会尽力回答你。如果需要获得更加专业或定制的助手,可以点击`+`创建自定义助手',
43
- desc: '开启大脑集群,激发思维火花。你的智能助理,在这里与你交流一切',
44
- title: '随便聊聊',
34
+ lang: {
35
+ 'en': '英语',
36
+ 'en-US': '英语',
37
+ 'ja-JP': '日语',
38
+ 'ko-KR': '韩语',
39
+ 'ru-RU': '俄语',
40
+ 'zh': '简体中文',
41
+ 'zh-CN': '简体中文',
42
+ 'zh-TW': '繁体中文',
45
43
  },
46
44
  layoutInitializing: '正在加载布局...',
47
- message: {
48
- function_loading: '插件请求中...',
49
- },
50
- moreSetting: '更多设置...',
51
- newAgent: '新建助手',
52
45
  noDescription: '暂无描述',
53
46
  ok: '确定',
54
47
  password: '密码',
@@ -58,24 +51,10 @@ export default {
58
51
  rename: '重命名',
59
52
  reset: '重置',
60
53
  retry: '重试',
61
- roleAndArchive: '角色与记录',
62
- searchAgentPlaceholder: '搜索助手和对话...',
63
54
  send: '发送',
64
- sendPlaceholder: '输入聊天内容...',
65
55
  sessionList: '助手列表',
66
56
  setting: '设置',
67
57
  share: '分享',
68
- shareModal: {
69
- download: '下载截图',
70
- imageType: '图片格式',
71
- screenshot: '截图',
72
- settings: '导出设置',
73
- shareToShareGPT: '生成 ShareGPT 分享链接',
74
- withBackground: '包含背景图片',
75
- withFooter: '包含页脚',
76
- withPluginInfo: '包含插件信息',
77
- withSystemRole: '包含助手角色设定',
78
- },
79
58
  stop: '停止',
80
59
  tab: {
81
60
  chat: '会话',
@@ -83,25 +62,11 @@ export default {
83
62
  setting: '设置',
84
63
  },
85
64
  temp: '临时',
86
- tokenDetail: '角色设定: {{systemRoleToken}} · 历史消息: {{chatsToken}}',
87
- tokenTag: {
88
- overload: '超过限制',
89
- remained: '剩余',
90
- used: '使用',
91
- },
92
- topic: {
93
- confirmRemoveTopic: '即将删除该话题,删除后将不可恢复,请谨慎操作。',
94
- defaultTitle: '默认话题',
95
- saveCurrentMessages: '将当前会话保存为话题',
96
- searchPlaceholder: '搜索话题...',
97
- title: '话题',
98
- },
65
+
99
66
  updateAgent: '更新助理信息',
100
- updatePrompt: '更新提示词',
101
67
  upgradeVersion: {
102
68
  action: '立即升级',
103
69
  hasNew: '有可用更新',
104
70
  newVersion: '有新版本可用:{{version}}',
105
71
  },
106
- warp: '换行',
107
72
  };
@@ -1,5 +1,7 @@
1
1
  import type { Locales } from '@/types/locale';
2
2
 
3
+ import _resources from './resources';
4
+
3
5
  type LocaleOptions = {
4
6
  label: string;
5
7
  value: Locales;
@@ -33,3 +35,11 @@ export const localeOptions: LocaleOptions = [
33
35
  ] as LocaleOptions;
34
36
 
35
37
  export const supportLangs: string[] = localeOptions.map((i) => i.value);
38
+
39
+ export const resources = {
40
+ ..._resources,
41
+ en: _resources['en-US'],
42
+ zh: _resources['zh-CN'],
43
+ };
44
+
45
+ export const supportLocales = Object.keys(resources);
@@ -1,3 +1,4 @@
1
+ import chat from '../../../locales/en_US/chat.json';
1
2
  import common from '../../../locales/en_US/common.json';
2
3
  import empty from '../../../locales/en_US/empty.json';
3
4
  import error from '../../../locales/en_US/error.json';
@@ -7,6 +8,7 @@ import setting from '../../../locales/en_US/setting.json';
7
8
  import welcome from '../../../locales/en_US/welcome.json';
8
9
 
9
10
  const resources = {
11
+ chat,
10
12
  common,
11
13
  empty,
12
14
  error,
@@ -10,10 +10,10 @@ const resources = {
10
10
  'ja-JP': ja_JP,
11
11
  'ko-KR': ko_KR,
12
12
  'ru-RU': ru_RU,
13
- 'zh': zh_CN,
14
13
  'zh-CN': zh_CN,
15
14
  'zh-TW': zh_TW,
16
15
  } as const;
16
+
17
17
  export default resources;
18
18
  export const defaultResources = zh_CN;
19
19
  export type Resources = typeof resources;
@@ -1,3 +1,4 @@
1
+ import chat from '../../../locales/ja_JP/chat.json';
1
2
  import common from '../../../locales/ja_JP/common.json';
2
3
  import empty from '../../../locales/ja_JP/empty.json';
3
4
  import error from '../../../locales/ja_JP/error.json';
@@ -7,6 +8,7 @@ import setting from '../../../locales/ja_JP/setting.json';
7
8
  import welcome from '../../../locales/ja_JP/welcome.json';
8
9
 
9
10
  const resources = {
11
+ chat,
10
12
  common,
11
13
  empty,
12
14
  error,