@lobehub/chat 1.113.3 → 1.114.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 (82) hide show
  1. package/.eslintignore +17 -0
  2. package/.github/workflows/auto-i18n.yml +1 -1
  3. package/.github/workflows/claude.yml +1 -1
  4. package/.github/workflows/desktop-pr-build.yml +4 -4
  5. package/.github/workflows/docker-database.yml +3 -3
  6. package/.github/workflows/docker-pglite.yml +3 -3
  7. package/.github/workflows/docker.yml +3 -3
  8. package/.github/workflows/lighthouse.yml +2 -2
  9. package/.github/workflows/release-desktop-beta.yml +3 -3
  10. package/.github/workflows/release.yml +2 -2
  11. package/.github/workflows/sync-database-schema.yml +1 -1
  12. package/.github/workflows/sync.yml +1 -1
  13. package/.github/workflows/test.yml +1 -1
  14. package/.stylelintignore +39 -0
  15. package/CHANGELOG.md +50 -0
  16. package/changelog/v1.json +14 -0
  17. package/package.json +1 -1
  18. package/packages/const/src/index.ts +2 -0
  19. package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +10 -5
  20. package/packages/model-runtime/src/openai/__snapshots__/index.test.ts.snap +29 -0
  21. package/packages/model-runtime/src/utils/modelParse.ts +29 -16
  22. package/packages/prompts/package.json +1 -0
  23. package/{src → packages/prompts/src}/chains/__tests__/langDetect.test.ts +1 -2
  24. package/{src → packages/prompts/src}/chains/__tests__/pickEmoji.test.ts +1 -2
  25. package/{src → packages/prompts/src}/chains/__tests__/summaryAgentName.test.ts +2 -15
  26. package/{src → packages/prompts/src}/chains/__tests__/summaryDescription.test.ts +2 -12
  27. package/{src → packages/prompts/src}/chains/__tests__/summaryHistory.test.ts +1 -5
  28. package/{src → packages/prompts/src}/chains/__tests__/summaryTags.test.ts +1 -14
  29. package/{src → packages/prompts/src}/chains/__tests__/summaryTitle.test.ts +2 -11
  30. package/{src → packages/prompts/src}/chains/abstractChunk.ts +2 -2
  31. package/{src → packages/prompts/src}/chains/answerWithContext.ts +1 -1
  32. package/packages/prompts/src/chains/index.ts +12 -0
  33. package/{src → packages/prompts/src}/chains/langDetect.ts +1 -1
  34. package/{src → packages/prompts/src}/chains/pickEmoji.ts +1 -1
  35. package/{src → packages/prompts/src}/chains/rewriteQuery.ts +2 -2
  36. package/{src → packages/prompts/src}/chains/summaryAgentName.ts +6 -5
  37. package/{src → packages/prompts/src}/chains/summaryDescription.ts +7 -5
  38. package/{src → packages/prompts/src}/chains/summaryGenerationTitle.ts +3 -5
  39. package/{src → packages/prompts/src}/chains/summaryHistory.ts +2 -3
  40. package/{src → packages/prompts/src}/chains/summaryTags.ts +3 -4
  41. package/{src → packages/prompts/src}/chains/summaryTitle.ts +5 -5
  42. package/{src → packages/prompts/src}/chains/translate.ts +1 -1
  43. package/packages/prompts/src/index.ts +2 -5
  44. package/packages/prompts/src/{files → prompts/files}/index.test.ts +1 -2
  45. package/packages/prompts/src/prompts/index.ts +5 -0
  46. package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.test.ts +1 -3
  47. package/packages/types/src/aiModel.ts +2 -2
  48. package/packages/types/src/index.ts +3 -0
  49. package/packages/types/src/llm.ts +3 -0
  50. package/src/app/[variants]/(main)/settings/provider/(detail)/[id]/index.tsx +5 -0
  51. package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/index.tsx +2 -4
  52. package/src/config/aiModels/fal.ts +26 -1
  53. package/src/features/AgentSetting/store/action.ts +19 -7
  54. package/src/server/routers/async/ragEval.ts +1 -1
  55. package/src/store/aiInfra/slices/aiProvider/__tests__/action.test.ts +8 -2
  56. package/src/store/chat/slices/aiChat/actions/memory.ts +1 -1
  57. package/src/store/chat/slices/aiChat/actions/rag.ts +1 -1
  58. package/src/store/chat/slices/thread/action.ts +3 -2
  59. package/src/store/chat/slices/topic/action.ts +3 -2
  60. package/src/store/chat/slices/translate/action.test.ts +2 -2
  61. package/src/store/chat/slices/translate/action.ts +1 -2
  62. package/src/store/image/slices/generationTopic/action.ts +6 -2
  63. package/tsconfig.json +1 -1
  64. package/.github/workflows/claude-code-review.yml +0 -78
  65. package/.github/workflows/wiki-sync.yml +0 -19
  66. /package/{src → packages/prompts/src}/chains/__tests__/__snapshots__/summaryHistory.test.ts.snap +0 -0
  67. /package/{src → packages/prompts/src}/chains/__tests__/translate.test.ts +0 -0
  68. /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.test.ts +0 -0
  69. /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.ts +0 -0
  70. /package/packages/prompts/src/{files → prompts/files}/file.ts +0 -0
  71. /package/packages/prompts/src/{files → prompts/files}/image.ts +0 -0
  72. /package/packages/prompts/src/{files → prompts/files}/index.ts +0 -0
  73. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/__snapshots__/index.test.ts.snap +0 -0
  74. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/chunk.ts +0 -0
  75. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.ts +0 -0
  76. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/knowledge.ts +0 -0
  77. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/userQuery.ts +0 -0
  78. /package/packages/prompts/src/{plugin → prompts/plugin}/index.test.ts +0 -0
  79. /package/packages/prompts/src/{plugin → prompts/plugin}/index.ts +0 -0
  80. /package/packages/prompts/src/{plugin → prompts/plugin}/tools.test.ts +0 -0
  81. /package/packages/prompts/src/{plugin → prompts/plugin}/tools.ts +0 -0
  82. /package/packages/prompts/src/{systemRole → prompts/systemRole}/index.ts +0 -0
