@lobehub/chat 1.133.2 → 1.133.4

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 (112) hide show
  1. package/.github/workflows/claude-translator.yml +2 -3
  2. package/.github/workflows/issue-auto-comments.yml +4 -9
  3. package/.github/workflows/issue-close-require.yml +3 -6
  4. package/CHANGELOG.md +66 -0
  5. package/changelog/v1.json +24 -0
  6. package/locales/ar/image.json +7 -0
  7. package/locales/ar/models.json +1 -1
  8. package/locales/bg-BG/image.json +7 -0
  9. package/locales/de-DE/image.json +7 -0
  10. package/locales/en-US/image.json +7 -0
  11. package/locales/es-ES/image.json +7 -0
  12. package/locales/es-ES/tool.json +1 -1
  13. package/locales/fa-IR/image.json +7 -0
  14. package/locales/fa-IR/models.json +1 -1
  15. package/locales/fr-FR/image.json +7 -0
  16. package/locales/fr-FR/models.json +1 -1
  17. package/locales/it-IT/image.json +7 -0
  18. package/locales/ja-JP/image.json +7 -0
  19. package/locales/ko-KR/image.json +7 -0
  20. package/locales/nl-NL/image.json +7 -0
  21. package/locales/pl-PL/image.json +7 -0
  22. package/locales/pt-BR/image.json +7 -0
  23. package/locales/ru-RU/image.json +7 -0
  24. package/locales/ru-RU/tool.json +1 -1
  25. package/locales/tr-TR/image.json +7 -0
  26. package/locales/tr-TR/models.json +1 -1
  27. package/locales/vi-VN/image.json +7 -0
  28. package/locales/zh-CN/image.json +7 -0
  29. package/locales/zh-TW/image.json +7 -0
  30. package/package.json +4 -5
  31. package/packages/const/package.json +4 -0
  32. package/packages/const/src/currency.ts +2 -0
  33. package/packages/const/src/index.ts +1 -0
  34. package/packages/model-bank/package.json +2 -1
  35. package/packages/model-bank/src/aiModels/aihubmix.ts +34 -1
  36. package/packages/model-bank/src/aiModels/anthropic.ts +3 -64
  37. package/packages/model-bank/src/aiModels/google.ts +6 -0
  38. package/packages/model-bank/src/aiModels/novita.ts +2 -2
  39. package/packages/model-bank/src/aiModels/openai.ts +6 -22
  40. package/packages/model-bank/src/aiModels/qwen.ts +21 -0
  41. package/packages/model-bank/src/aiModels/zhipu.ts +255 -62
  42. package/packages/model-bank/src/standard-parameters/index.ts +56 -46
  43. package/packages/model-runtime/package.json +1 -0
  44. package/packages/model-runtime/src/core/RouterRuntime/createRuntime.ts +4 -2
  45. package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +12 -2
  46. package/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts +16 -5
  47. package/packages/model-runtime/src/core/streams/anthropic.ts +25 -36
  48. package/packages/model-runtime/src/core/streams/google/google-ai.test.ts +1 -1
  49. package/packages/model-runtime/src/core/streams/google/index.ts +18 -42
  50. package/packages/model-runtime/src/core/streams/openai/openai.test.ts +7 -10
  51. package/packages/model-runtime/src/core/streams/openai/openai.ts +14 -11
  52. package/packages/model-runtime/src/core/streams/openai/responsesStream.ts +11 -5
  53. package/packages/model-runtime/src/core/streams/protocol.ts +25 -6
  54. package/packages/model-runtime/src/core/streams/qwen.ts +2 -2
  55. package/packages/model-runtime/src/core/streams/spark.ts +3 -3
  56. package/packages/model-runtime/src/core/streams/vertex-ai.test.ts +2 -2
  57. package/packages/model-runtime/src/core/streams/vertex-ai.ts +14 -23
  58. package/packages/model-runtime/src/core/usageConverters/anthropic.test.ts +99 -0
  59. package/packages/model-runtime/src/core/usageConverters/anthropic.ts +73 -0
  60. package/packages/model-runtime/src/core/usageConverters/google-ai.test.ts +88 -0
  61. package/packages/model-runtime/src/core/usageConverters/google-ai.ts +55 -0
  62. package/packages/model-runtime/src/core/usageConverters/index.ts +4 -0
  63. package/packages/model-runtime/src/core/usageConverters/openai.test.ts +429 -0
  64. package/packages/model-runtime/src/core/usageConverters/openai.ts +152 -0
  65. package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts +455 -0
  66. package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts +293 -0
  67. package/packages/model-runtime/src/core/usageConverters/utils/computeImageCost.test.ts +47 -0
  68. package/packages/model-runtime/src/core/usageConverters/utils/computeImageCost.ts +121 -0
  69. package/packages/model-runtime/src/core/usageConverters/utils/index.ts +11 -0
  70. package/packages/model-runtime/src/core/usageConverters/utils/withUsageCost.ts +19 -0
  71. package/packages/model-runtime/src/index.ts +2 -0
  72. package/packages/model-runtime/src/providers/anthropic/index.test.ts +0 -12
  73. package/packages/model-runtime/src/providers/anthropic/index.ts +48 -1
  74. package/packages/model-runtime/src/providers/google/createImage.ts +11 -2
  75. package/packages/model-runtime/src/providers/google/index.ts +8 -1
  76. package/packages/model-runtime/src/providers/novita/index.ts +2 -1
  77. package/packages/model-runtime/src/providers/novita/type.ts +4 -0
  78. package/packages/model-runtime/src/providers/ollamacloud/index.ts +1 -1
  79. package/packages/model-runtime/src/providers/openai/__snapshots__/index.test.ts.snap +7 -0
  80. package/packages/model-runtime/src/providers/openrouter/index.ts +11 -4
  81. package/packages/model-runtime/src/providers/zhipu/index.ts +3 -1
  82. package/packages/model-runtime/src/types/chat.ts +5 -3
  83. package/packages/model-runtime/src/types/image.ts +20 -9
  84. package/packages/model-runtime/src/utils/getModelPricing.ts +36 -0
  85. package/packages/obervability-otel/package.json +2 -2
  86. package/packages/ssrf-safe-fetch/index.test.ts +343 -0
  87. package/packages/ssrf-safe-fetch/index.ts +37 -0
  88. package/packages/ssrf-safe-fetch/package.json +17 -0
  89. package/packages/ssrf-safe-fetch/vitest.config.mts +10 -0
  90. package/packages/types/src/message/base.ts +43 -17
  91. package/packages/utils/package.json +0 -1
  92. package/packages/utils/src/client/apiKeyManager.test.ts +70 -0
  93. package/packages/utils/src/client/apiKeyManager.ts +41 -0
  94. package/packages/utils/src/client/index.ts +2 -0
  95. package/packages/utils/src/fetch/fetchSSE.ts +4 -4
  96. package/packages/utils/src/index.ts +1 -0
  97. package/packages/utils/src/toolManifest.ts +2 -1
  98. package/src/app/(backend)/webapi/proxy/route.ts +2 -13
  99. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatMinimap/index.tsx +51 -23
  100. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/QualitySelect.tsx +23 -0
  101. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/index.tsx +9 -0
  102. package/src/config/modelProviders/anthropic.ts +0 -30
  103. package/src/config/modelProviders/ollamacloud.ts +1 -0
  104. package/src/config/modelProviders/zhipu.ts +4 -21
  105. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +13 -13
  106. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +1 -1
  107. package/src/features/Conversation/components/WideScreenContainer/index.tsx +3 -0
  108. package/src/locales/default/image.ts +7 -0
  109. package/src/server/modules/EdgeConfig/index.ts +1 -1
  110. package/src/server/routers/async/image.ts +9 -1
  111. package/src/services/_auth.ts +12 -12
  112. package/src/services/chat/contextEngineering.ts +2 -3
