@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.
- package/.github/workflows/claude-translator.yml +2 -3
- package/.github/workflows/issue-auto-comments.yml +4 -9
- package/.github/workflows/issue-close-require.yml +3 -6
- package/CHANGELOG.md +66 -0
- package/changelog/v1.json +24 -0
- package/locales/ar/image.json +7 -0
- package/locales/ar/models.json +1 -1
- package/locales/bg-BG/image.json +7 -0
- package/locales/de-DE/image.json +7 -0
- package/locales/en-US/image.json +7 -0
- package/locales/es-ES/image.json +7 -0
- package/locales/es-ES/tool.json +1 -1
- package/locales/fa-IR/image.json +7 -0
- package/locales/fa-IR/models.json +1 -1
- package/locales/fr-FR/image.json +7 -0
- package/locales/fr-FR/models.json +1 -1
- package/locales/it-IT/image.json +7 -0
- package/locales/ja-JP/image.json +7 -0
- package/locales/ko-KR/image.json +7 -0
- package/locales/nl-NL/image.json +7 -0
- package/locales/pl-PL/image.json +7 -0
- package/locales/pt-BR/image.json +7 -0
- package/locales/ru-RU/image.json +7 -0
- package/locales/ru-RU/tool.json +1 -1
- package/locales/tr-TR/image.json +7 -0
- package/locales/tr-TR/models.json +1 -1
- package/locales/vi-VN/image.json +7 -0
- package/locales/zh-CN/image.json +7 -0
- package/locales/zh-TW/image.json +7 -0
- package/package.json +4 -5
- package/packages/const/package.json +4 -0
- package/packages/const/src/currency.ts +2 -0
- package/packages/const/src/index.ts +1 -0
- package/packages/model-bank/package.json +2 -1
- package/packages/model-bank/src/aiModels/aihubmix.ts +34 -1
- package/packages/model-bank/src/aiModels/anthropic.ts +3 -64
- package/packages/model-bank/src/aiModels/google.ts +6 -0
- package/packages/model-bank/src/aiModels/novita.ts +2 -2
- package/packages/model-bank/src/aiModels/openai.ts +6 -22
- package/packages/model-bank/src/aiModels/qwen.ts +21 -0
- package/packages/model-bank/src/aiModels/zhipu.ts +255 -62
- package/packages/model-bank/src/standard-parameters/index.ts +56 -46
- package/packages/model-runtime/package.json +1 -0
- package/packages/model-runtime/src/core/RouterRuntime/createRuntime.ts +4 -2
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +12 -2
- package/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts +16 -5
- package/packages/model-runtime/src/core/streams/anthropic.ts +25 -36
- package/packages/model-runtime/src/core/streams/google/google-ai.test.ts +1 -1
- package/packages/model-runtime/src/core/streams/google/index.ts +18 -42
- package/packages/model-runtime/src/core/streams/openai/openai.test.ts +7 -10
- package/packages/model-runtime/src/core/streams/openai/openai.ts +14 -11
- package/packages/model-runtime/src/core/streams/openai/responsesStream.ts +11 -5
- package/packages/model-runtime/src/core/streams/protocol.ts +25 -6
- package/packages/model-runtime/src/core/streams/qwen.ts +2 -2
- package/packages/model-runtime/src/core/streams/spark.ts +3 -3
- package/packages/model-runtime/src/core/streams/vertex-ai.test.ts +2 -2
- package/packages/model-runtime/src/core/streams/vertex-ai.ts +14 -23
- package/packages/model-runtime/src/core/usageConverters/anthropic.test.ts +99 -0
- package/packages/model-runtime/src/core/usageConverters/anthropic.ts +73 -0
- package/packages/model-runtime/src/core/usageConverters/google-ai.test.ts +88 -0
- package/packages/model-runtime/src/core/usageConverters/google-ai.ts +55 -0
- package/packages/model-runtime/src/core/usageConverters/index.ts +4 -0
- package/packages/model-runtime/src/core/usageConverters/openai.test.ts +429 -0
- package/packages/model-runtime/src/core/usageConverters/openai.ts +152 -0
- package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts +455 -0
- package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts +293 -0
- package/packages/model-runtime/src/core/usageConverters/utils/computeImageCost.test.ts +47 -0
- package/packages/model-runtime/src/core/usageConverters/utils/computeImageCost.ts +121 -0
- package/packages/model-runtime/src/core/usageConverters/utils/index.ts +11 -0
- package/packages/model-runtime/src/core/usageConverters/utils/withUsageCost.ts +19 -0
- package/packages/model-runtime/src/index.ts +2 -0
- package/packages/model-runtime/src/providers/anthropic/index.test.ts +0 -12
- package/packages/model-runtime/src/providers/anthropic/index.ts +48 -1
- package/packages/model-runtime/src/providers/google/createImage.ts +11 -2
- package/packages/model-runtime/src/providers/google/index.ts +8 -1
- package/packages/model-runtime/src/providers/novita/index.ts +2 -1
- package/packages/model-runtime/src/providers/novita/type.ts +4 -0
- package/packages/model-runtime/src/providers/ollamacloud/index.ts +1 -1
- package/packages/model-runtime/src/providers/openai/__snapshots__/index.test.ts.snap +7 -0
- package/packages/model-runtime/src/providers/openrouter/index.ts +11 -4
- package/packages/model-runtime/src/providers/zhipu/index.ts +3 -1
- package/packages/model-runtime/src/types/chat.ts +5 -3
- package/packages/model-runtime/src/types/image.ts +20 -9
- package/packages/model-runtime/src/utils/getModelPricing.ts +36 -0
- package/packages/obervability-otel/package.json +2 -2
- package/packages/ssrf-safe-fetch/index.test.ts +343 -0
- package/packages/ssrf-safe-fetch/index.ts +37 -0
- package/packages/ssrf-safe-fetch/package.json +17 -0
- package/packages/ssrf-safe-fetch/vitest.config.mts +10 -0
- package/packages/types/src/message/base.ts +43 -17
- package/packages/utils/package.json +0 -1
- package/packages/utils/src/client/apiKeyManager.test.ts +70 -0
- package/packages/utils/src/client/apiKeyManager.ts +41 -0
- package/packages/utils/src/client/index.ts +2 -0
- package/packages/utils/src/fetch/fetchSSE.ts +4 -4
- package/packages/utils/src/index.ts +1 -0
- package/packages/utils/src/toolManifest.ts +2 -1
- package/src/app/(backend)/webapi/proxy/route.ts +2 -13
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatMinimap/index.tsx +51 -23
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/QualitySelect.tsx +23 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/index.tsx +9 -0
- package/src/config/modelProviders/anthropic.ts +0 -30
- package/src/config/modelProviders/ollamacloud.ts +1 -0
- package/src/config/modelProviders/zhipu.ts +4 -21
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +13 -13
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +1 -1
- package/src/features/Conversation/components/WideScreenContainer/index.tsx +3 -0
- package/src/locales/default/image.ts +7 -0
- package/src/server/modules/EdgeConfig/index.ts +1 -1
- package/src/server/routers/async/image.ts +9 -1
- package/src/services/_auth.ts +12 -12
- 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
|
}));
|
|
@@ -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
|
|
package/src/services/_auth.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
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 '
|
|
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';
|