@@ -1,25 +1,15 @@
1
1
  import { Mock, describe, expect, it } from 'vitest';
2
2
 
3
- import { globalHelpers } from '@/store/global/helpers';
4
-
5
3
  import { chainSummaryTags } from '../summaryTags';
6
4
 
7
- // Mock the getCurrentLanguage function
8
- vi.mock('@/store/global/helpers', () => ({
9
- globalHelpers: {
10
- getCurrentLanguage: vi.fn(),
11
- },
12
- }));
13
-
14
5
  describe('chainSummaryTags', () => {
15
6
  it('should create a payload with system and user messages including the provided content and current language', () => {
16
7
  // Arrange
17
8
  const content = '这是一段测试文本';
18
9
  const currentLanguage = 'en-US';
19
- (globalHelpers.getCurrentLanguage as Mock).mockReturnValue(currentLanguage);
20
10
 
21
11
  // Act
22
- const result = chainSummaryTags(content);
12
+ const result = chainSummaryTags(content, currentLanguage);
23
13
 
24
14
  // Assert
25
15
  expect(result).toEqual({
@@ -47,8 +37,5 @@ describe('chainSummaryTags', () => {
47
37
  { content: `输入: {${content}} [${currentLanguage}]`, role: 'user' },
48
38
  ],
49
39
  });
50
-
51
- // Verify that the getCurrentLanguage function was called
52
- expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
53
40
  });
54
41
  });
@@ -1,18 +1,10 @@
1
+ import { OpenAIChatMessage } from '@lobechat/types';
1
2
  import { Mock, describe, expect, it, vi } from 'vitest';
2
3
 
3
4
  import { chatHelpers } from '@/store/chat/helpers';
4
- import { globalHelpers } from '@/store/global/helpers';
5
- import { OpenAIChatMessage } from '@/types/openai/chat';
6
5
 
7
6
  import { chainSummaryTitle } from '../summaryTitle';
8
7
 
9
- // Mock the getCurrentLanguage function
10
- vi.mock('@/store/global/helpers', () => ({
11
- globalHelpers: {
12
- getCurrentLanguage: vi.fn(),
13
- },
14
- }));
15
-
16
8
  // Mock the chatHelpers.getMessagesTokenCount function
17
9
  vi.mock('@/store/chat/helpers', () => ({
18
10
  chatHelpers: {
@@ -29,11 +21,10 @@ describe('chainSummaryTitle', () => {
29
21
  ];
30
22
  const currentLanguage = 'en-US';
31
23
  const tokenCount = 10000; // Arbitrary token count below the GPT-3.5 limit
32
- (globalHelpers.getCurrentLanguage as Mock).mockReturnValue(currentLanguage);
33
24
  (chatHelpers.getMessagesTokenCount as Mock).mockResolvedValue(tokenCount);
34
25
 
35
26
  // Act
36
- const result = await chainSummaryTitle(messages);
27
+ const result = await chainSummaryTitle(messages, currentLanguage);
37
28
 
38
29
  // Assert
39
30
  expect(result).toEqual({
@@ -1,5 +1,5 @@
1
- import { DEFAULT_MODEL } from '@/const/settings';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { DEFAULT_MODEL } from '@lobechat/const';
2
+ import { ChatStreamPayload } from '@lobechat/types';
3
3
 
4
4
  export const chainAbstractChunkText = (text: string): Partial<ChatStreamPayload> => {
5
5
  return {
@@ -1,4 +1,4 @@
1
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
2
2
 
3
3
  export const chainAnswerWithContext = ({
4
4
  context,
@@ -0,0 +1,12 @@
1
+ export * from './abstractChunk';
2
+ export * from './answerWithContext';
3
+ export * from './langDetect';
4
+ export * from './pickEmoji';
5
+ export * from './rewriteQuery';
6
+ export * from './summaryAgentName';
7
+ export * from './summaryDescription';
8
+ export * from './summaryGenerationTitle';
9
+ export * from './summaryHistory';
10
+ export * from './summaryTags';
11
+ export * from './summaryTitle';
12
+ export * from './translate';
@@ -1,4 +1,4 @@
1
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
2
2
 
3
3
  export const chainLangDetect = (content: string): Partial<ChatStreamPayload> => ({
4
4
  messages: [
@@ -1,4 +1,4 @@
1
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
2
2
 
3
3
  /**
4
4
  * pick emoji for user prompt
@@ -1,5 +1,5 @@
1
- import { DEFAULT_REWRITE_QUERY } from '@/const/settings';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { DEFAULT_REWRITE_QUERY } from '@lobechat/const';
2
+ import { ChatStreamPayload } from '@lobechat/types';
3
3
 
4
4
  export const chainRewriteQuery = (
5
5
  query: string,
@@ -1,11 +1,12 @@
1
- import { globalHelpers } from '@/store/global/helpers';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
3
2
 
4
3
  /**
5
4
  * summary agent name for user prompt
6
- * @param content
7
5
  */
8
- export const chainSummaryAgentName = (content: string): Partial<ChatStreamPayload> => ({
6
+ export const chainSummaryAgentName = (
7
+ content: string,
8
+ locale: string,
9
+ ): Partial<ChatStreamPayload> => ({
9
10
  messages: [
10
11
  {
11
12
  content: `你是一名擅长起名的起名大师,名字需要有文学内涵,注重精炼和赋子意境,你需要将用户的描述总结为 10 个字以内的角色,并翻译为目标语言。格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {角色名}`,
@@ -30,6 +31,6 @@ export const chainSummaryAgentName = (content: string): Partial<ChatStreamPayloa
30
31
  role: 'user',
31
32
  },
32
33
  { content: '邮件优化助理', role: 'assistant' },
33
- { content: `输入: {${content}} [${globalHelpers.getCurrentLanguage()}]`, role: 'user' },
34
+ { content: `输入: {${content}} [${locale}]`, role: 'user' },
34
35
  ],
35
36
  });
@@ -1,10 +1,12 @@
1
- import { globalHelpers } from '@/store/global/helpers';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
3
2
 
4
- export const chainSummaryDescription = (content: string): Partial<ChatStreamPayload> => ({
3
+ export const chainSummaryDescription = (
4
+ content: string,
5
+ locale: string,
6
+ ): Partial<ChatStreamPayload> => ({
5
7
  messages: [
6
8
  {
7
- content: `你是一名擅长技能总结的助理,你需要将用户的输入的内容总结为一个角色技能简介,不超过 20 个字。内容需要确保信息清晰、逻辑清晰,并有效地传达角色的技能和经验,需要并翻译为目标语言:${globalHelpers.getCurrentLanguage()}。格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {简介}`,
9
+ content: `你是一名擅长技能总结的助理,你需要将用户的输入的内容总结为一个角色技能简介,不超过 20 个字。内容需要确保信息清晰、逻辑清晰,并有效地传达角色的技能和经验,需要并翻译为目标语言:${locale}。格式要求如下:\n输入: {文本作为JSON引用字符串} [locale]\n输出: {简介}`,
8
10
  role: 'system',
9
11
  },
10
12
  {
@@ -43,7 +45,7 @@ nav: API
43
45
  role: 'user',
44
46
  },
45
47
  { content: '擅长创业计划撰写与咨询', role: 'assistant' },
46
- { content: `输入: {${content}} [${globalHelpers.getCurrentLanguage()}]`, role: 'user' },
48
+ { content: `输入: {${content}} [${locale}]`, role: 'user' },
47
49
  ],
48
50
  temperature: 0,
49
51
  });
@@ -1,19 +1,17 @@
1
- import { globalHelpers } from '@/store/global/helpers';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
3
2
 
4
3
  export const chainSummaryGenerationTitle = (
5
4
  prompts: string[],
6
5
  modal: 'image' | 'video',
6
+ locale: string,
7
7
  ): Partial<ChatStreamPayload> => {
8
- const lang = globalHelpers.getCurrentLanguage();
9
-
10
8
  // Format multiple prompts for better readability
11
9
  const formattedPrompts = prompts.map((prompt, index) => `${index + 1}. ${prompt}`).join('\n');
12
10
 
13
11
  return {
14
12
  messages: [
15
13
  {
16
- content: `你是一位资深的 AI 艺术创作者和语言大师。你需要根据用户提供的 AI ${modal} prompt 总结出一个标题。这个标题应简洁地描述创作的核心内容,将用于标识和管理该系列作品。字数需控制在10个字以内,不需要包含标点符号,输出语言为:${lang}。`,
14
+ content: `你是一位资深的 AI 艺术创作者和语言大师。你需要根据用户提供的 AI ${modal} prompt 总结出一个标题。这个标题应简洁地描述创作的核心内容,将用于标识和管理该系列作品。字数需控制在10个字以内,不需要包含标点符号,输出语言为:${locale}。`,
17
15
  role: 'system',
18
16
  },
19
17
  {
@@ -1,7 +1,6 @@
1
- import { chatHistoryPrompts } from '@lobechat/prompts';
2
- import { ChatMessage } from '@lobechat/types';
1
+ import { ChatMessage, ChatStreamPayload } from '@lobechat/types';
3
2
 
4
- import { ChatStreamPayload } from '@/types/openai/chat';
3
+ import { chatHistoryPrompts } from '../prompts';
5
4
 
6
5
  export const chainSummaryHistory = (messages: ChatMessage[]): Partial<ChatStreamPayload> => ({
7
6
  messages: [
@@ -1,7 +1,6 @@
1
- import { globalHelpers } from '@/store/global/helpers';
2
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
3
2
 
4
- export const chainSummaryTags = (content: string): Partial<ChatStreamPayload> => ({
3
+ export const chainSummaryTags = (content: string, locale: string): Partial<ChatStreamPayload> => ({
5
4
  messages: [
6
5
  {
7
6
  content:
@@ -23,6 +22,6 @@ export const chainSummaryTags = (content: string): Partial<ChatStreamPayload> =>
23
22
  role: 'user',
24
23
  },
25
24
  { content: 'entrepreneurship,planning,consulting', role: 'assistant' },
26
- { content: `输入: {${content}} [${globalHelpers.getCurrentLanguage()}]`, role: 'user' },
25
+ { content: `输入: {${content}} [${locale}]`, role: 'user' },
27
26
  ],
28
27
  });
@@ -1,9 +1,9 @@
1
- import { globalHelpers } from '@/store/global/helpers';
2
1
  import { ChatStreamPayload, OpenAIChatMessage } from '@/types/openai/chat';
3
2
 
4
- export const chainSummaryTitle = (messages: OpenAIChatMessage[]): Partial<ChatStreamPayload> => {
5
- const lang = globalHelpers.getCurrentLanguage();
6
-
3
+ export const chainSummaryTitle = (
4
+ messages: OpenAIChatMessage[],
5
+ locale: string,
6
+ ): Partial<ChatStreamPayload> => {
7
7
  return {
8
8
  messages: [
9
9
  {
@@ -13,7 +13,7 @@ export const chainSummaryTitle = (messages: OpenAIChatMessage[]): Partial<ChatSt
13
13
  {
14
14
  content: `${messages.map((message) => `${message.role}: ${message.content}`).join('\n')}
15
15
 
16
- 请总结上述对话为10个字以内的标题,不需要包含标点符号,输出语言语种为:${lang}`,
16
+ 请总结上述对话为10个字以内的标题,不需要包含标点符号,输出语言语种为:${locale}`,
17
17
  role: 'user',
18
18
  },
19
19
  ],
@@ -1,4 +1,4 @@
1
- import { ChatStreamPayload } from '@/types/openai/chat';
1
+ import { ChatStreamPayload } from '@lobechat/types';
2
2
 
3
3
  export const chainTranslate = (
4
4
  content: string,
@@ -1,5 +1,2 @@
1
- export * from './chatMessages';
2
- export * from './files';
3
- export * from './knowledgeBaseQA';
4
- export * from './plugin';
5
- export * from './systemRole';
1
+ export * from './chains';
2
+ export * from './prompts';
@@ -1,7 +1,6 @@
1
+ import { ChatFileItem, ChatImageItem } from '@lobechat/types';
1
2
  import { describe, expect, it } from 'vitest';
2
3
 
3
- import { ChatFileItem, ChatImageItem } from '@/types/message';
4
-
5
4
  import { filesPrompts } from './index';
6
5
 
7
6
  describe('filesPrompts', () => {
@@ -0,0 +1,5 @@
1
+ export * from './chatMessages';
2
+ export * from './files';
3
+ export * from './knowledgeBaseQA';
4
+ export * from './plugin';
5
+ export * from './systemRole';
@@ -1,8 +1,6 @@
1
+ import { ChatSemanticSearchChunk, KnowledgeItem, KnowledgeType } from '@lobechat/types';
1
2
  import { describe, expect, it } from 'vitest';
2
3
 
3
- import { ChatSemanticSearchChunk } from '@/types/chunk';
4
- import { KnowledgeItem, KnowledgeType } from '@/types/knowledgeBase';
5
-
6
4
  import { knowledgeBaseQAPrompts } from './index';
7
5
 
8
6
  describe('knowledgeBaseQAPrompts', () => {
@@ -326,7 +326,7 @@ export interface AiProviderModelListItem {
326
326
  displayName?: string;
327
327
  enabled: boolean;
328
328
  id: string;
329
- parameters?: Record<string, any>;
329
+ parameters?: ModelParamsSchema;
330
330
  pricing?: Pricing;
331
331
  releasedAt?: string;
332
332
  settings?: AiModelSettings;
@@ -378,7 +378,7 @@ export interface EnabledAiModel {
378
378
  displayName?: string;
379
379
  enabled?: boolean;
380
380
  id: string;
381
- parameters?: Record<string, any>;
381
+ parameters?: ModelParamsSchema;
382
382
  providerId: string;
383
383
  settings?: AiModelSettings;
384
384
  sort?: number;
@@ -3,4 +3,7 @@ export * from './chunk';
3
3
  export * from './fetch';
4
4
  export * from './knowledgeBase';
5
5
  export * from './message';
6
+ // FIXME: I think we need a refactor for the "openai" types
7
+ // it more likes the UI message payload
8
+ export * from './openai/chat';
6
9
  export * from './trace';
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
 
3
+ import { ModelParamsSchema } from '@/libs/standard-parameters';
3
4
  import { AiModelType, Pricing } from '@/types/aiModel';
4
5
  import { AiProviderSettings } from '@/types/aiProvider';
5
6
 
@@ -41,6 +42,8 @@ export interface ChatModelCard {
41
42
  */
42
43
  legacy?: boolean;
43
44
  maxOutput?: number;
45
+ parameters?: ModelParamsSchema;
46
+
44
47
  pricing?: Pricing;
45
48
 
46
49
  /**
@@ -3,6 +3,8 @@
3
3
  import { memo } from 'react';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
+ import { useAiInfraStore } from '@/store/aiInfra';
7
+
6
8
  import ModelList from '../../features/ModelList';
7
9
  import ProviderConfig, { ProviderConfigProps } from '../../features/ProviderConfig';
8
10
 
@@ -10,6 +12,9 @@ interface ProviderDetailProps extends ProviderConfigProps {
10
12
  showConfig?: boolean;
11
13
  }
12
14
  const ProviderDetail = memo<ProviderDetailProps>(({ showConfig = true, ...card }) => {
15
+ const useFetchAiProviderItem = useAiInfraStore((s) => s.useFetchAiProviderItem);
16
+ useFetchAiProviderItem(card.id);
17
+
13
18
  return (
14
19
  <Flexbox gap={24} paddingBlock={8}>
15
20
  {/* ↓ cloud slot ↓ */}
@@ -143,7 +143,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
143
143
  const { cx, styles, theme } = useStyles();
144
144
 
145
145
  const [
146
- useFetchAiProviderItem,
146
+ data,
147
147
  updateAiProviderConfig,
148
148
  enabled,
149
149
  isLoading,
@@ -153,7 +153,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
153
153
  isProviderEndpointNotEmpty,
154
154
  isProviderApiKeyNotEmpty,
155
155
  ] = useAiInfraStore((s) => [
156
- s.useFetchAiProviderItem,
156
+ aiProviderSelectors.activeProviderConfig(s),
157
157
  s.updateAiProviderConfig,
158
158
  aiProviderSelectors.isProviderEnabled(id)(s),
159
159
  aiProviderSelectors.isAiProviderConfigLoading(id)(s),
@@ -164,8 +164,6 @@ const ProviderConfig = memo<ProviderConfigProps>(
164
164
  aiProviderSelectors.isActiveProviderApiKeyNotEmpty(s),
165
165
  ]);
166
166
 
167
- const { data } = useFetchAiProviderItem(id);
168
-
169
167
  useLayoutEffect(() => {
170
168
  if (isLoading) return;
171
169
 
@@ -20,6 +20,8 @@ export const fluxKreaParamsSchema: ModelParamsSchema = {
20
20
 
21
21
  export const qwenImageParamsSchema: ModelParamsSchema = {
22
22
  cfg: { default: 2.5, max: 20, min: 0, step: 0.1 },
23
+ // 实测 fal 宽高 最大就支持到 1536
24
+ // 默认值取自 https://chat.qwen.ai/ 官网的默认值
23
25
  height: { default: 1328, max: 1536, min: 512, step: 1 },
24
26
  prompt: { default: '' },
25
27
  seed: { default: null },
@@ -27,6 +29,16 @@ export const qwenImageParamsSchema: ModelParamsSchema = {
27
29
  width: { default: 1328, max: 1536, min: 512, step: 1 },
28
30
  };
29
31
 
32
+ export const qwenEditParamsSchema: ModelParamsSchema = {
33
+ cfg: { default: 4, max: 20, min: 0, step: 0.1 },
34
+ height: { default: 1328, max: 1536, min: 512, step: 1 },
35
+ imageUrl: { default: null },
36
+ prompt: { default: '' },
37
+ seed: { default: null },
38
+ steps: { default: 30, max: 50, min: 2, step: 1 },
39
+ width: { default: 1328, max: 1536, min: 512, step: 1 },
40
+ };
41
+
30
42
  const falImageModels: AIImageModelCard[] = [
31
43
  {
32
44
  description: '专注于图像编辑任务的FLUX.1模型,支持文本和图像输入。',
@@ -112,7 +124,20 @@ const falImageModels: AIImageModelCard[] = [
112
124
  },
113
125
  {
114
126
  description:
115
- 'Qwen团队带来的强大生图模型,具有令人印象深刻的中文文字生成能力和多样图片视觉风格。',
127
+ 'Qwen 团队发布的专业图像编辑模型,支持语义编辑和外观编辑,能够精确编辑中英文文字,实现风格转换、对象旋转等高质量图像编辑。',
128
+ displayName: 'Qwen Edit',
129
+ enabled: true,
130
+ id: 'qwen-image-edit',
131
+ parameters: qwenEditParamsSchema,
132
+ pricing: {
133
+ units: [{ name: 'imageGeneration', rate: 0.025, strategy: 'fixed', unit: 'image' }],
134
+ },
135
+ releasedAt: '2025-08-19',
136
+ type: 'image',
137
+ },
138
+ {
139
+ description:
140
+ 'Qwen 团队带来的强大生图模型,具有令人印象深刻的中文文字生成能力和多样图片视觉风格。',
116
141
  displayName: 'Qwen Image',
117
142
  enabled: true,
118
143
  id: 'qwen-image',
@@ -1,13 +1,16 @@
1
+ import {
2
+ chainPickEmoji,
3
+ chainSummaryAgentName,
4
+ chainSummaryDescription,
5
+ chainSummaryTags,
6
+ } from '@lobechat/prompts';
1
7
  import { TraceNameMap, TracePayload, TraceTopicType } from '@lobechat/types';
2
8
  import { getSingletonAnalyticsOptional } from '@lobehub/analytics';
3
9
  import type { PartialDeep } from 'type-fest';
4
10
  import { StateCreator } from 'zustand/vanilla';
5
11
 
6
- import { chainPickEmoji } from '@/chains/pickEmoji';
7
- import { chainSummaryAgentName } from '@/chains/summaryAgentName';
8
- import { chainSummaryDescription } from '@/chains/summaryDescription';
9
- import { chainSummaryTags } from '@/chains/summaryTags';
10
12
  import { chatService } from '@/services/chat';
13
+ import { globalHelpers } from '@/store/global/helpers';
11
14
  import { useUserStore } from '@/store/user';
12
15
  import { systemAgentSelectors } from '@/store/user/slices/settings/selectors';
13
16
  import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
@@ -118,7 +121,10 @@ export const store: StateCreator<Store, [['zustand/devtools', never]]> = (set, g
118
121
  updateLoadingState('description', loading);
119
122
  },
120
123
  onMessageHandle: streamUpdateMetaString('description'),
121
- params: merge(get().internal_getSystemAgentForMeta(), chainSummaryDescription(systemRole)),
124
+ params: merge(
125
+ get().internal_getSystemAgentForMeta(),
126
+ chainSummaryDescription(systemRole, globalHelpers.getCurrentLanguage()),
127
+ ),
122
128
  trace: get().getCurrentTracePayload({ traceName: TraceNameMap.SummaryAgentDescription }),
123
129
  });
124
130
  },
@@ -145,7 +151,10 @@ export const store: StateCreator<Store, [['zustand/devtools', never]]> = (set, g
145
151
  onMessageHandle: streamUpdateMetaArray('tags'),
146
152
  params: merge(
147
153
  get().internal_getSystemAgentForMeta(),
148
- chainSummaryTags([meta.title, meta.description, systemRole].filter(Boolean).join(',')),
154
+ chainSummaryTags(
155
+ [meta.title, meta.description, systemRole].filter(Boolean).join(','),
156
+ globalHelpers.getCurrentLanguage(),
157
+ ),
149
158
  ),
150
159
  trace: get().getCurrentTracePayload({ traceName: TraceNameMap.SummaryAgentTags }),
151
160
  });
@@ -172,7 +181,10 @@ export const store: StateCreator<Store, [['zustand/devtools', never]]> = (set, g
172
181
  onMessageHandle: streamUpdateMetaString('title'),
173
182
  params: merge(
174
183
  get().internal_getSystemAgentForMeta(),
175
- chainSummaryAgentName([meta.description, systemRole].filter(Boolean).join(',')),
184
+ chainSummaryAgentName(
185
+ [meta.description, systemRole].filter(Boolean).join(','),
186
+ globalHelpers.getCurrentLanguage(),
187
+ ),
176
188
  ),
177
189
  trace: get().getCurrentTracePayload({ traceName: TraceNameMap.SummaryAgentTitle }),
178
190
  });
@@ -1,9 +1,9 @@
1
1
  import { ModelProvider } from '@lobechat/model-runtime';
2
+ import { chainAnswerWithContext } from '@lobechat/prompts';
2
3
  import { TRPCError } from '@trpc/server';
3
4
  import OpenAI from 'openai';
4
5
  import { z } from 'zod';
5
6
 
6
- import { chainAnswerWithContext } from '@/chains/answerWithContext';
7
7
  import { DEFAULT_EMBEDDING_MODEL, DEFAULT_MODEL } from '@/const/settings';
8
8
  import { ChunkModel } from '@/database/models/chunk';
9
9
  import { EmbeddingModel } from '@/database/models/embedding';
@@ -48,7 +48,10 @@ describe('getModelListByType', () => {
48
48
  abilities: {} as ModelAbilities,
49
49
  displayName: 'DALL-E 3',
50
50
  enabled: true,
51
- parameters: { size: '1024x1024', quality: 'standard' },
51
+ parameters: {
52
+ prompt: { default: '' },
53
+ size: { default: '1024x1024', enum: ['512x512', '1024x1024', '1536x1536'] }
54
+ },
52
55
  },
53
56
  {
54
57
  id: 'midjourney',
@@ -89,7 +92,10 @@ describe('getModelListByType', () => {
89
92
  contextWindowTokens: undefined,
90
93
  displayName: 'DALL-E 3',
91
94
  id: 'dall-e-3',
92
- parameters: { size: '1024x1024', quality: 'standard' },
95
+ parameters: {
96
+ prompt: { default: '' },
97
+ size: { default: '1024x1024', enum: ['512x512', '1024x1024', '1536x1536'] }
98
+ },
93
99
  });
94
100
  });
95
101
 
@@ -1,7 +1,7 @@
1
+ import { chainSummaryHistory } from '@lobechat/prompts';
1
2
  import { TraceNameMap } from '@lobechat/types';
2
3
  import { StateCreator } from 'zustand/vanilla';
3
4
 
4
- import { chainSummaryHistory } from '@/chains/summaryHistory';
5
5
  import { chatService } from '@/services/chat';
6
6
  import { topicService } from '@/services/topic';
7
7
  import { ChatStore } from '@/store/chat';
@@ -1,6 +1,6 @@
1
+ import { chainRewriteQuery } from '@lobechat/prompts';
1
2
  import { StateCreator } from 'zustand/vanilla';
2
3
 
3
- import { chainRewriteQuery } from '@/chains/rewriteQuery';
4
4
  import { chatService } from '@/services/chat';
5
5
  import { ragService } from '@/services/rag';
6
6
  import { useAgentStore } from '@/store/agent';
@@ -1,10 +1,10 @@
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 { chainSummaryTitle } from '@lobechat/prompts';
3
4
  import isEqual from 'fast-deep-equal';
4
5
  import { SWRResponse, mutate } from 'swr';
5
6
  import { StateCreator } from 'zustand/vanilla';
6
7
 
7
- import { chainSummaryTitle } from '@/chains/summaryTitle';
8
8
  import { LOADING_FLAT, THREAD_DRAFT_ID } from '@/const/message';
9
9
  import { isDeprecatedEdition } from '@/const/version';
10
10
  import { useClientDataSWR } from '@/libs/swr';
@@ -12,6 +12,7 @@ import { chatService } from '@/services/chat';
12
12
  import { threadService } from '@/services/thread';
13
13
  import { threadSelectors } from '@/store/chat/selectors';
14
14
  import { ChatStore } from '@/store/chat/store';
15
+ import { globalHelpers } from '@/store/global/helpers';
15
16
  import { useSessionStore } from '@/store/session';
16
17
  import { useUserStore } from '@/store/user';
17
18
  import { systemAgentSelectors } from '@/store/user/selectors';
@@ -280,7 +281,7 @@ export const chatThreadMessage: StateCreator<
280
281
 
281
282
  internal_updateThreadTitleInSummary(threadId, output);
282
283
  },
283
- params: merge(threadConfig, chainSummaryTitle(messages)),
284
+ params: merge(threadConfig, chainSummaryTitle(messages, globalHelpers.getCurrentLanguage())),
284
285
  });
285
286
  },
286
287
 
@@ -1,13 +1,13 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
2
2
  // Note: To make the code more logic and readable, we just disable the auto sort key eslint rule
3
3
  // DON'T REMOVE THE FIRST LINE
4
+ import { chainSummaryTitle } from '@lobechat/prompts';
4
5
  import { TraceNameMap } from '@lobechat/types';
5
6
  import isEqual from 'fast-deep-equal';
6
7
  import { t } from 'i18next';
7
8
  import useSWR, { SWRResponse, mutate } from 'swr';
8
9
  import { StateCreator } from 'zustand/vanilla';
9
10
 
10
- import { chainSummaryTitle } from '@/chains/summaryTitle';
11
11
  import { message } from '@/components/AntdStaticMethods';
12
12
  import { LOADING_FLAT } from '@/const/message';
13
13
  import { useClientDataSWR } from '@/libs/swr';
@@ -16,6 +16,7 @@ import { messageService } from '@/services/message';
16
16
  import { topicService } from '@/services/topic';
17
17
  import { CreateTopicParams } from '@/services/topic/type';
18
18
  import type { ChatStore } from '@/store/chat';
19
+ import { globalHelpers } from '@/store/global/helpers';
19
20
  import { useUserStore } from '@/store/user';
20
21
  import { systemAgentSelectors } from '@/store/user/selectors';
21
22
  import { ChatMessage } from '@/types/message';
@@ -167,7 +168,7 @@ export const chatTopic: StateCreator<
167
168
 
168
169
  internal_updateTopicTitleInSummary(topicId, output);
169
170
  },
170
- params: merge(topicConfig, chainSummaryTitle(messages)),
171
+ params: merge(topicConfig, chainSummaryTitle(messages, globalHelpers.getCurrentLanguage())),
171
172
  trace: get().getCurrentTracePayload({ traceName: TraceNameMap.SummaryTopicTitle, topicId }),
172
173
  });
173
174
  },
@@ -1,8 +1,8 @@
1
+ import { chainLangDetect } from '@lobechat/prompts';
2
+ import { chainTranslate } from '@lobechat/prompts';
1
3
  import { act, renderHook } from '@testing-library/react';
2
4
  import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
5
 
4
- import { chainLangDetect } from '@/chains/langDetect';
5
- import { chainTranslate } from '@/chains/translate';
6
6
  import { chatService } from '@/services/chat';
7
7
  import { messageService } from '@/services/message';
8
8
  import { messageMapKey } from '@/store/chat/utils/messageMapKey';
@@ -1,9 +1,8 @@
1
+ import { chainLangDetect , chainTranslate } from '@lobechat/prompts';
1
2
  import { TraceNameMap, TracePayload } from '@lobechat/types';
2
3
  import { produce } from 'immer';
3
4
  import { StateCreator } from 'zustand/vanilla';
4
5
 
5
- import { chainLangDetect } from '@/chains/langDetect';
6
- import { chainTranslate } from '@/chains/translate';
7
6
  import { supportLocales } from '@/locales/resources';
8
7
  import { chatService } from '@/services/chat';
9
8
  import { messageService } from '@/services/message';