@@ -1,6 +1,6 @@
1
- import type { ModelTokensUsage } from '@lobechat/model-runtime';
2
1
  import { LobeDefaultAiModelListItem } from 'model-bank';
3
2
 
3
+ import type { ModelTokensUsage } from '@/types/message';
4
4
  import { getAudioInputUnitRate, getAudioOutputUnitRate } from '@/utils/pricing';
5
5
 
6
6
  import { getPrice } from './pricing';
@@ -11,6 +11,9 @@ import { systemStatusSelectors } from '@/store/global/selectors';
11
11
  const useStyles = createStyles(({ css, token }) => ({
12
12
  container: css`
13
13
  align-self: center;
14
+
15
+ /* Leave some space for the minimap */
16
+ padding-inline: 12px;
14
17
  transition: width 0.25s ${token.motionEaseInOut};
15
18
  `,
16
19
  }));
@@ -30,6 +30,13 @@ export default {
30
30
  prompt: {
31
31
  placeholder: '描述你想要生成的内容',
32
32
  },
33
+ quality: {
34
+ label: '图片质量',
35
+ options: {
36
+ hd: '高清',
37
+ standard: '标准',
38
+ },
39
+ },
33
40
  seed: {
34
41
  label: '种子',
35
42
  random: '随机种子',
@@ -2,7 +2,7 @@ import { EdgeConfigClient, createClient } from '@vercel/edge-config';
2
2
 
3
3
  import { appEnv } from '@/envs/app';
4
4
 
5
- import { EdgeConfigData } from './types';
5
+ import type { EdgeConfigData } from './types';
6
6
 
7
7
  export class EdgeConfig {
8
8
  get client(): EdgeConfigClient {
@@ -134,13 +134,14 @@ export const imageRouter = router({
134
134
  try {
135
135
  const imageGenerationPromise = async (signal: AbortSignal) => {
136
136
  log('Initializing agent runtime for provider: %s', provider);
137
+
137
138
  const agentRuntime = await initModelRuntimeWithUserPayload(provider, ctx.jwtPayload);
138
139
 
139
140
  // Check if operation has been cancelled
140
141
  checkAbortSignal(signal);
141
142
 
142
143
  log('Agent runtime initialized, calling createImage');
143
- const response = await agentRuntime.createImage({
144
+ const response = await agentRuntime.createImage!({
144
145
  model,
145
146
  params: params as unknown as RuntimeImageGenParams,
146
147
  });
@@ -150,6 +151,13 @@ export const imageRouter = router({
150
151
  throw new Error('Create image response is empty');
151
152
  }
152
153
 
154
+ log('Create image response: %O', {
155
+ ...response,
156
+ imageUrl: response.imageUrl?.startsWith('data:')
157
+ ? response.imageUrl.slice(0, IMAGE_URL_PREVIEW_LENGTH) + '...'
158
+ : response.imageUrl,
159
+ });
160
+
153
161
  // Check if operation has been cancelled
154
162
  checkAbortSignal(signal);
155
163
 
@@ -1,17 +1,17 @@
1
- import { ClientSecretPayload } from '@lobechat/types';
2
- import { ModelProvider } from 'model-bank';
3
-
4
- import { LOBE_CHAT_AUTH_HEADER } from '@/const/auth';
5
- import { isDeprecatedEdition } from '@/const/version';
6
- import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
7
- import { useUserStore } from '@/store/user';
8
- import { keyVaultsConfigSelectors, userProfileSelectors } from '@/store/user/selectors';
1
+ import { LOBE_CHAT_AUTH_HEADER, isDeprecatedEdition } from '@lobechat/const';
9
2
  import {
10
3
  AWSBedrockKeyVault,
11
4
  AzureOpenAIKeyVault,
5
+ ClientSecretPayload,
12
6
  CloudflareKeyVault,
13
7
  OpenAICompatibleKeyVault,
14
- } from '@/types/user/settings';
8
+ } from '@lobechat/types';
9
+ import { clientApiKeyManager } from '@lobechat/utils/client';
10
+ import { ModelProvider } from 'model-bank';
11
+
12
+ import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
13
+ import { useUserStore } from '@/store/user';
14
+ import { keyVaultsConfigSelectors, userProfileSelectors } from '@/store/user/selectors';
15
15
  import { obfuscatePayloadWithXOR } from '@/utils/client/xor-obfuscation';
16
16
 
17
17
  export const getProviderAuthPayload = (
@@ -49,7 +49,7 @@ export const getProviderAuthPayload = (
49
49
 
50
50
  case ModelProvider.Azure: {
51
51
  return {
52
- apiKey: keyVaults.apiKey,
52
+ apiKey: clientApiKeyManager.pick(keyVaults.apiKey),
53
53
 
54
54
  apiVersion: keyVaults.apiVersion,
55
55
  /** @deprecated */
@@ -64,7 +64,7 @@ export const getProviderAuthPayload = (
64
64
 
65
65
  case ModelProvider.Cloudflare: {
66
66
  return {
67
- apiKey: keyVaults?.apiKey,
67
+ apiKey: clientApiKeyManager.pick(keyVaults?.apiKey),
68
68
 
69
69
  baseURLOrAccountID: keyVaults?.baseURLOrAccountID,
70
70
  /** @deprecated */
@@ -73,7 +73,7 @@ export const getProviderAuthPayload = (
73
73
  }
74
74
 
75
75
  default: {
76
- return { apiKey: keyVaults?.apiKey, baseURL: keyVaults?.baseURL };
76
+ return { apiKey: clientApiKeyManager.pick(keyVaults?.apiKey), baseURL: keyVaults?.baseURL };
77
77
  }
78
78
  }
79
79
  };
@@ -1,4 +1,4 @@
1
- import { INBOX_SESSION_ID, isDesktop, isServerMode } from '@lobechat/const';
1
+ import { INBOX_GUIDE_SYSTEMROLE, INBOX_SESSION_ID, isDesktop, isServerMode } from '@lobechat/const';
2
2
  import {
3
3
  type AgentState,
4
4
  ContextEngine,
@@ -16,12 +16,11 @@ import {
16
16
  } from '@lobechat/context-engine';
17
17
  import { historySummaryPrompt } from '@lobechat/prompts';
18
18
  import { ChatMessage, OpenAIChatMessage } from '@lobechat/types';
19
+ import { VARIABLE_GENERATORS } from '@lobechat/utils/client';
19
20
 
20
- import { INBOX_GUIDE_SYSTEMROLE } from '@/const/guide';
21
21
  import { isCanUseFC } from '@/helpers/isCanUseFC';
22
22
  import { getToolStoreState } from '@/store/tool';
23
23
  import { toolSelectors } from '@/store/tool/selectors';
24
- import { VARIABLE_GENERATORS } from '@/utils/client/parserPlaceholder';
25
24
  import { genToolCallingName } from '@/utils/toolCall';
26
25
 
27
26
  import { isCanUseVideo, isCanUseVision } from './helper';