@lobehub/chat 1.110.1 → 1.110.2

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 (113) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/Dockerfile +1 -1
  3. package/apps/desktop/.i18nrc.js +2 -1
  4. package/apps/desktop/package.json +1 -2
  5. package/apps/desktop/resources/locales/ar/menu.json +1 -0
  6. package/apps/desktop/resources/locales/bg-BG/menu.json +1 -0
  7. package/apps/desktop/resources/locales/de-DE/menu.json +1 -0
  8. package/apps/desktop/resources/locales/en-US/menu.json +1 -0
  9. package/apps/desktop/resources/locales/es-ES/menu.json +1 -0
  10. package/apps/desktop/resources/locales/fa-IR/menu.json +1 -0
  11. package/apps/desktop/resources/locales/fr-FR/menu.json +1 -0
  12. package/apps/desktop/resources/locales/it-IT/menu.json +1 -0
  13. package/apps/desktop/resources/locales/ja-JP/menu.json +1 -0
  14. package/apps/desktop/resources/locales/ko-KR/menu.json +1 -0
  15. package/apps/desktop/resources/locales/nl-NL/menu.json +1 -0
  16. package/apps/desktop/resources/locales/pl-PL/menu.json +1 -0
  17. package/apps/desktop/resources/locales/pt-BR/menu.json +1 -0
  18. package/apps/desktop/resources/locales/ru-RU/menu.json +1 -0
  19. package/apps/desktop/resources/locales/tr-TR/menu.json +1 -0
  20. package/apps/desktop/resources/locales/vi-VN/menu.json +1 -0
  21. package/apps/desktop/resources/locales/zh-CN/menu.json +1 -0
  22. package/apps/desktop/resources/locales/zh-TW/menu.json +1 -0
  23. package/apps/desktop/src/main/controllers/MenuCtr.ts +2 -2
  24. package/apps/desktop/src/main/locales/default/menu.ts +1 -0
  25. package/apps/desktop/src/main/menus/impls/linux.ts +9 -24
  26. package/apps/desktop/src/main/menus/impls/macOS.ts +9 -28
  27. package/apps/desktop/src/main/menus/impls/windows.ts +9 -27
  28. package/changelog/v1.json +12 -0
  29. package/locales/ar/modelProvider.json +10 -1
  30. package/locales/ar/models.json +19 -1
  31. package/locales/bg-BG/modelProvider.json +10 -1
  32. package/locales/bg-BG/models.json +19 -1
  33. package/locales/de-DE/modelProvider.json +10 -1
  34. package/locales/de-DE/models.json +19 -1
  35. package/locales/en-US/modelProvider.json +10 -1
  36. package/locales/en-US/models.json +19 -1
  37. package/locales/es-ES/modelProvider.json +10 -1
  38. package/locales/es-ES/models.json +19 -1
  39. package/locales/fa-IR/modelProvider.json +10 -1
  40. package/locales/fa-IR/models.json +19 -1
  41. package/locales/fr-FR/modelProvider.json +10 -1
  42. package/locales/fr-FR/models.json +19 -1
  43. package/locales/it-IT/modelProvider.json +10 -1
  44. package/locales/it-IT/models.json +19 -1
  45. package/locales/ja-JP/modelProvider.json +10 -1
  46. package/locales/ja-JP/models.json +19 -1
  47. package/locales/ko-KR/modelProvider.json +10 -1
  48. package/locales/ko-KR/models.json +19 -1
  49. package/locales/nl-NL/modelProvider.json +10 -1
  50. package/locales/nl-NL/models.json +19 -1
  51. package/locales/pl-PL/modelProvider.json +10 -1
  52. package/locales/pl-PL/models.json +19 -1
  53. package/locales/pt-BR/modelProvider.json +10 -1
  54. package/locales/pt-BR/models.json +19 -1
  55. package/locales/ru-RU/modelProvider.json +10 -1
  56. package/locales/ru-RU/models.json +19 -1
  57. package/locales/tr-TR/modelProvider.json +10 -1
  58. package/locales/tr-TR/models.json +19 -1
  59. package/locales/vi-VN/modelProvider.json +10 -1
  60. package/locales/vi-VN/models.json +19 -1
  61. package/locales/zh-CN/modelProvider.json +10 -1
  62. package/locales/zh-CN/models.json +19 -1
  63. package/locales/zh-TW/modelProvider.json +10 -1
  64. package/locales/zh-TW/models.json +19 -1
  65. package/package.json +1 -1
  66. package/packages/electron-client-ipc/src/events/menu.ts +1 -1
  67. package/packages/types/package.json +3 -0
  68. package/packages/types/src/agent/chatConfig.ts +1 -1
  69. package/packages/types/src/agent/index.ts +3 -4
  70. package/packages/types/src/discover/assistants.ts +3 -3
  71. package/packages/types/src/message/chat.ts +4 -4
  72. package/src/app/(backend)/_deprecated/createBizOpenAI/auth.ts +2 -1
  73. package/src/app/(backend)/_deprecated/createBizOpenAI/createAzureOpenai.ts +1 -1
  74. package/src/app/(backend)/_deprecated/createBizOpenAI/createOpenai.ts +1 -1
  75. package/src/app/(backend)/_deprecated/createBizOpenAI/index.ts +1 -1
  76. package/src/app/(backend)/middleware/auth/index.test.ts +1 -1
  77. package/src/app/(backend)/middleware/auth/index.ts +1 -1
  78. package/src/app/(backend)/middleware/auth/utils.ts +1 -1
  79. package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +1 -1
  80. package/src/app/(backend)/webapi/chat/[provider]/route.ts +2 -1
  81. package/src/app/(backend)/webapi/models/[provider]/pull/route.ts +2 -1
  82. package/src/app/(backend)/webapi/models/[provider]/route.ts +1 -1
  83. package/src/app/(backend)/webapi/plugin/gateway/route.ts +1 -1
  84. package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +1 -1
  85. package/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx +15 -5
  86. package/src/app/[variants]/(main)/settings/provider/features/ModelList/EnabledModelList/index.tsx +22 -4
  87. package/src/app/[variants]/(main)/settings/provider/features/ModelList/index.tsx +99 -3
  88. package/src/config/modelProviders/ai302.ts +1 -0
  89. package/src/config/modelProviders/openai.ts +1 -0
  90. package/src/features/ChatInput/Desktop/InputArea/index.tsx +14 -0
  91. package/src/features/Conversation/Error/index.tsx +1 -1
  92. package/src/features/Conversation/components/ChatItem/index.tsx +18 -1
  93. package/src/features/Portal/Artifacts/Header.tsx +1 -1
  94. package/src/libs/model-runtime/RouterRuntime/createRuntime.ts +2 -2
  95. package/src/locales/default/modelProvider.ts +9 -0
  96. package/src/services/__tests__/chat.test.ts +1 -1
  97. package/src/services/chat.ts +1 -1
  98. package/src/services/electron/system.ts +3 -1
  99. package/src/store/chat/slices/message/action.ts +1 -1
  100. package/src/store/chat/slices/plugin/action.ts +1 -1
  101. package/src/utils/errorResponse.test.ts +1 -1
  102. package/src/utils/errorResponse.ts +2 -1
  103. package/src/utils/fetch/__tests__/parseError.test.ts +1 -2
  104. package/src/utils/fetch/fetchSSE.ts +2 -1
  105. package/src/utils/fetch/parseError.ts +1 -1
  106. package/tsconfig.json +1 -1
  107. package/.dockerignore +0 -9
  108. package/packages/file-loaders/src/loaders/docx/fixtures/test.docx +0 -0
  109. package/packages/file-loaders/src/loaders/excel/fixtures/test.xlsx +0 -0
  110. package/packages/file-loaders/src/loaders/pptx/fixtures/test.pptx +0 -0
  111. package/packages/file-loaders/test/fixtures/test.docx +0 -0
  112. package/packages/file-loaders/test/fixtures/test.pptx +0 -0
  113. /package/{packages/types/src → src/types}/next.ts +0 -0
