@lobehub/chat 1.27.3 → 1.28.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.
- package/CHANGELOG.md +50 -0
- package/locales/ar/chat.json +7 -1
- package/locales/ar/models.json +3 -0
- package/locales/bg-BG/chat.json +7 -1
- package/locales/bg-BG/models.json +3 -0
- package/locales/de-DE/chat.json +7 -1
- package/locales/de-DE/models.json +3 -0
- package/locales/en-US/chat.json +7 -1
- package/locales/en-US/models.json +3 -0
- package/locales/es-ES/chat.json +7 -1
- package/locales/es-ES/models.json +3 -0
- package/locales/fa-IR/chat.json +7 -1
- package/locales/fa-IR/models.json +3 -0
- package/locales/fr-FR/chat.json +7 -1
- package/locales/fr-FR/models.json +3 -0
- package/locales/it-IT/chat.json +7 -1
- package/locales/it-IT/models.json +3 -0
- package/locales/ja-JP/chat.json +7 -1
- package/locales/ja-JP/models.json +3 -0
- package/locales/ko-KR/chat.json +7 -1
- package/locales/ko-KR/models.json +3 -0
- package/locales/nl-NL/chat.json +7 -1
- package/locales/nl-NL/models.json +3 -0
- package/locales/pl-PL/chat.json +7 -1
- package/locales/pl-PL/models.json +3 -0
- package/locales/pt-BR/chat.json +7 -1
- package/locales/pt-BR/models.json +3 -0
- package/locales/ru-RU/chat.json +7 -1
- package/locales/ru-RU/models.json +3 -0
- package/locales/tr-TR/chat.json +7 -1
- package/locales/tr-TR/models.json +3 -0
- package/locales/vi-VN/chat.json +7 -1
- package/locales/vi-VN/models.json +3 -0
- package/locales/zh-CN/chat.json +7 -1
- package/locales/zh-CN/models.json +3 -0
- package/locales/zh-TW/chat.json +7 -1
- package/locales/zh-TW/models.json +3 -0
- package/package.json +1 -1
- package/src/app/(main)/chat/(workspace)/features/ShareButton/index.tsx +2 -1
- package/src/database/server/migrations/0010_add_accessed_at_and_clean_tables.sql +26 -0
- package/src/database/server/migrations/meta/0010_snapshot.json +3184 -0
- package/src/database/server/migrations/meta/_journal.json +7 -0
- package/src/database/server/models/__tests__/session.test.ts +0 -2
- package/src/database/server/models/__tests__/topic.test.ts +2 -0
- package/src/database/server/schemas/lobechat/_helpers.ts +8 -0
- package/src/database/server/schemas/lobechat/agent.ts +6 -7
- package/src/database/server/schemas/lobechat/asyncTask.ts +2 -3
- package/src/database/server/schemas/lobechat/file.ts +5 -5
- package/src/database/server/schemas/lobechat/index.ts +0 -1
- package/src/database/server/schemas/lobechat/message.ts +2 -3
- package/src/database/server/schemas/lobechat/rag.ts +4 -6
- package/src/database/server/schemas/lobechat/ragEvals.ts +5 -7
- package/src/database/server/schemas/lobechat/relations.ts +0 -33
- package/src/database/server/schemas/lobechat/session.ts +3 -5
- package/src/database/server/schemas/lobechat/topic.ts +7 -8
- package/src/database/server/schemas/lobechat/user.ts +3 -5
- package/src/{app/(main)/chat/(workspace)/features/ShareButton → features/ShareModal/ShareImage}/Preview.tsx +5 -3
- package/src/features/ShareModal/ShareImage/index.tsx +103 -0
- package/src/{app/(main)/chat/(workspace)/features/ShareButton → features/ShareModal/ShareImage}/style.ts +1 -23
- package/src/features/ShareModal/ShareJSON/Preview.tsx +18 -0
- package/src/features/ShareModal/ShareJSON/generateMessages.test.ts +135 -0
- package/src/features/ShareModal/ShareJSON/generateMessages.ts +35 -0
- package/src/features/ShareModal/ShareJSON/index.tsx +99 -0
- package/src/features/ShareModal/ShareJSON/type.ts +4 -0
- package/src/features/ShareModal/ShareText/Preview.tsx +16 -0
- package/src/features/ShareModal/ShareText/index.tsx +119 -0
- package/src/features/ShareModal/ShareText/template.test.ts +178 -0
- package/src/features/ShareModal/ShareText/template.ts +79 -0
- package/src/features/ShareModal/ShareText/type.ts +6 -0
- package/src/features/ShareModal/index.tsx +69 -0
- package/src/features/ShareModal/style.ts +30 -0
- package/src/locales/default/chat.ts +7 -1
- package/src/services/__tests__/share.test.ts +35 -105
- package/src/services/share.ts +0 -30
- package/src/store/chat/slices/share/action.test.ts +7 -198
- package/src/store/chat/slices/share/action.ts +9 -113
- package/src/utils/client/exportFile.ts +20 -0
- package/src/app/(main)/chat/(workspace)/features/ShareButton/ShareModal.tsx +0 -164
- package/src/database/server/schemas/lobechat/discover.ts +0 -84
- /package/src/{app/(main)/chat/(workspace)/features/ShareButton → features/ShareModal/ShareImage}/type.ts +0 -0
- /package/src/{app/(main)/chat/(workspace)/features/ShareButton → features/ShareModal/ShareImage}/useScreenshot.ts +0 -0
@@ -1,164 +0,0 @@
|
|
1
|
-
import { Form, type FormItemProps, Modal, type ModalProps } from '@lobehub/ui';
|
2
|
-
import { Button, Segmented, SegmentedProps, Switch } from 'antd';
|
3
|
-
import { memo, useMemo, useState } from 'react';
|
4
|
-
import { useTranslation } from 'react-i18next';
|
5
|
-
import { Flexbox } from 'react-layout-kit';
|
6
|
-
|
7
|
-
import { FORM_STYLE } from '@/const/layoutTokens';
|
8
|
-
import { useChatStore } from '@/store/chat';
|
9
|
-
import { useUserStore } from '@/store/user';
|
10
|
-
import { userProfileSelectors } from '@/store/user/selectors';
|
11
|
-
|
12
|
-
import Preview from './Preview';
|
13
|
-
import { FieldType, ImageType } from './type';
|
14
|
-
import { useScreenshot } from './useScreenshot';
|
15
|
-
|
16
|
-
enum Tab {
|
17
|
-
Screenshot = 'screenshot',
|
18
|
-
ShareGPT = 'sharegpt',
|
19
|
-
}
|
20
|
-
|
21
|
-
export const imageTypeOptions: SegmentedProps['options'] = [
|
22
|
-
{
|
23
|
-
label: 'JPG',
|
24
|
-
value: ImageType.JPG,
|
25
|
-
},
|
26
|
-
{
|
27
|
-
label: 'PNG',
|
28
|
-
value: ImageType.PNG,
|
29
|
-
},
|
30
|
-
{
|
31
|
-
label: 'SVG',
|
32
|
-
value: ImageType.SVG,
|
33
|
-
},
|
34
|
-
{
|
35
|
-
label: 'WEBP',
|
36
|
-
value: ImageType.WEBP,
|
37
|
-
},
|
38
|
-
];
|
39
|
-
|
40
|
-
const DEFAULT_FIELD_VALUE: FieldType = {
|
41
|
-
imageType: ImageType.JPG,
|
42
|
-
withBackground: true,
|
43
|
-
withFooter: false,
|
44
|
-
withPluginInfo: false,
|
45
|
-
withSystemRole: false,
|
46
|
-
};
|
47
|
-
|
48
|
-
const ShareModal = memo<ModalProps>(({ onCancel, open }) => {
|
49
|
-
const [fieldValue, setFieldValue] = useState<FieldType>(DEFAULT_FIELD_VALUE);
|
50
|
-
const [tab, setTab] = useState<Tab>(Tab.Screenshot);
|
51
|
-
const { t } = useTranslation('chat');
|
52
|
-
const avatar = useUserStore(userProfileSelectors.userAvatar);
|
53
|
-
const [shareLoading, shareToShareGPT] = useChatStore((s) => [s.shareLoading, s.shareToShareGPT]);
|
54
|
-
const { loading, onDownload, title } = useScreenshot(fieldValue.imageType);
|
55
|
-
|
56
|
-
const options: SegmentedProps['options'] = useMemo(
|
57
|
-
() => [
|
58
|
-
{
|
59
|
-
label: t('shareModal.screenshot'),
|
60
|
-
value: Tab.Screenshot,
|
61
|
-
},
|
62
|
-
{
|
63
|
-
label: 'ShareGPT',
|
64
|
-
value: Tab.ShareGPT,
|
65
|
-
},
|
66
|
-
],
|
67
|
-
[],
|
68
|
-
);
|
69
|
-
|
70
|
-
const settings: FormItemProps[] = useMemo(
|
71
|
-
() => [
|
72
|
-
{
|
73
|
-
children: <Switch />,
|
74
|
-
label: t('shareModal.withSystemRole'),
|
75
|
-
minWidth: undefined,
|
76
|
-
name: 'withSystemRole',
|
77
|
-
valuePropName: 'checked',
|
78
|
-
},
|
79
|
-
{
|
80
|
-
children: <Switch />,
|
81
|
-
hidden: tab !== Tab.Screenshot,
|
82
|
-
label: t('shareModal.withBackground'),
|
83
|
-
minWidth: undefined,
|
84
|
-
name: 'withBackground',
|
85
|
-
valuePropName: 'checked',
|
86
|
-
},
|
87
|
-
{
|
88
|
-
children: <Switch />,
|
89
|
-
hidden: tab !== Tab.Screenshot,
|
90
|
-
label: t('shareModal.withFooter'),
|
91
|
-
minWidth: undefined,
|
92
|
-
name: 'withFooter',
|
93
|
-
valuePropName: 'checked',
|
94
|
-
},
|
95
|
-
{
|
96
|
-
children: <Segmented options={imageTypeOptions} />,
|
97
|
-
hidden: tab !== Tab.Screenshot,
|
98
|
-
label: t('shareModal.imageType'),
|
99
|
-
minWidth: undefined,
|
100
|
-
name: 'imageType',
|
101
|
-
},
|
102
|
-
{
|
103
|
-
children: <Switch />,
|
104
|
-
hidden: tab !== Tab.ShareGPT,
|
105
|
-
label: t('shareModal.withPluginInfo'),
|
106
|
-
minWidth: undefined,
|
107
|
-
name: 'withPluginInfo',
|
108
|
-
valuePropName: 'checked',
|
109
|
-
},
|
110
|
-
],
|
111
|
-
[tab],
|
112
|
-
);
|
113
|
-
|
114
|
-
return (
|
115
|
-
<Modal
|
116
|
-
allowFullscreen
|
117
|
-
centered={false}
|
118
|
-
footer={
|
119
|
-
<>
|
120
|
-
{tab === Tab.Screenshot && (
|
121
|
-
<Button block loading={loading} onClick={onDownload} size={'large'} type={'primary'}>
|
122
|
-
{t('shareModal.download')}
|
123
|
-
</Button>
|
124
|
-
)}
|
125
|
-
{tab === Tab.ShareGPT && (
|
126
|
-
<Button
|
127
|
-
block
|
128
|
-
loading={shareLoading}
|
129
|
-
onClick={() => shareToShareGPT({ avatar, ...fieldValue })}
|
130
|
-
size={'large'}
|
131
|
-
type={'primary'}
|
132
|
-
>
|
133
|
-
{t('shareModal.shareToShareGPT')}
|
134
|
-
</Button>
|
135
|
-
)}
|
136
|
-
</>
|
137
|
-
}
|
138
|
-
maxHeight={false}
|
139
|
-
onCancel={onCancel}
|
140
|
-
open={open}
|
141
|
-
title={t('share', { ns: 'common' })}
|
142
|
-
>
|
143
|
-
<Flexbox gap={16}>
|
144
|
-
<Segmented
|
145
|
-
block
|
146
|
-
onChange={(value) => setTab(value as Tab)}
|
147
|
-
options={options}
|
148
|
-
style={{ width: '100%' }}
|
149
|
-
value={tab}
|
150
|
-
/>
|
151
|
-
{tab === Tab.Screenshot && <Preview title={title} {...fieldValue} />}
|
152
|
-
<Form
|
153
|
-
initialValues={DEFAULT_FIELD_VALUE}
|
154
|
-
items={settings}
|
155
|
-
itemsType={'flat'}
|
156
|
-
onValuesChange={(_, v) => setFieldValue(v)}
|
157
|
-
{...FORM_STYLE}
|
158
|
-
/>
|
159
|
-
</Flexbox>
|
160
|
-
</Modal>
|
161
|
-
);
|
162
|
-
});
|
163
|
-
|
164
|
-
export default ShareModal;
|
@@ -1,84 +0,0 @@
|
|
1
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
2
|
-
import { integer, pgTable, primaryKey, serial, text } from 'drizzle-orm/pg-core';
|
3
|
-
|
4
|
-
import { createdAt, updatedAt } from './_helpers';
|
5
|
-
import { agents } from './agent';
|
6
|
-
import { users } from './user';
|
7
|
-
|
8
|
-
export const tags = pgTable('tags', {
|
9
|
-
id: serial('id').primaryKey(),
|
10
|
-
slug: text('slug').notNull().unique(),
|
11
|
-
name: text('name'),
|
12
|
-
|
13
|
-
userId: text('user_id')
|
14
|
-
.references(() => users.id, { onDelete: 'cascade' })
|
15
|
-
.notNull(),
|
16
|
-
|
17
|
-
createdAt: createdAt(),
|
18
|
-
updatedAt: updatedAt(),
|
19
|
-
});
|
20
|
-
|
21
|
-
export const plugins = pgTable('plugins', {
|
22
|
-
id: serial('id').primaryKey(),
|
23
|
-
identifier: text('identifier').notNull().unique(),
|
24
|
-
|
25
|
-
title: text('title').notNull(),
|
26
|
-
description: text('description'),
|
27
|
-
avatar: text('avatar'),
|
28
|
-
author: text('author'),
|
29
|
-
|
30
|
-
manifest: text('manifest').notNull(),
|
31
|
-
locale: text('locale').notNull(),
|
32
|
-
createdAt: createdAt(),
|
33
|
-
updatedAt: updatedAt(),
|
34
|
-
});
|
35
|
-
|
36
|
-
export const pluginsTags = pgTable(
|
37
|
-
'plugins_tags',
|
38
|
-
{
|
39
|
-
pluginId: integer('plugin_id')
|
40
|
-
.notNull()
|
41
|
-
.references(() => plugins.id, { onDelete: 'cascade' }),
|
42
|
-
tagId: integer('tag_id')
|
43
|
-
.notNull()
|
44
|
-
.references(() => tags.id, { onDelete: 'cascade' }),
|
45
|
-
},
|
46
|
-
(t) => ({
|
47
|
-
pk: primaryKey({ columns: [t.pluginId, t.tagId] }),
|
48
|
-
}),
|
49
|
-
);
|
50
|
-
|
51
|
-
export const agentsTags = pgTable(
|
52
|
-
'agents_tags',
|
53
|
-
{
|
54
|
-
agentId: text('agent_id')
|
55
|
-
.notNull()
|
56
|
-
.references(() => agents.id, { onDelete: 'cascade' }),
|
57
|
-
tagId: integer('tag_id')
|
58
|
-
.notNull()
|
59
|
-
.references(() => tags.id, { onDelete: 'cascade' }),
|
60
|
-
},
|
61
|
-
(t) => ({
|
62
|
-
pk: primaryKey({ columns: [t.agentId, t.tagId] }),
|
63
|
-
}),
|
64
|
-
);
|
65
|
-
|
66
|
-
export const market = pgTable('market', {
|
67
|
-
id: serial('id').primaryKey(),
|
68
|
-
|
69
|
-
agentId: text('agent_id').references(() => agents.id, { onDelete: 'cascade' }),
|
70
|
-
pluginId: integer('plugin_id').references(() => plugins.id, { onDelete: 'cascade' }),
|
71
|
-
|
72
|
-
type: text('type', { enum: ['plugin', 'model', 'agent', 'group'] }).notNull(),
|
73
|
-
|
74
|
-
view: integer('view').default(0),
|
75
|
-
like: integer('like').default(0),
|
76
|
-
used: integer('used').default(0),
|
77
|
-
|
78
|
-
userId: text('user_id')
|
79
|
-
.references(() => users.id, { onDelete: 'cascade' })
|
80
|
-
.notNull(),
|
81
|
-
|
82
|
-
createdAt: createdAt(),
|
83
|
-
updatedAt: updatedAt(),
|
84
|
-
});
|
File without changes
|
File without changes
|