@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.
Files changed (83) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +2 -2
  4. package/README.zh-CN.md +2 -2
  5. package/__mocks__/zustand/traditional.ts +25 -0
  6. package/package.json +7 -3
  7. package/src/app/api/files/image/imgur.ts +72 -0
  8. package/src/app/api/files/image/route.ts +42 -0
  9. package/src/app/api/openai/chat/createChatCompletion.ts +2 -1
  10. package/src/app/chat/(desktop)/features/ChatInput/DragUpload.tsx +166 -0
  11. package/src/app/chat/(desktop)/features/ChatInput/Footer/LocalFiles.tsx +10 -0
  12. package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +64 -0
  13. package/src/app/chat/(desktop)/features/ChatInput/InputArea.tsx +3 -3
  14. package/src/app/chat/(desktop)/features/ChatInput/index.tsx +38 -30
  15. package/src/app/chat/components/FileList/FileItem.style.ts +81 -0
  16. package/src/app/chat/components/FileList/FileItem.tsx +69 -0
  17. package/src/app/chat/components/FileList/Lightbox.tsx +46 -0
  18. package/src/app/chat/components/FileList/index.tsx +63 -0
  19. package/src/app/chat/features/ChatInput/ActionBar/Clear.tsx +13 -4
  20. package/src/app/chat/features/ChatInput/ActionBar/FileUpload.tsx +53 -0
  21. package/src/app/chat/features/ChatInput/ActionBar/config.ts +3 -1
  22. package/src/app/chat/{(desktop)/features → features}/ChatInput/useSend.ts +5 -1
  23. package/src/app/chat/features/Conversation/ChatList/Messages/User.tsx +23 -0
  24. package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +2 -0
  25. package/src/app/market/(desktop)/features/AgentDetail.tsx +14 -9
  26. package/src/app/market/(desktop)/index.tsx +2 -3
  27. package/src/app/market/(mobile)/index.tsx +2 -3
  28. package/src/app/market/features/AgentCard/AgentCardItem.tsx +4 -1
  29. package/src/app/market/features/AgentCard/index.tsx +20 -31
  30. package/src/app/market/features/AgentDetailContent/AgentInfo/Header.tsx +0 -1
  31. package/src/app/market/features/AgentDetailContent/AgentInfo/index.tsx +2 -3
  32. package/src/app/market/features/AgentSearchBar/index.tsx +9 -4
  33. package/src/app/market/features/TagList/Inner.tsx +28 -0
  34. package/src/app/market/features/TagList/index.tsx +12 -23
  35. package/src/config/__tests__/client.test.ts +76 -0
  36. package/src/config/__tests__/server.test.ts +52 -0
  37. package/src/config/server.ts +8 -0
  38. package/src/const/layoutTokens.ts +1 -1
  39. package/src/const/llm.ts +3 -0
  40. package/src/const/settings.ts +2 -0
  41. package/src/database/core/__tests__/db.test.ts +77 -0
  42. package/src/database/core/__tests__/model.test.ts +55 -0
  43. package/src/database/core/db.ts +25 -0
  44. package/src/database/core/index.ts +1 -0
  45. package/src/database/core/model.ts +49 -0
  46. package/src/database/core/schema.ts +9 -0
  47. package/src/database/models/file.test.ts +71 -0
  48. package/src/database/models/file.ts +26 -0
  49. package/src/locales/default/chat.ts +5 -0
  50. package/src/services/__tests__/file.test.ts +88 -0
  51. package/src/services/chatModel.ts +11 -6
  52. package/src/services/file.ts +36 -0
  53. package/src/store/files/index.ts +2 -0
  54. package/src/store/files/initialState.ts +7 -0
  55. package/src/store/files/selectors.test.ts +75 -0
  56. package/src/store/files/selectors.ts +34 -0
  57. package/src/store/files/slices/images/action.test.ts +186 -0
  58. package/src/store/files/slices/images/action.ts +83 -0
  59. package/src/store/files/slices/images/index.ts +3 -0
  60. package/src/store/files/slices/images/initialState.ts +11 -0
  61. package/src/store/files/store.ts +27 -0
  62. package/src/store/global/selectors/settings.test.ts +1 -3
  63. package/src/store/market/action.ts +9 -1
  64. package/src/store/market/initialState.ts +2 -0
  65. package/src/store/market/selectors.ts +10 -8
  66. package/src/store/session/slices/agentConfig/selectors.ts +7 -1
  67. package/src/store/session/slices/chat/actions/message.ts +78 -17
  68. package/src/store/session/slices/chat/reducers/files.test.ts +38 -0
  69. package/src/store/session/slices/chat/reducers/files.ts +37 -0
  70. package/src/store/session/slices/session/initialState.ts +1 -0
  71. package/src/store/session/slices/session/reducers/session.test.ts +98 -1
  72. package/src/store/session/slices/session/reducers/session.ts +26 -1
  73. package/src/types/chatMessage.ts +3 -2
  74. package/src/types/database/db.ts +4 -0
  75. package/src/types/database/files.ts +38 -0
  76. package/src/types/files.ts +8 -0
  77. package/src/types/market.ts +1 -0
  78. package/src/types/openai/chat.ts +15 -1
  79. package/src/types/session.ts +1 -0
  80. package/tests/setup.ts +8 -0
  81. package/vitest.config.ts +2 -0
  82. package/src/app/chat/(desktop)/features/ChatInput/Footer.tsx +0 -63
  83. 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
- };