@@ -2,6 +2,7 @@ import { ModelProviderCard } from '@/types/llm';
2
2
 
3
3
  // ref: https://platform.openai.com/docs/deprecations
4
4
  const OpenAI: ModelProviderCard = {
5
+ apiKeyUrl: 'https://platform.openai.com/api-keys?utm_source=lobehub',
5
6
  chatModels: [
6
7
  {
7
8
  contextWindowTokens: 1_047_576,
@@ -5,6 +5,7 @@ import { RefObject, memo, useEffect, useRef } from 'react';
5
5
  import { useHotkeysContext } from 'react-hotkeys-hook';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
+ import { isDesktop } from '@/const/version';
8
9
  import { useUserStore } from '@/store/user';
9
10
  import { preferenceSelectors } from '@/store/user/selectors';
10
11
  import { HotkeyEnum } from '@/types/hotkey';
@@ -86,6 +87,19 @@ const InputArea = memo<InputAreaProps>(({ onSend, value, loading, onChange }) =>
86
87
  onCompositionStart={() => {
87
88
  isChineseInput.current = true;
88
89
  }}
90
+ onContextMenu={async (e) => {
91
+ if (isDesktop) {
92
+ e.preventDefault();
93
+ const textArea = ref.current?.resizableTextArea?.textArea;
94
+ const hasSelection = textArea && textArea.selectionStart !== textArea.selectionEnd;
95
+ const { electronSystemService } = await import('@/services/electron/system');
96
+
97
+ electronSystemService.showContextMenu('editor', {
98
+ hasSelection: !!hasSelection,
99
+ value: value,
100
+ });
101
+ }
102
+ }}
89
103
  onFocus={() => {
90
104
  enableScope(HotkeyEnum.AddUserMessage);
91
105
  }}
@@ -1,3 +1,4 @@
1
+ import { ChatErrorType, ErrorType } from '@lobechat/types/fetch';
1
2
  import { IPluginErrorType } from '@lobehub/chat-plugin-sdk';
2
3
  import type { AlertProps } from '@lobehub/ui';
3
4
  import { Skeleton } from 'antd';
@@ -7,7 +8,6 @@ import { useTranslation } from 'react-i18next';
7
8
 
8
9
  import { useProviderName } from '@/hooks/useProviderName';
9
10
  import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '@/libs/model-runtime';
10
- import { ChatErrorType, ErrorType } from '@/types/fetch';
11
11
  import { ChatMessage, ChatMessageError } from '@/types/message';
12
12
 
13
13
  import ChatInvalidAPIKey from './ChatInvalidApiKey';
@@ -6,6 +6,7 @@ import { MouseEventHandler, ReactNode, memo, use, useCallback, useMemo } from 'r
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
+ import { isDesktop } from '@/const/version';
9
10
  import ChatItem from '@/features/ChatItem';
10
11
  import { VirtuosoContext } from '@/features/Conversation/components/VirtualizedList/VirtuosoContext';
11
12
  import { useAgentStore } from '@/store/agent';
@@ -220,6 +221,19 @@ const Item = memo<ChatListItemProps>(
220
221
  toggleMessageEditing(id, edit);
221
222
  }, []);
222
223
 
224
+ const onContextMenu = useCallback(async () => {
225
+ if (isDesktop && item) {
226
+ const { electronSystemService } = await import('@/services/electron/system');
227
+
228
+ electronSystemService.showContextMenu('chat', {
229
+ content: item.content,
230
+ hasError: !!item.error,
231
+ messageId: id,
232
+ role: item.role,
233
+ });
234
+ }
235
+ }, [id, item]);
236
+
223
237
  const belowMessage = useMemo(() => item && <BelowMessage data={item} />, [item]);
224
238
  const errorMessage = useMemo(() => item && <ErrorMessageExtra data={item} />, [item]);
225
239
  const messageExtra = useMemo(() => item && <MessageExtra data={item} />, [item]);
@@ -228,7 +242,10 @@ const Item = memo<ChatListItemProps>(
228
242
  item && (
229
243
  <InPortalThreadContext.Provider value={inPortalThread}>
230
244
  {enableHistoryDivider && <History />}
231
- <Flexbox className={cx(styles.message, className, isMessageLoading && styles.loading)}>
245
+ <Flexbox
246
+ className={cx(styles.message, className, isMessageLoading && styles.loading)}
247
+ onContextMenu={onContextMenu}
248
+ >
232
249
  <ChatItem
233
250
  actions={actionBar}
234
251
  avatar={item.meta}
@@ -1,3 +1,4 @@
1
+ import { ArtifactType } from '@lobechat/types/artifact';
1
2
  import { ActionIcon, Icon, Segmented, Text } from '@lobehub/ui';
2
3
  import { ConfigProvider } from 'antd';
3
4
  import { cx } from 'antd-style';
@@ -9,7 +10,6 @@ import { useChatStore } from '@/store/chat';
9
10
  import { chatPortalSelectors } from '@/store/chat/selectors';
10
11
  import { ArtifactDisplayMode } from '@/store/chat/slices/portal/initialState';
11
12
  import { oneLineEllipsis } from '@/styles';
12
- import { ArtifactType } from '@/types/artifact';
13
13
 
14
14
  const Header = () => {
15
15
  const { t } = useTranslation('portal');
@@ -135,9 +135,9 @@ export const createRouterRuntime = ({
135
135
  this._runtimes = routers.map((router) => {
136
136
  const providerAI = router.runtime ?? baseRuntimeMap[router.apiType] ?? LobeOpenAI;
137
137
 
138
- const finalOptions = { ...router.options, ...options };
138
+ const finalOptions = { ...params, ...options, ...router.options };
139
139
  // @ts-ignore
140
- const runtime: LobeRuntimeAI = new providerAI({ ...params, ...finalOptions, id });
140
+ const runtime: LobeRuntimeAI = new providerAI({ ...finalOptions, id });
141
141
 
142
142
  return { id: router.apiType, models: router.models, runtime };
143
143
  });
@@ -310,6 +310,7 @@ export default {
310
310
  latestTime: '上次更新时间:{{time}}',
311
311
  noLatestTime: '暂未获取列表',
312
312
  },
313
+ noModelsInCategory: '该分类下暂无启用的模型',
313
314
  resetAll: {
314
315
  conform: '确认重置当前模型的所有修改?重置后当前模型列表将会回到默认状态',
315
316
  success: '重置成功',
@@ -321,6 +322,14 @@ export default {
321
322
  total: '共 {{count}} 个模型可用',
322
323
  },
323
324
  searchNotFound: '未找到搜索结果',
325
+ tabs: {
326
+ all: '全部',
327
+ chat: '对话',
328
+ embedding: '向量化',
329
+ image: '图片',
330
+ stt: 'ASR',
331
+ tts: 'TTS',
332
+ },
324
333
  },
325
334
  sortModal: {
326
335
  success: '排序更新成功',
@@ -1,3 +1,4 @@
1
+ import { ChatErrorType } from '@lobechat/types/fetch';
1
2
  import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
2
3
  import { act } from '@testing-library/react';
3
4
  import { merge } from 'lodash-es';
@@ -35,7 +36,6 @@ import { UserStore } from '@/store/user';
35
36
  import { UserSettingsState, initialSettingsState } from '@/store/user/slices/settings/initialState';
36
37
  import { DalleManifest } from '@/tools/dalle';
37
38
  import { WebBrowsingManifest } from '@/tools/web-browsing';
38
- import { ChatErrorType } from '@/types/fetch';
39
39
  import { ChatImageItem, ChatMessage } from '@/types/message';
40
40
  import { ChatStreamPayload, type OpenAIChatMessage } from '@/types/openai/chat';
41
41
  import { LobeTool } from '@/types/tool';
@@ -1,3 +1,4 @@
1
+ import { ChatErrorType } from '@lobechat/types/fetch';
1
2
  import { PluginRequestPayload, createHeadersWithPluginSettings } from '@lobehub/chat-plugin-sdk';
2
3
  import { produce } from 'immer';
3
4
  import { merge } from 'lodash-es';
@@ -34,7 +35,6 @@ import {
34
35
  } from '@/store/user/selectors';
35
36
  import { WebBrowsingManifest } from '@/tools/web-browsing';
36
37
  import { WorkingModel } from '@/types/agent';
37
- import { ChatErrorType } from '@/types/fetch';
38
38
  import { ChatImageItem, ChatMessage, MessageToolCall } from '@/types/message';
39
39
  import type { ChatStreamPayload, OpenAIChatMessage } from '@/types/openai/chat';
40
40
  import { UserMessageContentPart } from '@/types/openai/chat';
@@ -26,7 +26,9 @@ class ElectronSystemService {
26
26
  return dispatch('minimizeWindow');
27
27
  }
28
28
 
29
- // Add other system-related service methods here if needed in the future
29
+ showContextMenu = async (type: string, data?: any) => {
30
+ return dispatch('showContextMenu', { data, type });
31
+ };
30
32
  }
31
33
 
32
34
  // Export a singleton instance of the service
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
2
2
  // Disable the auto sort key eslint rule to make the code more logic and readable
3
+ import { ChatErrorType } from '@lobechat/types/fetch';
3
4
  import { copyToClipboard } from '@lobehub/ui';
4
5
  import isEqual from 'fast-deep-equal';
5
6
  import { SWRResponse, mutate } from 'swr';
@@ -12,7 +13,6 @@ import { topicService } from '@/services/topic';
12
13
  import { traceService } from '@/services/trace';
13
14
  import { ChatStore } from '@/store/chat/store';
14
15
  import { messageMapKey } from '@/store/chat/utils/messageMapKey';
15
- import { ChatErrorType } from '@/types/fetch';
16
16
  import {
17
17
  ChatMessage,
18
18
  ChatMessageError,
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
2
+ import { ChatErrorType } from '@lobechat/types/fetch';
2
3
  import { PluginErrorType } from '@lobehub/chat-plugin-sdk';
3
4
  import isEqual from 'fast-deep-equal';
4
5
  import { t } from 'i18next';
@@ -13,7 +14,6 @@ import { ChatStore } from '@/store/chat/store';
13
14
  import { useToolStore } from '@/store/tool';
14
15
  import { pluginSelectors } from '@/store/tool/selectors';
15
16
  import { builtinTools } from '@/tools';
16
- import { ChatErrorType } from '@/types/fetch';
17
17
  import {
18
18
  ChatMessage,
19
19
  ChatMessageError,
@@ -1,7 +1,7 @@
1
+ import { ChatErrorType } from '@lobechat/types/fetch';
1
2
  import { describe, expect, it, vi } from 'vitest';
2
3
 
3
4
  import { AgentRuntimeErrorType } from '@/libs/model-runtime';
4
- import { ChatErrorType } from '@/types/fetch';
5
5
 
6
6
  import { createErrorResponse } from './errorResponse';
7
7
 
@@ -1,5 +1,6 @@
1
+ import { ChatErrorType, ErrorResponse, ErrorType } from '@lobechat/types/fetch';
2
+
1
3
  import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '@/libs/model-runtime';
2
- import { ChatErrorType, ErrorResponse, ErrorType } from '@/types/fetch';
3
4
 
4
5
  const getStatus = (errorType: ILobeAgentRuntimeErrorType | ErrorType) => {
5
6
  // InvalidAccessCode / InvalidAzureAPIKey / InvalidOpenAIAPIKey / InvalidZhipuAPIKey ....
@@ -1,7 +1,6 @@
1
+ import { ErrorResponse } from '@lobechat/types/fetch';
1
2
  import { afterEach, describe, expect, it, vi } from 'vitest';
2
3
 
3
- import { ErrorResponse } from '@/types/fetch';
4
-
5
4
  import { getMessageError } from '../parseError';
6
5
 
7
6
  // 模拟 i18next
@@ -1,7 +1,8 @@
1
+ import { ChatErrorType } from '@lobechat/types/fetch';
2
+
1
3
  import { MESSAGE_CANCEL_FLAT } from '@/const/message';
2
4
  import { LOBE_CHAT_OBSERVATION_ID, LOBE_CHAT_TRACE_ID } from '@/const/trace';
3
5
  import { parseToolCalls } from '@/libs/model-runtime';
4
- import { ChatErrorType } from '@/types/fetch';
5
6
  import { ResponseAnimation, ResponseAnimationStyle } from '@/types/llm';
6
7
  import {
7
8
  ChatMessageError,
@@ -1,6 +1,6 @@
1
+ import { ErrorResponse, ErrorType } from '@lobechat/types/fetch';
1
2
  import { t } from 'i18next';
2
3
 
3
- import { ErrorResponse, ErrorType } from '@/types/fetch';
4
4
  import { ChatMessageError } from '@/types/message';
5
5
 
6
6
  export const getMessageError = async (response: Response) => {
package/tsconfig.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "baseUrl": ".",
19
19
  "types": ["vitest/globals", "@serwist/next/typings"],
20
20
  "paths": {
21
- "@/types/*": ["./packages/types/src/*"],
21
+ "@/types/*": ["./packages/types/src/*", "./src/types/*"],
22
22
  "@/*": ["./src/*"],
23
23
  "~test-utils": ["./tests/utils.tsx"]
24
24
  },
package/.dockerignore DELETED
@@ -1,9 +0,0 @@
1
- Dockerfile
2
- .dockerignore
3
- node_modules
4
- npm-debug.log
5
- .next
6
- .git
7
- .github
8
- *.md
9
- .env.example
File without changes