@lobehub/chat 0.14.0 → 0.15.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 (46) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/locales/en_US/common.json +19 -27
  3. package/locales/en_US/plugin.json +10 -0
  4. package/locales/en_US/setting.json +42 -6
  5. package/locales/zh_CN/common.json +8 -17
  6. package/locales/zh_CN/plugin.json +10 -0
  7. package/locales/zh_CN/setting.json +36 -0
  8. package/package.json +1 -1
  9. package/src/components/HeaderSpacing/index.tsx +3 -1
  10. package/src/components/HeaderTitle/index.tsx +42 -0
  11. package/src/const/layoutTokens.ts +6 -1
  12. package/src/const/meta.ts +3 -0
  13. package/src/locales/default/common.ts +31 -51
  14. package/src/locales/default/plugin.ts +10 -0
  15. package/src/locales/default/setting.ts +46 -1
  16. package/src/locales/resources/en_US.ts +2 -0
  17. package/src/locales/resources/zh_CN.ts +2 -0
  18. package/src/pages/chat/SessionList/List/SessionItem.tsx +1 -2
  19. package/src/pages/chat/[id]/Config/Header.tsx +26 -0
  20. package/src/pages/chat/[id]/Config/SideBar.tsx +86 -0
  21. package/src/pages/chat/[id]/Config/index.tsx +5 -45
  22. package/src/pages/chat/[id]/Conversation/FunctionMessage.tsx +1 -1
  23. package/src/pages/chat/[id]/Conversation/Input/Action.tsx +13 -5
  24. package/src/pages/chat/[id]/Conversation/Input/index.tsx +11 -3
  25. package/src/pages/chat/[id]/Header.tsx +34 -43
  26. package/src/pages/chat/[id]/edit/AgentConfig/index.tsx +154 -95
  27. package/src/pages/chat/[id]/edit/AgentMeta/AutoGenerateInput.tsx +39 -0
  28. package/src/pages/chat/[id]/edit/AgentMeta/BackgroundSwatches.tsx +31 -0
  29. package/src/pages/chat/[id]/edit/AgentMeta/EmojiPicker.tsx +7 -3
  30. package/src/pages/chat/[id]/edit/AgentMeta/index.tsx +68 -75
  31. package/src/pages/chat/[id]/edit/AgentPlugin/index.tsx +44 -0
  32. package/src/pages/chat/[id]/edit/AgentPrompt/index.tsx +48 -0
  33. package/src/pages/chat/[id]/edit/Header.tsx +31 -0
  34. package/src/pages/chat/[id]/edit/index.page.tsx +12 -40
  35. package/src/pages/chat/[id]/index.page.tsx +2 -1
  36. package/src/pages/setting/Header.tsx +4 -11
  37. package/src/pages/setting/SettingForm.tsx +9 -9
  38. package/src/pages/setting/index.page.tsx +2 -1
  39. package/src/store/session/slices/agentConfig/initialState.ts +1 -5
  40. package/src/store/session/slices/agentConfig/selectors.ts +15 -5
  41. package/src/store/session/slices/chat/selectors/chat.ts +2 -2
  42. package/src/store/session/slices/session/selectors/chat.ts +1 -1
  43. package/src/utils/genSiteHeadTitle.ts +1 -0
  44. package/src/pages/chat/[id]/Config/ReadMode.tsx +0 -64
  45. package/src/pages/chat/[id]/edit/AgentConfig/Plugin.tsx +0 -46
  46. package/src/pages/chat/[id]/edit/AgentConfig/Prompt.tsx +0 -69
@@ -1,4 +1,4 @@
1
- import { DEFAULT_AVATAR } from '@/store/session/slices/agentConfig';
1
+ import { DEFAULT_AVATAR } from '@/const/meta';
2
2
  import { MetaData } from '@/types/meta';
3
3
 
4
4
  export const getAgentAvatar = (s: MetaData) => s.avatar || DEFAULT_AVATAR;
