@lobehub/chat 0.100.5 → 0.101.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/.eslintrc.js +1 -0
- package/CHANGELOG.md +50 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/__mocks__/zustand/traditional.ts +25 -0
- package/package.json +7 -3
- package/src/app/api/files/image/imgur.ts +72 -0
- package/src/app/api/files/image/route.ts +42 -0
- package/src/app/api/openai/chat/createChatCompletion.ts +2 -1
- package/src/app/chat/(desktop)/features/ChatInput/DragUpload.tsx +166 -0
- package/src/app/chat/(desktop)/features/ChatInput/Footer/LocalFiles.tsx +10 -0
- package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +64 -0
- package/src/app/chat/(desktop)/features/ChatInput/InputArea.tsx +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/index.tsx +38 -30
- package/src/app/chat/components/FileList/FileItem.style.ts +81 -0
- package/src/app/chat/components/FileList/FileItem.tsx +69 -0
- package/src/app/chat/components/FileList/Lightbox.tsx +46 -0
- package/src/app/chat/components/FileList/index.tsx +63 -0
- package/src/app/chat/features/ChatInput/ActionBar/Clear.tsx +13 -4
- package/src/app/chat/features/ChatInput/ActionBar/FileUpload.tsx +53 -0
- package/src/app/chat/features/ChatInput/ActionBar/config.ts +3 -1
- package/src/app/chat/{(desktop)/features → features}/ChatInput/useSend.ts +5 -1
- package/src/app/chat/features/Conversation/ChatList/Messages/User.tsx +23 -0
- package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +2 -0
- package/src/app/market/(desktop)/features/AgentDetail.tsx +14 -9
- package/src/app/market/(desktop)/index.tsx +2 -3
- package/src/app/market/(mobile)/index.tsx +2 -3
- package/src/app/market/features/AgentCard/AgentCardItem.tsx +4 -1
- package/src/app/market/features/AgentCard/index.tsx +20 -31
- package/src/app/market/features/AgentDetailContent/AgentInfo/Header.tsx +0 -1
- package/src/app/market/features/AgentDetailContent/AgentInfo/index.tsx +2 -3
- package/src/app/market/features/AgentSearchBar/index.tsx +9 -4
- package/src/app/market/features/TagList/Inner.tsx +28 -0
- package/src/app/market/features/TagList/index.tsx +12 -23
- package/src/config/__tests__/client.test.ts +76 -0
- package/src/config/__tests__/server.test.ts +52 -0
- package/src/config/server.ts +8 -0
- package/src/const/layoutTokens.ts +1 -1
- package/src/const/llm.ts +3 -0
- package/src/const/settings.ts +2 -0
- package/src/database/core/__tests__/db.test.ts +77 -0
- package/src/database/core/__tests__/model.test.ts +55 -0
- package/src/database/core/db.ts +25 -0
- package/src/database/core/index.ts +1 -0
- package/src/database/core/model.ts +49 -0
- package/src/database/core/schema.ts +9 -0
- package/src/database/models/file.test.ts +71 -0
- package/src/database/models/file.ts +26 -0
- package/src/locales/default/chat.ts +5 -0
- package/src/services/__tests__/file.test.ts +88 -0
- package/src/services/chatModel.ts +11 -6
- package/src/services/file.ts +36 -0
- package/src/store/files/index.ts +2 -0
- package/src/store/files/initialState.ts +7 -0
- package/src/store/files/selectors.test.ts +75 -0
- package/src/store/files/selectors.ts +34 -0
- package/src/store/files/slices/images/action.test.ts +186 -0
- package/src/store/files/slices/images/action.ts +83 -0
- package/src/store/files/slices/images/index.ts +3 -0
- package/src/store/files/slices/images/initialState.ts +11 -0
- package/src/store/files/store.ts +27 -0
- package/src/store/global/selectors/settings.test.ts +1 -3
- package/src/store/market/action.ts +9 -1
- package/src/store/market/initialState.ts +2 -0
- package/src/store/market/selectors.ts +10 -8
- package/src/store/session/slices/agentConfig/selectors.ts +7 -1
- package/src/store/session/slices/chat/actions/message.ts +78 -17
- package/src/store/session/slices/chat/reducers/files.test.ts +38 -0
- package/src/store/session/slices/chat/reducers/files.ts +37 -0
- package/src/store/session/slices/session/initialState.ts +1 -0
- package/src/store/session/slices/session/reducers/session.test.ts +98 -1
- package/src/store/session/slices/session/reducers/session.ts +26 -1
- package/src/types/chatMessage.ts +3 -2
- package/src/types/database/db.ts +4 -0
- package/src/types/database/files.ts +38 -0
- package/src/types/files.ts +8 -0
- package/src/types/market.ts +1 -0
- package/src/types/openai/chat.ts +15 -1
- package/src/types/session.ts +1 -0
- package/tests/setup.ts +8 -0
- package/vitest.config.ts +2 -0
- package/src/app/chat/(desktop)/features/ChatInput/Footer.tsx +0 -63
- package/src/utils/findDuplicates.ts +0 -22
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Icon } from '@lobehub/ui';
|
|
2
|
-
import { Button } from 'antd';
|
|
3
|
-
import { createStyles } from 'antd-style';
|
|
4
|
-
import { ArrowBigUp, CornerDownLeft, Loader2 } from 'lucide-react';
|
|
5
|
-
import { memo } from 'react';
|
|
6
|
-
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import { Flexbox } from 'react-layout-kit';
|
|
8
|
-
|
|
9
|
-
import SaveTopic from '@/app/chat/features/ChatInput/Topic';
|
|
10
|
-
import { useSessionStore } from '@/store/session';
|
|
11
|
-
|
|
12
|
-
import { useSendMessage } from './useSend';
|
|
13
|
-
|
|
14
|
-
const useStyles = createStyles(({ css }) => ({
|
|
15
|
-
footerBar: css`
|
|
16
|
-
display: flex;
|
|
17
|
-
flex: none;
|
|
18
|
-
gap: 8px;
|
|
19
|
-
align-items: center;
|
|
20
|
-
justify-content: flex-end;
|
|
21
|
-
|
|
22
|
-
padding: 0 24px;
|
|
23
|
-
`,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const Footer = memo(() => {
|
|
27
|
-
const { t } = useTranslation('chat');
|
|
28
|
-
const { styles, theme } = useStyles();
|
|
29
|
-
const [loading, onStop] = useSessionStore((s) => [!!s.chatLoadingId, s.stopGenerateMessage]);
|
|
30
|
-
|
|
31
|
-
const onSend = useSendMessage();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div className={styles.footerBar}>
|
|
35
|
-
<Flexbox
|
|
36
|
-
gap={4}
|
|
37
|
-
horizontal
|
|
38
|
-
style={{ color: theme.colorTextDescription, fontSize: 12, marginRight: 12 }}
|
|
39
|
-
>
|
|
40
|
-
<Icon icon={CornerDownLeft} />
|
|
41
|
-
<span>{t('send')}</span>
|
|
42
|
-
<span>/</span>
|
|
43
|
-
<Flexbox horizontal>
|
|
44
|
-
<Icon icon={ArrowBigUp} />
|
|
45
|
-
<Icon icon={CornerDownLeft} />
|
|
46
|
-
</Flexbox>
|
|
47
|
-
<span>{t('warp')}</span>
|
|
48
|
-
</Flexbox>
|
|
49
|
-
<SaveTopic />
|
|
50
|
-
{loading ? (
|
|
51
|
-
<Button icon={loading && <Icon icon={Loader2} spin />} onClick={onStop}>
|
|
52
|
-
{t('stop')}
|
|
53
|
-
</Button>
|
|
54
|
-
) : (
|
|
55
|
-
<Button onClick={() => onSend()} type={'primary'}>
|
|
56
|
-
{t('send')}
|
|
57
|
-
</Button>
|
|
58
|
-
)}
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export default Footer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const findDuplicates = (arr: string[]): string[] => {
|
|
2
|
-
const duplicates: { [key: string]: number } = {};
|
|
3
|
-
|
|
4
|
-
// 统计每个项目出现的次数
|
|
5
|
-
for (const item of arr) {
|
|
6
|
-
if (duplicates[item]) {
|
|
7
|
-
duplicates[item]++;
|
|
8
|
-
} else {
|
|
9
|
-
duplicates[item] = 1;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// 挑出重复出现 3 次以上的项目
|
|
14
|
-
const COUNT = 3;
|
|
15
|
-
|
|
16
|
-
const result = Object.keys(duplicates).filter((item) => duplicates[item] >= COUNT);
|
|
17
|
-
|
|
18
|
-
// 按重复次数从多到少排序
|
|
19
|
-
result.sort((a, b) => duplicates[b] - duplicates[a]);
|
|
20
|
-
|
|
21
|
-
return result;
|
|
22
|
-
};
|