@@ -0,0 +1 @@
1
+ export const genSiteHeadTitle = (title?: string) => (title ? `${title} - LobeChat` : 'LobeChat');
@@ -1,64 +0,0 @@
1
- import { Avatar } from '@lobehub/ui';
2
- import { createStyles } from 'antd-style';
3
- import isEqual from 'fast-deep-equal';
4
- import { LucideBrain, LucideThermometer, WholeWord } from 'lucide-react';
5
- import { memo } from 'react';
6
- import { useTranslation } from 'react-i18next';
7
- import { Center, Flexbox } from 'react-layout-kit';
8
- import { shallow } from 'zustand/shallow';
9
-
10
- import { agentSelectors, sessionSelectors, useSessionStore } from '@/store/session';
11
- import { DEFAULT_TITLE } from '@/store/session/slices/agentConfig';
12
-
13
- import { ConfigCell, ConfigCellGroup } from './ConfigCell';
14
-
15
- const useStyles = createStyles(({ css, token }) => ({
16
- desc: css`
17
- color: ${token.colorText};
18
- `,
19
- model: css`
20
- color: ${token.colorTextTertiary};
21
- `,
22
- title: css`
23
- font-size: ${token.fontSizeHeading4}px;
24
- font-weight: bold;
25
- `,
26
- }));
27
-
28
- const ReadMode = memo(() => {
29
- const { styles } = useStyles();
30
- const session = useSessionStore(sessionSelectors.currentSessionSafe, isEqual);
31
- const avatar = useSessionStore(agentSelectors.currentAgentAvatar, shallow);
32
- const title = useSessionStore(agentSelectors.currentAgentTitle, shallow);
33
- const model = useSessionStore(agentSelectors.currentAgentModel, shallow);
34
-
35
- const { t } = useTranslation('common');
36
- return (
37
- <Center gap={12} paddingBlock={16} style={{ marginTop: 8 }}>
38
- <Avatar avatar={avatar} size={100} />
39
- <Flexbox className={styles.title}>{title || DEFAULT_TITLE}</Flexbox>
40
- <Flexbox className={styles.model}>{model}</Flexbox>
41
- <Flexbox className={styles.desc}>{session.meta.description}</Flexbox>
42
-
43
- <Flexbox flex={1} gap={12} width={'100%'}>
44
- <ConfigCell icon={LucideBrain} label={t('agentPrompt')} />
45
- <ConfigCellGroup
46
- items={[
47
- {
48
- icon: LucideThermometer,
49
- label: t('modelTemperature'),
50
- value: session.config.params.temperature,
51
- },
52
- {
53
- icon: WholeWord,
54
- label: t('agentMaxToken'),
55
- value: session.config.params.max_tokens,
56
- },
57
- ]}
58
- />
59
- </Flexbox>
60
- </Center>
61
- );
62
- });
63
-
64
- export default ReadMode;
@@ -1,46 +0,0 @@
1
- import { Avatar } from '@lobehub/ui';
2
- import { List, Switch, Tag } from 'antd';
3
- import isEqual from 'fast-deep-equal';
4
- import { useTranslation } from 'react-i18next';
5
- import { Flexbox } from 'react-layout-kit';
6
- import { shallow } from 'zustand/shallow';
7
-
8
- import pluginList from '@/plugins';
9
- import { agentSelectors, useSessionStore } from '@/store/session';
10
-
11
- const PluginList = () => {
12
- const { t } = useTranslation('common');
13
-
14
- const config = useSessionStore(agentSelectors.currentAgentConfigSafe, isEqual);
15
-
16
- const [toggleAgentPlugin] = useSessionStore((s) => [s.toggleAgentPlugin], shallow);
17
-
18
- return (
19
- <List
20
- bordered
21
- dataSource={pluginList}
22
- renderItem={(item) => (
23
- <List.Item>
24
- <List.Item.Meta
25
- avatar={<Avatar avatar={item.avatar} />}
26
- description={item.schema.description}
27
- title={
28
- <Flexbox align={'center'} gap={8} horizontal>
29
- {t(`plugin-${item.name}` as any)} <Tag>{item.name}</Tag>
30
- </Flexbox>
31
- }
32
- />
33
- <Switch
34
- checked={!config.plugins ? false : config.plugins.includes(item.name)}
35
- onChange={() => {
36
- toggleAgentPlugin(item.name);
37
- }}
38
- />
39
- </List.Item>
40
- )}
41
- size={'large'}
42
- />
43
- );
44
- };
45
-
46
- export default PluginList;
@@ -1,69 +0,0 @@
1
- import { EditableMessage } from '@lobehub/ui';
2
- import { Button } from 'antd';
3
- import { createStyles } from 'antd-style';
4
- import { useState } from 'react';
5
- import { useTranslation } from 'react-i18next';
6
- import { Flexbox } from 'react-layout-kit';
7
- import { shallow } from 'zustand/shallow';
8
-
9
- import { agentSelectors, useSessionStore } from '@/store/session';
10
-
11
- import { FormItem } from '../FormItem';
12
-
13
- export const useStyles = createStyles(({ css, token }) => ({
14
- input: css`
15
- padding: 12px;
16
- background: ${token.colorFillTertiary};
17
- border: 1px solid ${token.colorPrimaryBorder};
18
- border-radius: 8px;
19
- `,
20
- markdown: css`
21
- padding: 12px;
22
- background: ${token.colorFillTertiary};
23
- `,
24
- }));
25
-
26
- const Prompt = () => {
27
- const { t } = useTranslation('common');
28
-
29
- const [editing, setEditing] = useState(false);
30
- const { styles } = useStyles();
31
-
32
- const systemRole = useSessionStore((s) => {
33
- const config = agentSelectors.currentAgentConfigSafe(s);
34
- return config.systemRole;
35
- }, shallow);
36
-
37
- const [updateAgentConfig] = useSessionStore((s) => [s.updateAgentConfig], shallow);
38
-
39
- return (
40
- <FormItem label={t('agentPrompt')}>
41
- <Flexbox gap={16}>
42
- <EditableMessage
43
- classNames={styles}
44
- editing={editing}
45
- onChange={(e) => {
46
- updateAgentConfig({ systemRole: e });
47
- }}
48
- onEditingChange={setEditing}
49
- showEditWhenEmpty
50
- value={systemRole}
51
- />
52
- {!editing && !!systemRole && (
53
- <Flexbox direction={'horizontal-reverse'}>
54
- <Button
55
- onClick={() => {
56
- setEditing(true);
57
- }}
58
- type={'primary'}
59
- >
60
- {t('edit')}
61
- </Button>
62
- </Flexbox>
63
- )}
64
- </Flexbox>
65
- </FormItem>
66
- );
67
- };
68
-
69
- export default Prompt;