@lobehub/chat 1.119.1 → 1.120.0
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/.vscode/settings.json +2 -3
- package/CHANGELOG.md +58 -0
- package/changelog/v1.json +17 -0
- package/package.json +5 -6
- package/packages/const/src/auth.ts +0 -36
- package/packages/const/src/index.ts +3 -1
- package/packages/database/src/models/__tests__/aiModel.test.ts +1 -2
- package/packages/database/src/models/__tests__/generationBatch.test.ts +47 -1
- package/packages/database/src/models/aiModel.ts +2 -3
- package/packages/database/src/models/generationBatch.ts +8 -1
- package/packages/database/src/repositories/aiInfra/index.test.ts +1 -1
- package/packages/database/src/repositories/aiInfra/index.ts +4 -4
- package/packages/model-bank/src/aiModels/ai21.ts +1 -1
- package/packages/model-bank/src/aiModels/ai302.ts +1 -1
- package/packages/model-bank/src/aiModels/ai360.ts +1 -1
- package/packages/model-bank/src/aiModels/aihubmix.ts +3 -3
- package/packages/model-bank/src/aiModels/akashchat.ts +1 -1
- package/packages/model-bank/src/aiModels/anthropic.ts +1 -1
- package/packages/model-bank/src/aiModels/azure.ts +1 -1
- package/packages/model-bank/src/aiModels/azureai.ts +1 -1
- package/packages/model-bank/src/aiModels/baichuan.ts +1 -1
- package/packages/model-bank/src/aiModels/bedrock.ts +1 -1
- package/packages/model-bank/src/aiModels/bfl.ts +2 -3
- package/packages/model-bank/src/aiModels/cloudflare.ts +1 -1
- package/packages/model-bank/src/aiModels/cohere.ts +1 -1
- package/packages/model-bank/src/aiModels/deepseek.ts +1 -1
- package/packages/model-bank/src/aiModels/fal.ts +1 -1
- package/packages/model-bank/src/aiModels/fireworksai.ts +1 -1
- package/packages/model-bank/src/aiModels/giteeai.ts +1 -1
- package/packages/model-bank/src/aiModels/github.ts +1 -1
- package/packages/model-bank/src/aiModels/google.ts +6 -7
- package/packages/model-bank/src/aiModels/groq.ts +1 -1
- package/packages/model-bank/src/aiModels/higress.ts +1 -1
- package/packages/model-bank/src/aiModels/huggingface.ts +1 -1
- package/packages/model-bank/src/aiModels/hunyuan.ts +1 -1
- package/packages/model-bank/src/aiModels/index.ts +1 -1
- package/packages/model-bank/src/aiModels/infiniai.ts +1 -1
- package/packages/model-bank/src/aiModels/internlm.ts +1 -1
- package/packages/model-bank/src/aiModels/jina.ts +1 -1
- package/packages/model-bank/src/aiModels/lmstudio.ts +1 -1
- package/packages/model-bank/src/aiModels/lobehub.ts +1 -1
- package/packages/model-bank/src/aiModels/minimax.ts +1 -1
- package/packages/model-bank/src/aiModels/mistral.ts +1 -1
- package/packages/model-bank/src/aiModels/modelscope.ts +1 -1
- package/packages/model-bank/src/aiModels/moonshot.ts +1 -1
- package/packages/model-bank/src/aiModels/novita.ts +1 -1
- package/packages/model-bank/src/aiModels/nvidia.ts +1 -1
- package/packages/model-bank/src/aiModels/ollama.ts +1 -1
- package/packages/model-bank/src/aiModels/openai.ts +1 -1
- package/packages/model-bank/src/aiModels/openrouter.ts +3 -3
- package/packages/model-bank/src/aiModels/perplexity.ts +1 -1
- package/packages/model-bank/src/aiModels/ppio.ts +1 -1
- package/packages/model-bank/src/aiModels/qiniu.ts +1 -1
- package/packages/model-bank/src/aiModels/qwen.ts +4 -2
- package/packages/model-bank/src/aiModels/sambanova.ts +1 -1
- package/packages/model-bank/src/aiModels/search1api.ts +1 -1
- package/packages/model-bank/src/aiModels/sensenova.ts +1 -1
- package/packages/model-bank/src/aiModels/siliconcloud.ts +7 -1
- package/packages/model-bank/src/aiModels/spark.ts +1 -1
- package/packages/model-bank/src/aiModels/stepfun.ts +1 -1
- package/packages/model-bank/src/aiModels/taichu.ts +1 -1
- package/packages/model-bank/src/aiModels/tencentcloud.ts +1 -1
- package/packages/model-bank/src/aiModels/togetherai.ts +1 -1
- package/packages/model-bank/src/aiModels/upstage.ts +1 -1
- package/packages/model-bank/src/aiModels/v0.ts +1 -1
- package/packages/model-bank/src/aiModels/vertexai.ts +3 -3
- package/packages/model-bank/src/aiModels/vllm.ts +1 -1
- package/packages/model-bank/src/aiModels/volcengine.ts +1 -1
- package/packages/model-bank/src/aiModels/wenxin.ts +1 -1
- package/packages/model-bank/src/aiModels/xai.ts +1 -1
- package/packages/model-bank/src/aiModels/xinference.ts +1 -1
- package/packages/model-bank/src/aiModels/zeroone.ts +1 -1
- package/packages/model-bank/src/aiModels/zhipu.ts +1 -1
- package/packages/model-bank/src/index.ts +1 -0
- package/packages/model-bank/src/standard-parameters/index.ts +48 -0
- package/packages/{types/src → model-bank/src/types}/aiModel.ts +12 -1
- package/packages/model-bank/src/types/index.ts +1 -0
- package/packages/model-runtime/package.json +4 -1
- package/packages/model-runtime/src/BaseAI.ts +2 -2
- package/packages/model-runtime/src/ModelRuntime.test.ts +4 -4
- package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +3 -7
- package/packages/model-runtime/src/ai302/index.ts +1 -1
- package/packages/model-runtime/src/aihubmix/index.ts +1 -2
- package/packages/model-runtime/src/anthropic/index.ts +1 -1
- package/packages/model-runtime/src/azureOpenai/index.ts +2 -3
- package/packages/model-runtime/src/azureai/index.ts +2 -3
- package/packages/model-runtime/src/bedrock/index.ts +1 -1
- package/packages/model-runtime/src/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/bfl/createImage.ts +2 -2
- package/packages/model-runtime/src/bfl/index.ts +1 -1
- package/packages/model-runtime/src/cloudflare/index.ts +1 -1
- package/packages/model-runtime/src/const/models.ts +64 -0
- package/packages/model-runtime/src/fal/index.test.ts +2 -3
- package/packages/model-runtime/src/fal/index.ts +1 -1
- package/packages/model-runtime/src/github/index.ts +1 -1
- package/packages/model-runtime/src/google/createImage.test.ts +1 -1
- package/packages/model-runtime/src/google/createImage.ts +53 -25
- package/packages/model-runtime/src/google/index.test.ts +1 -1
- package/packages/model-runtime/src/google/index.ts +4 -3
- package/packages/model-runtime/src/groq/index.ts +1 -1
- package/packages/model-runtime/src/helpers/parseToolCalls.ts +1 -2
- package/packages/model-runtime/src/huggingface/index.ts +1 -1
- package/packages/model-runtime/src/index.ts +3 -1
- package/packages/model-runtime/src/infiniai/index.ts +1 -1
- package/packages/model-runtime/src/ollama/index.test.ts +1 -1
- package/packages/model-runtime/src/ollama/index.ts +2 -3
- package/packages/model-runtime/src/openai/index.ts +16 -8
- package/packages/model-runtime/src/providerTestUtils.ts +1 -2
- package/packages/model-runtime/src/qiniu/index.test.ts +2 -3
- package/packages/model-runtime/src/qwen/index.ts +1 -1
- package/packages/model-runtime/src/siliconcloud/index.ts +2 -2
- package/packages/model-runtime/src/types/chat.ts +2 -22
- package/packages/model-runtime/src/{error.ts → types/error.ts} +29 -0
- package/packages/model-runtime/src/types/index.ts +4 -0
- package/packages/model-runtime/src/types/toolsCalling.ts +48 -0
- package/packages/model-runtime/src/types/type.ts +1 -1
- package/packages/model-runtime/src/types/usage.ts +27 -0
- package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +2 -2
- package/packages/model-runtime/src/utils/anthropicHelpers.ts +1 -1
- package/packages/model-runtime/src/utils/createError.ts +1 -1
- package/packages/model-runtime/src/utils/errorResponse.test.ts +110 -0
- package/packages/model-runtime/src/utils/errorResponse.ts +64 -0
- package/packages/{utils/src → model-runtime/src/utils}/getFallbackModelProperty.ts +1 -1
- package/packages/model-runtime/src/utils/googleErrorParser.test.ts +1 -1
- package/packages/model-runtime/src/utils/googleErrorParser.ts +1 -1
- package/packages/model-runtime/src/utils/handleOpenAIError.ts +1 -1
- package/packages/model-runtime/src/utils/imageToBase64.test.ts +91 -0
- package/packages/model-runtime/src/utils/imageToBase64.ts +62 -0
- package/packages/model-runtime/src/utils/modelParse.test.ts +2 -2
- package/packages/model-runtime/src/utils/modelParse.ts +16 -10
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/createImage.ts +1 -1
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +3 -3
- package/packages/model-runtime/src/utils/openaiHelpers.test.ts +2 -2
- package/packages/model-runtime/src/utils/openaiHelpers.ts +3 -4
- package/packages/model-runtime/src/utils/postProcessModelList.ts +2 -2
- package/packages/model-runtime/src/utils/safeParseJSON.test.ts +71 -0
- package/packages/model-runtime/src/utils/safeParseJSON.ts +12 -0
- package/packages/model-runtime/src/utils/streams/bedrock/claude.ts +1 -1
- package/packages/model-runtime/src/utils/streams/bedrock/llama.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/bedrock/llama.ts +1 -1
- package/packages/model-runtime/src/utils/streams/google-ai.test.ts +1 -1
- package/packages/model-runtime/src/utils/streams/google-ai.ts +1 -1
- package/packages/model-runtime/src/utils/streams/ollama.test.ts +1 -1
- package/packages/model-runtime/src/utils/streams/ollama.ts +2 -3
- package/packages/model-runtime/src/utils/streams/openai/openai.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/openai/openai.ts +1 -1
- package/packages/model-runtime/src/utils/streams/openai/responsesStream.ts +1 -1
- package/packages/model-runtime/src/utils/streams/protocol.ts +3 -3
- package/packages/model-runtime/src/utils/streams/vertex-ai.test.ts +1 -1
- package/packages/model-runtime/src/utils/streams/vertex-ai.ts +2 -2
- package/packages/model-runtime/src/utils/uuid.ts +7 -0
- package/packages/model-runtime/src/vertexai/index.ts +1 -1
- package/packages/types/src/agent/index.ts +2 -1
- package/packages/types/src/aiProvider.ts +10 -2
- package/packages/types/src/auth.ts +35 -0
- package/packages/types/src/discover/models.ts +1 -1
- package/packages/types/src/discover/providers.ts +1 -1
- package/packages/types/src/index.ts +4 -0
- package/packages/types/src/llm.ts +2 -47
- package/packages/types/src/session/agentSession.ts +3 -3
- package/packages/types/src/session/index.ts +2 -2
- package/packages/types/src/session/sessionGroup.ts +0 -2
- package/packages/types/src/user/settings/general.ts +1 -1
- package/packages/types/src/user/settings/modelProvider.ts +1 -1
- package/packages/utils/src/fetch/fetchSSE.ts +1 -1
- package/packages/utils/src/format.ts +2 -3
- package/packages/utils/src/index.ts +3 -1
- package/packages/utils/src/number.test.ts +1 -2
- package/packages/utils/src/number.ts +1 -2
- package/packages/utils/src/parseModels.test.ts +1 -2
- package/packages/utils/src/parseModels.ts +2 -3
- package/packages/utils/src/pricing.test.ts +1 -2
- package/packages/utils/src/pricing.ts +1 -1
- package/packages/utils/src/server/xor.ts +3 -1
- package/src/app/(backend)/middleware/auth/index.ts +1 -2
- package/src/app/(backend)/webapi/chat/vertexai/route.ts +1 -1
- package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +1 -2
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +2 -16
- package/src/app/[variants]/(main)/chat/@session/_layout/Desktop/SessionHeader.tsx +1 -3
- package/src/app/[variants]/(main)/chat/@session/_layout/Mobile/SessionHeader.tsx +1 -3
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/ModelTypeIcon.tsx +1 -2
- package/src/app/[variants]/(main)/image/@menu/components/SeedNumberInput/index.tsx +1 -1
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/hooks/useAutoDimensions.ts +4 -3
- package/src/app/[variants]/(main)/settings/hooks/useCategory.tsx +3 -21
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelItem.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/ListItem.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/index.tsx +1 -1
- package/src/components/ModelSelect/index.tsx +1 -1
- package/src/config/featureFlags/schema.test.ts +1 -2
- package/src/config/featureFlags/schema.ts +0 -6
- package/src/config/featureFlags/utils/parser.test.ts +7 -7
- package/src/database/_deprecated/core/index.ts +0 -1
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +2 -5
- package/src/database/_deprecated/core/model.ts +4 -38
- package/src/database/_deprecated/models/message.ts +1 -1
- package/src/features/Conversation/Extras/Usage/UsageDetail/ModelCard.tsx +1 -1
- package/src/features/Conversation/Extras/Usage/UsageDetail/pricing.ts +3 -4
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +1 -1
- package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +3 -2
- package/src/layout/GlobalProvider/StoreInitialization.tsx +0 -3
- package/src/libs/trpc/async/context.ts +2 -1
- package/src/libs/trpc/edge/context.ts +2 -6
- package/src/libs/trpc/lambda/context.ts +1 -1
- package/src/migrations/FromV5ToV6/types/v5.ts +2 -2
- package/src/migrations/FromV5ToV6/types/v6.ts +2 -1
- package/src/server/globalConfig/genServerAiProviderConfig.ts +3 -3
- package/src/server/modules/ModelRuntime/index.test.ts +1 -1
- package/src/server/modules/ModelRuntime/index.ts +1 -1
- package/src/server/routers/async/caller.ts +2 -1
- package/src/server/routers/async/image.ts +2 -2
- package/src/server/routers/lambda/aiModel.ts +1 -1
- package/src/server/services/chunk/index.ts +2 -1
- package/src/server/services/generation/index.ts +2 -2
- package/src/services/_auth.ts +2 -1
- package/src/services/aiModel/server.test.ts +1 -1
- package/src/services/aiModel/type.ts +1 -1
- package/src/services/chat.ts +1 -1
- package/src/services/upload.ts +3 -3
- package/src/store/agent/slices/chat/action.ts +1 -1
- package/src/store/aiInfra/slices/aiModel/action.ts +6 -6
- package/src/store/aiInfra/slices/aiModel/initialState.ts +1 -1
- package/src/store/aiInfra/slices/aiModel/selectors.test.ts +1 -1
- package/src/store/aiInfra/slices/aiModel/selectors.ts +2 -1
- package/src/store/aiInfra/slices/aiProvider/__tests__/action.test.ts +7 -7
- package/src/store/aiInfra/slices/aiProvider/action.ts +8 -8
- package/src/store/aiInfra/slices/aiProvider/initialState.ts +2 -1
- package/src/store/electron/actions/app.ts +1 -1
- package/src/store/image/slices/generationConfig/action.test.ts +1 -1
- package/src/store/image/slices/generationConfig/action.ts +1 -1
- package/src/store/image/slices/generationConfig/hooks.test.ts +1 -1
- package/src/store/image/slices/generationConfig/hooks.ts +6 -3
- package/src/store/image/slices/generationConfig/selectors.test.ts +1 -1
- package/src/store/serverConfig/selectors.test.ts +0 -1
- package/src/store/user/initialState.ts +1 -4
- package/src/store/user/selectors.ts +0 -1
- package/src/store/user/slices/auth/action.ts +1 -1
- package/src/store/user/slices/auth/selectors.ts +3 -4
- package/src/store/user/slices/modelList/action.ts +8 -7
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +8 -5
- package/src/store/user/slices/preference/selectors.ts +3 -2
- package/src/store/user/slices/settings/selectors/settings.ts +1 -2
- package/src/store/user/store.ts +1 -4
- package/docs/self-hosting/advanced/webrtc.mdx +0 -86
- package/docs/self-hosting/advanced/webrtc.zh-CN.mdx +0 -80
- package/packages/const/src/image.ts +0 -51
- package/src/app/[variants]/(main)/settings/sync/features/Alert.tsx +0 -53
- package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/Card.tsx +0 -42
- package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/DeviceName.tsx +0 -62
- package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/SystemIcon.tsx +0 -31
- package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/index.tsx +0 -103
- package/src/app/[variants]/(main)/settings/sync/features/WebRTC/ChannelNameInput.tsx +0 -45
- package/src/app/[variants]/(main)/settings/sync/features/WebRTC/SyncSwitch/index.css +0 -238
- package/src/app/[variants]/(main)/settings/sync/features/WebRTC/SyncSwitch/index.tsx +0 -79
- package/src/app/[variants]/(main)/settings/sync/features/WebRTC/generateRandomRoomName.ts +0 -4
- package/src/app/[variants]/(main)/settings/sync/features/WebRTC/index.tsx +0 -103
- package/src/app/[variants]/(main)/settings/sync/index.tsx +0 -17
- package/src/app/[variants]/(main)/settings/sync/page.tsx +0 -29
- package/src/database/_deprecated/core/sync.ts +0 -321
- package/src/features/SyncStatusInspector/DisableSync.tsx +0 -79
- package/src/features/SyncStatusInspector/EnableSync.tsx +0 -132
- package/src/features/SyncStatusInspector/EnableTag.tsx +0 -66
- package/src/features/SyncStatusInspector/index.tsx +0 -27
- package/src/hooks/useSyncData.ts +0 -50
- package/src/services/__tests__/sync.test.ts +0 -56
- package/src/services/sync.ts +0 -19
- package/src/store/user/slices/sync/action.test.ts +0 -164
- package/src/store/user/slices/sync/action.ts +0 -101
- package/src/store/user/slices/sync/initialState.ts +0 -13
- package/src/store/user/slices/sync/selectors.ts +0 -20
- /package/packages/{utils/src → model-runtime/src/utils}/getFallbackModelProperty.test.ts +0 -0
@@ -1,16 +1,16 @@
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
2
|
+
import {
|
3
|
+
AiModelSortMap,
|
4
|
+
AiProviderModelListItem,
|
5
|
+
CreateAiModelParams,
|
6
|
+
ToggleAiModelEnableParams,
|
7
|
+
} from 'model-bank';
|
2
8
|
import { SWRResponse, mutate } from 'swr';
|
3
9
|
import { StateCreator } from 'zustand/vanilla';
|
4
10
|
|
5
11
|
import { useClientDataSWR } from '@/libs/swr';
|
6
12
|
import { aiModelService } from '@/services/aiModel';
|
7
13
|
import { AiInfraStore } from '@/store/aiInfra/store';
|
8
|
-
import {
|
9
|
-
AiModelSortMap,
|
10
|
-
AiProviderModelListItem,
|
11
|
-
CreateAiModelParams,
|
12
|
-
ToggleAiModelEnableParams,
|
13
|
-
} from '@/types/aiModel';
|
14
14
|
|
15
15
|
const FETCH_AI_PROVIDER_MODEL_LIST_KEY = 'FETCH_AI_PROVIDER_MODELS';
|
16
16
|
|
@@ -1,7 +1,7 @@
|
|
1
|
+
import { AiModelSourceEnum } from 'model-bank';
|
1
2
|
import { describe, expect, it } from 'vitest';
|
2
3
|
|
3
4
|
import { AIProviderStoreState } from '@/store/aiInfra/initialState';
|
4
|
-
import { AiModelSourceEnum } from '@/types/aiModel';
|
5
5
|
|
6
6
|
import { aiModelSelectors } from './selectors';
|
7
7
|
|
@@ -1,5 +1,6 @@
|
|
1
|
+
import { AiModelSourceEnum } from 'model-bank';
|
2
|
+
|
1
3
|
import { AIProviderStoreState } from '@/store/aiInfra/initialState';
|
2
|
-
import { AiModelSourceEnum } from '@/types/aiModel';
|
3
4
|
import { ModelSearchImplement } from '@/types/search';
|
4
5
|
|
5
6
|
const aiProviderChatModelListIds = (s: AIProviderStoreState) =>
|
@@ -1,14 +1,9 @@
|
|
1
|
+
import * as runtimeModule from '@lobechat/model-runtime';
|
2
|
+
import type { EnabledAiModel, ModelAbilities } from 'model-bank';
|
1
3
|
import { describe, expect, it, vi } from 'vitest';
|
2
4
|
|
3
|
-
import type { EnabledAiModel, ModelAbilities } from '@/types/aiModel';
|
4
|
-
|
5
5
|
import { getModelListByType } from '../action';
|
6
6
|
|
7
|
-
// Mock getModelPropertyWithFallback
|
8
|
-
vi.mock('@/utils/getFallbackModelProperty', () => ({
|
9
|
-
getModelPropertyWithFallback: vi.fn().mockResolvedValue({ size: '1024x1024' }),
|
10
|
-
}));
|
11
|
-
|
12
7
|
describe('getModelListByType', () => {
|
13
8
|
const mockChatModels: EnabledAiModel[] = [
|
14
9
|
{
|
@@ -100,6 +95,11 @@ describe('getModelListByType', () => {
|
|
100
95
|
});
|
101
96
|
|
102
97
|
it('should use fallback parameters for image models without parameters', async () => {
|
98
|
+
// Mock getModelPropertyWithFallback
|
99
|
+
vi.spyOn(runtimeModule, 'getModelPropertyWithFallback').mockResolvedValueOnce({
|
100
|
+
size: '1024x1024',
|
101
|
+
});
|
102
|
+
|
103
103
|
const result = await getModelListByType(allModels, 'midjourney', 'image');
|
104
104
|
|
105
105
|
expect(result[0]).toEqual({
|
@@ -1,17 +1,18 @@
|
|
1
|
+
import { isDeprecatedEdition, isDesktop, isUsePgliteDB } from '@lobechat/const';
|
2
|
+
import { getModelPropertyWithFallback } from '@lobechat/model-runtime';
|
1
3
|
import { uniqBy } from 'lodash-es';
|
4
|
+
import {
|
5
|
+
AIImageModelCard,
|
6
|
+
EnabledAiModel,
|
7
|
+
LobeDefaultAiModelListItem,
|
8
|
+
ModelAbilities,
|
9
|
+
} from 'model-bank';
|
2
10
|
import { SWRResponse, mutate } from 'swr';
|
3
11
|
import { StateCreator } from 'zustand/vanilla';
|
4
12
|
|
5
|
-
import { isDeprecatedEdition, isDesktop, isUsePgliteDB } from '@/const/version';
|
6
13
|
import { useClientDataSWR } from '@/libs/swr';
|
7
14
|
import { aiProviderService } from '@/services/aiProvider';
|
8
15
|
import { AiInfraStore } from '@/store/aiInfra/store';
|
9
|
-
import {
|
10
|
-
AIImageModelCard,
|
11
|
-
EnabledAiModel,
|
12
|
-
LobeDefaultAiModelListItem,
|
13
|
-
ModelAbilities,
|
14
|
-
} from '@/types/aiModel';
|
15
16
|
import {
|
16
17
|
AiProviderDetailItem,
|
17
18
|
AiProviderListItem,
|
@@ -24,7 +25,6 @@ import {
|
|
24
25
|
UpdateAiProviderConfigParams,
|
25
26
|
UpdateAiProviderParams,
|
26
27
|
} from '@/types/aiProvider';
|
27
|
-
import { getModelPropertyWithFallback } from '@/utils/getFallbackModelProperty';
|
28
28
|
|
29
29
|
/**
|
30
30
|
* Get models by provider ID and type, with proper formatting and deduplication
|
@@ -8,7 +8,7 @@ import { electronSystemService } from '@/services/electron/system';
|
|
8
8
|
import { globalAgentContextManager } from '@/utils/client/GlobalAgentContextManager';
|
9
9
|
import { merge } from '@/utils/merge';
|
10
10
|
|
11
|
-
import { ElectronStore } from '../store';
|
11
|
+
import type { ElectronStore } from '../store';
|
12
12
|
|
13
13
|
// ======== Action Interface ======== //
|
14
14
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { act, renderHook } from '@testing-library/react';
|
2
2
|
import { ModelParamsSchema, RuntimeImageGenParams, extractDefaultValues } from 'model-bank';
|
3
3
|
import { fluxSchnellParamsSchema } from 'model-bank';
|
4
|
+
import { AIImageModelCard } from 'model-bank';
|
4
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
5
6
|
|
6
7
|
import { useImageStore } from '@/store/image';
|
7
|
-
import { AIImageModelCard } from '@/types/aiModel';
|
8
8
|
|
9
9
|
// Mock external dependencies
|
10
10
|
vi.mock('@/store/aiInfra', () => ({
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import {
|
2
|
+
AIImageModelCard,
|
2
3
|
ModelParamsSchema,
|
3
4
|
RuntimeImageGenParams,
|
4
5
|
RuntimeImageGenParamsKeys,
|
@@ -8,7 +9,6 @@ import {
|
|
8
9
|
import { StateCreator } from 'zustand/vanilla';
|
9
10
|
|
10
11
|
import { aiProviderSelectors, getAiInfraStoreState } from '@/store/aiInfra';
|
11
|
-
import { AIImageModelCard } from '@/types/aiModel';
|
12
12
|
|
13
13
|
import type { ImageStore } from '../../store';
|
14
14
|
import { adaptSizeToRatio, parseRatio } from '../../utils/size';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { act, renderHook } from '@testing-library/react';
|
2
2
|
import { ModelParamsSchema, RuntimeImageGenParams } from 'model-bank';
|
3
3
|
import { fluxSchnellParamsSchema } from 'model-bank';
|
4
|
+
import { AIImageModelCard } from 'model-bank';
|
4
5
|
import { describe, expect, it, vi } from 'vitest';
|
5
6
|
|
6
7
|
import { useImageStore } from '@/store/image';
|
7
|
-
import { AIImageModelCard } from '@/types/aiModel';
|
8
8
|
|
9
9
|
import { useGenerationConfigParam } from './hooks';
|
10
10
|
|
@@ -1,8 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
DEFAULT_ASPECT_RATIO,
|
3
|
+
PRESET_ASPECT_RATIOS,
|
4
|
+
RuntimeImageGenParams,
|
5
|
+
RuntimeImageGenParamsKeys,
|
6
|
+
} from 'model-bank';
|
2
7
|
import { useCallback, useMemo } from 'react';
|
3
8
|
|
4
|
-
import { DEFAULT_ASPECT_RATIO, PRESET_ASPECT_RATIOS } from '@/const/image';
|
5
|
-
|
6
9
|
import { useImageStore } from '../../store';
|
7
10
|
import { imageGenerationConfigSelectors } from './selectors';
|
8
11
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { ModelParamsSchema, RuntimeImageGenParams, gptImage1ParamsSchema } from 'model-bank';
|
2
|
+
import { AIImageModelCard } from 'model-bank';
|
2
3
|
import { describe, expect, it, vi } from 'vitest';
|
3
4
|
|
4
5
|
import { ImageStore } from '@/store/image';
|
5
6
|
import { initialState } from '@/store/image/initialState';
|
6
|
-
import { AIImageModelCard } from '@/types/aiModel';
|
7
7
|
import { merge } from '@/utils/merge';
|
8
8
|
|
9
9
|
import { imageGenerationConfigSelectors } from './selectors';
|
@@ -3,17 +3,14 @@ import { CommonState, initialCommonState } from './slices/common/initialState';
|
|
3
3
|
import { ModelListState, initialModelListState } from './slices/modelList/initialState';
|
4
4
|
import { UserPreferenceState, initialPreferenceState } from './slices/preference/initialState';
|
5
5
|
import { UserSettingsState, initialSettingsState } from './slices/settings/initialState';
|
6
|
-
import { UserSyncState, initialSyncState } from './slices/sync/initialState';
|
7
6
|
|
8
|
-
export type UserState =
|
9
|
-
UserSettingsState &
|
7
|
+
export type UserState = UserSettingsState &
|
10
8
|
UserPreferenceState &
|
11
9
|
UserAuthState &
|
12
10
|
ModelListState &
|
13
11
|
CommonState;
|
14
12
|
|
15
13
|
export const initialState: UserState = {
|
16
|
-
...initialSyncState,
|
17
14
|
...initialSettingsState,
|
18
15
|
...initialPreferenceState,
|
19
16
|
...initialAuthState,
|
@@ -2,7 +2,7 @@ import { StateCreator } from 'zustand/vanilla';
|
|
2
2
|
|
3
3
|
import { enableAuth, enableClerk, enableNextAuth } from '@/const/auth';
|
4
4
|
|
5
|
-
import { UserStore } from '../../store';
|
5
|
+
import type { UserStore } from '../../store';
|
6
6
|
|
7
7
|
export interface UserAuthAction {
|
8
8
|
enableAuth: () => boolean;
|
@@ -1,10 +1,9 @@
|
|
1
|
+
import { BRANDING_NAME, isDesktop } from '@lobechat/const';
|
2
|
+
import { LobeUser } from '@lobechat/types';
|
1
3
|
import { t } from 'i18next';
|
2
4
|
|
3
5
|
import { enableAuth, enableClerk, enableNextAuth } from '@/const/auth';
|
4
|
-
import {
|
5
|
-
import { isDesktop } from '@/const/version';
|
6
|
-
import { UserStore } from '@/store/user';
|
7
|
-
import { LobeUser } from '@/types/user';
|
6
|
+
import type { UserStore } from '@/store/user';
|
8
7
|
|
9
8
|
const DEFAULT_USERNAME = BRANDING_NAME;
|
10
9
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import { ModelProvider } from '@lobechat/model-runtime';
|
2
|
-
import { produce } from 'immer';
|
3
|
-
import useSWR, { SWRResponse } from 'swr';
|
4
|
-
import type { StateCreator } from 'zustand/vanilla';
|
5
|
-
|
6
|
-
import { UserStore } from '@/store/user';
|
7
|
-
import type { ChatModelCard, ModelProviderCard } from '@/types/llm';
|
8
2
|
import type {
|
3
|
+
ChatModelCard,
|
9
4
|
GlobalLLMProviderKey,
|
5
|
+
ModelProviderCard,
|
10
6
|
UserKeyVaults,
|
11
7
|
UserModelProviderConfig,
|
12
|
-
} from '
|
8
|
+
} from '@lobechat/types';
|
9
|
+
import { produce } from 'immer';
|
10
|
+
import useSWR, { SWRResponse } from 'swr';
|
11
|
+
import type { StateCreator } from 'zustand/vanilla';
|
12
|
+
|
13
|
+
import type { UserStore } from '@/store/user';
|
13
14
|
|
14
15
|
import { settingsSelectors } from '../settings/selectors';
|
15
16
|
import { CustomModelCardDispatch, customModelCardsReducer } from './reducers/customModelCard';
|
@@ -1,12 +1,15 @@
|
|
1
|
+
import type {
|
2
|
+
ChatModelCard,
|
3
|
+
EnabledProviderWithModels,
|
4
|
+
GlobalLLMProviderKey,
|
5
|
+
ModelProviderCard,
|
6
|
+
} from '@lobechat/types';
|
7
|
+
import { ServerModelProviderConfig } from '@lobechat/types';
|
1
8
|
import { uniqBy } from 'lodash-es';
|
2
9
|
|
3
10
|
import { filterEnabledModels } from '@/config/modelProviders';
|
4
|
-
import {
|
5
|
-
import { ChatModelCard, ModelProviderCard } from '@/types/llm';
|
6
|
-
import { ServerModelProviderConfig } from '@/types/serverConfig';
|
7
|
-
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
11
|
+
import type { UserStore } from '@/store/user';
|
8
12
|
|
9
|
-
import { UserStore } from '../../../store';
|
10
13
|
import { currentSettings, getProviderConfigById } from '../../settings/selectors/settings';
|
11
14
|
|
12
15
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { DEFAULT_PREFERENCE } from '
|
2
|
-
|
1
|
+
import { DEFAULT_PREFERENCE } from '@lobechat/const';
|
2
|
+
|
3
|
+
import type { UserStore } from '@/store/user';
|
3
4
|
|
4
5
|
const useCmdEnterToSend = (s: UserStore): boolean => s.preference.useCmdEnterToSend || false;
|
5
6
|
const topicDisplayMode = (s: UserStore) =>
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
DEFAULT_SYSTEM_AGENT_CONFIG,
|
7
7
|
DEFAULT_TTS_CONFIG,
|
8
8
|
} from '@/const/settings';
|
9
|
+
import type { UserStore } from '@/store/user';
|
9
10
|
import { HotkeyId } from '@/types/hotkey';
|
10
11
|
import {
|
11
12
|
GlobalLLMProviderKey,
|
@@ -15,8 +16,6 @@ import {
|
|
15
16
|
} from '@/types/user/settings';
|
16
17
|
import { merge } from '@/utils/merge';
|
17
18
|
|
18
|
-
import { UserStore } from '../../../store';
|
19
|
-
|
20
19
|
export const currentSettings = (s: UserStore): UserSettings => merge(s.defaultSettings, s.settings);
|
21
20
|
|
22
21
|
export const currentLLMSettings = (s: UserStore): UserModelProviderConfig =>
|
package/src/store/user/store.ts
CHANGED
@@ -10,12 +10,10 @@ import { type CommonAction, createCommonSlice } from './slices/common/action';
|
|
10
10
|
import { type ModelListAction, createModelListSlice } from './slices/modelList/action';
|
11
11
|
import { type PreferenceAction, createPreferenceSlice } from './slices/preference/action';
|
12
12
|
import { type UserSettingsAction, createSettingsSlice } from './slices/settings/action';
|
13
|
-
import { type SyncAction, createSyncSlice } from './slices/sync/action';
|
14
13
|
|
15
14
|
// =============== 聚合 createStoreFn ============ //
|
16
15
|
|
17
|
-
export type UserStore =
|
18
|
-
UserState &
|
16
|
+
export type UserStore = UserState &
|
19
17
|
UserSettingsAction &
|
20
18
|
PreferenceAction &
|
21
19
|
ModelListAction &
|
@@ -24,7 +22,6 @@ export type UserStore = SyncAction &
|
|
24
22
|
|
25
23
|
const createStore: StateCreator<UserStore, [['zustand/devtools', never]]> = (...parameters) => ({
|
26
24
|
...initialState,
|
27
|
-
...createSyncSlice(...parameters),
|
28
25
|
...createSettingsSlice(...parameters),
|
29
26
|
...createPreferenceSlice(...parameters),
|
30
27
|
...createAuthSlice(...parameters),
|
@@ -1,86 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: LobeChat WebRTC Sync - Real-Time Data Sharing
|
3
|
-
description: >-
|
4
|
-
Explore LobeChat's WebRTC sync for real-time data sharing and privacy without servers.
|
5
|
-
|
6
|
-
tags:
|
7
|
-
- WebRTC
|
8
|
-
- LobeChat
|
9
|
-
- Data Synchronization
|
10
|
-
- Real-Time Communication
|
11
|
-
- Peer-to-Peer
|
12
|
-
---
|
13
|
-
|
14
|
-
# LobeChat WebRTC Sync
|
15
|
-
|
16
|
-
## Introduction to WebRTC
|
17
|
-
|
18
|
-
WebRTC (Web Real-Time Communication) is a technology that enables peer-to-peer communication between browsers. In LobeChat, we experimentally implemented real-time data synchronization between devices based on WebRTC and YJS, without relying on traditional server databases. This solution offers high privacy, zero conflicts, and provides a real-time session synchronization experience.
|
19
|
-
|
20
|
-
## Configuring WebRTC for Synchronization
|
21
|
-
|
22
|
-
To use the WebRTC synchronization feature in LobeChat, you need to complete the following steps:
|
23
|
-
|
24
|
-
<Steps>
|
25
|
-
### Deploy Signaling Server
|
26
|
-
|
27
|
-
Deploy a WebRTC signaling server with one click using the Zeabur platform:
|
28
|
-
|
29
|
-
[](https://zeabur.com/templates/MY0JZG?referralCode=arvinxx)
|
30
|
-
|
31
|
-
Alternatively, you can view the [source code](https://github.com/lobehub/y-webrtc-signaling) and deploy it on your own.
|
32
|
-
|
33
|
-
After deployment, you will receive a URL, for example: `https://my-signaling-server.zeabur.app`.
|
34
|
-
|
35
|
-
### Enable WebRTC Sync in the Deployment Instance
|
36
|
-
|
37
|
-
The WebRTC sync feature in LobeChat is hidden by default and needs to be enabled by adding the environment variable `FEATURE_FLAGS=+webrtc_sync`.
|
38
|
-
|
39
|
-
### Configure WebRTC Sync Settings in LobeChat
|
40
|
-
|
41
|
-
1. Open LobeChat settings -> Data Sync
|
42
|
-
2. Enter the signaling server address in the WebRTC sync section;
|
43
|
-
3. Set the sync channel name and password
|
44
|
-
|
45
|
-
<Image alt={'LobeChat Data Sync Settings Page'} height={356} inStep src={'https://github.com/lobehub/lobe-chat/assets/28616219/bf86bf1e-87fb-4015-8587-15ff28bb9c24'} />
|
46
|
-
|
47
|
-
### Repeat the Above Configuration on Devices that Need to Sync
|
48
|
-
|
49
|
-
Ensure all devices use the same signaling server, channel name, and password. Once configured, the devices should automatically start syncing data.
|
50
|
-
</Steps>
|
51
|
-
|
52
|
-
## Limitations and Known Issues
|
53
|
-
|
54
|
-
Although WebRTC has the advantages of no database and flexibility, after extensive community testing, the following limitations and known issues have been identified:
|
55
|
-
|
56
|
-
### Requirement for Devices to be Online Simultaneously
|
57
|
-
|
58
|
-
WebRTC requires devices to be online simultaneously to synchronize, meaning changes cannot be made on one device while offline and then synced later on another device.
|
59
|
-
|
60
|
-
This limitation is due to the communication nature of WebRTC. In a pure frontend, serverless scenario, data synchronization between two devices can only be achieved through peer-to-peer communication. When one device is online and the other is offline, it is impossible to determine where the data should come from. Only when both devices are online can data communication occur. This mode is more like an online chat room where everyone needs to be online to see each other's data and achieve synchronization.
|
61
|
-
|
62
|
-
Therefore, in certain situations, WebRTC's pure peer-to-peer approach may not fully meet users' needs (e.g., one device is a work computer, and the other is a home computer), and there are also some issues with data synchronization.
|
63
|
-
|
64
|
-
### Network Issues Leading to Sync Failures
|
65
|
-
|
66
|
-
Due to the implementation mechanism of WebRTC, its peer-to-peer communication has strict network requirements. Many of our users have reported:
|
67
|
-
|
68
|
-
- Syncing between PCs is possible, but syncing between a mobile device with a SIM card and a PC is not, although syncing is possible when using the same WIFI as the PC;
|
69
|
-
- Syncing fails when switching networks.
|
70
|
-
|
71
|
-
### Stability and Performance Issues
|
72
|
-
|
73
|
-
- Some users have reported ICE connection failures on the Firefox browser: [WebRTC Data Sync Feedback](https://github.com/lobehub/lobe-chat/issues/1683#issuecomment-2094745907)
|
74
|
-
- For extremely long text or large amounts of conversation records, the synchronization process may slow down or become unstable: [When the model outputs a very long conversation, the end of the conversation will contain synchronization-related content tags, leading to sync failures](https://github.com/lobehub/lobe-chat/issues/1962)
|
75
|
-
|
76
|
-
## Our Recommendations
|
77
|
-
|
78
|
-
Considering the above reasons, we recommend users treat the WebRTC sync feature as experimental and regularly back up important data.
|
79
|
-
|
80
|
-
We have already released a more stable and user-friendly server database synchronization solution ([deployment guide](/docs/self-hosting/advanced/server-database)). We recommend users prioritize using the server database synchronization solution.
|
81
|
-
|
82
|
-
<Callout type={'warning'}>
|
83
|
-
Please note that we have officially announced the archiving of this sync feature in [PR
|
84
|
-
3182](https://github.com/lobehub/lobe-chat/pull/3182), and the above issues will no longer be
|
85
|
-
considered for fixes.
|
86
|
-
</Callout>
|
@@ -1,80 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: LobeChat WebRTC 同步配置指南
|
3
|
-
description: 在 LobeChat 中实现基于 WebRTC 和 YJS 的设备间实时数据同步。了解如何配置 WebRTC 并开启同步功能,以及使用局限性和已知问题。
|
4
|
-
tags:
|
5
|
-
- YJS
|
6
|
-
- 信令服务器
|
7
|
-
---
|
8
|
-
|
9
|
-
# LobeChat WebRTC 同步
|
10
|
-
|
11
|
-
## WebRTC 简介
|
12
|
-
|
13
|
-
WebRTC (Web Real-Time Communication) 是一项实现浏览器之间点对点通信的技术。在 LobeChat 中,我们实验性地基于 WebRTC 和 YJS 实现了设备间的实时数据同步,无需依赖传统的服务器数据库。这种方案具有高度隐私性、零冲突性,并能提供实时会话同步体验。
|
14
|
-
|
15
|
-
## 配置 WebRTC 并实现同步
|
16
|
-
|
17
|
-
要使用 LobeChat 的 WebRTC 同步功能,需要完成以下步骤:
|
18
|
-
|
19
|
-
<Steps>
|
20
|
-
### 部署信令服务器
|
21
|
-
|
22
|
-
使用 Zeabur 平台一键部署 WebRTC 信令服务器:
|
23
|
-
|
24
|
-
[](https://zeabur.com/templates/MY0JZG?referralCode=arvinxx)
|
25
|
-
|
26
|
-
或者查看 [源码](https://github.com/lobehub/y-webrtc-signaling) 自行部署。
|
27
|
-
|
28
|
-
部署完成后,可以得到一个 URL,例如:`https://my-signaling-server.zeabur.app`。
|
29
|
-
|
30
|
-
### 在部署实例中开启 WebRTC 同步
|
31
|
-
|
32
|
-
LobeChat 默认隐藏了 WebRTC 同步功能,需要通过添加环境变量 `FEATURE_FLAGS=+webrtc_sync` 来开启 WebRTC 同步特性。
|
33
|
-
|
34
|
-
### 配置 LobeChat 的 WebRTC 同步设置
|
35
|
-
|
36
|
-
1. 打开 LobeChat 设置 -> 数据同步
|
37
|
-
2. 在 WebRTC 同步中填写信令服务器地址;
|
38
|
-
3. 设置同步频道名称和密码
|
39
|
-
|
40
|
-
<Image alt={'LobeChat 数据同步设置页'} height={356} inStep src={'https://github.com/lobehub/lobe-chat/assets/28616219/bf86bf1e-87fb-4015-8587-15ff28bb9c24'} />
|
41
|
-
|
42
|
-
### 在需要同步的设备上重复以上配置
|
43
|
-
|
44
|
-
确保所有设备使用相同的信令服务器、频道名称和密码,完成配置后,设备间应该可以开始自动同步数据。
|
45
|
-
</Steps>
|
46
|
-
|
47
|
-
## 使用局限性和已知问题
|
48
|
-
|
49
|
-
虽然 WebRTC 具有无数据库、比较灵活的特性,但目前该功能经过大范围社区测试,存在以下局限性和已知问题:
|
50
|
-
|
51
|
-
### 设备同时在线要求
|
52
|
-
|
53
|
-
WebRTC 要求设备同时在线才能进行同步,这意味着无法在一台设备离线时在另一台设备上进行更改并稍后同步。
|
54
|
-
|
55
|
-
这是 WebRTC 本身的通信特性有关系,由于在纯前端、无服务端的情况下,两个设备的数据同步只能通过点对点通信的形式达成。当一个设备在线,一个设备离线的情况下,我们无从感知数据到底应该从哪来,只有当两台设备都在线的时候,双发数据才能通信。其实这种模式更像是一个在线聊天室,大家都在线时才能看到对方的数据,然后达成同步。
|
56
|
-
|
57
|
-
因此 WebRTC 这种纯点对点的方式在某些情况下并无法完全满足用户的诉求(例如一个是公司电脑,一个是家里电脑),同时也存在一些数据同步层面的问题。
|
58
|
-
|
59
|
-
### 网络问题可能导致同步失败
|
60
|
-
|
61
|
-
由于 WebRTC 的实现机制,其点对点通信对于网络要求非常苛刻,我们的很多用户反馈:
|
62
|
-
|
63
|
-
- 在 PC 上可以互相同步、 手机 sim 卡无法和 PC 同步、但是换成和 PC 一样的 WIFI 可以和 PC 同步;
|
64
|
-
- 任何切换网络都无法同步;
|
65
|
-
|
66
|
-
### 稳定性与性能问题
|
67
|
-
|
68
|
-
- 部分用户报告在 Firefox 浏览器上遇到 ICE 连接失败的问题:[WebRTC Data Sync Feedback](https://github.com/lobehub/lobe-chat/issues/1683#issuecomment-2094745907)
|
69
|
-
- 对于超长文本或大量对话记录,同步过程可能变慢或不稳定:[当模型输出超长对话时,对话末尾会出现同步相关的内容标签,导致同步失败](https://github.com/lobehub/lobe-chat/issues/1962)
|
70
|
-
|
71
|
-
## 我们的建议
|
72
|
-
|
73
|
-
鉴于以上原因,我们建议用户将 WebRTC 同步功能视为实验性功能,并定期备份重要数据。
|
74
|
-
|
75
|
-
目前我们已经发布了更稳定、更用户友好的服务端数据库同步方案([部署指南](/zh/docs/self-hosting/advanced/server-database)),我们建议用户优先考虑使用服务端数据库同步方案。
|
76
|
-
|
77
|
-
<Callout type={'warning'}>
|
78
|
-
请注意,我们已经在 [PR 3182](https://github.com/lobehub/lobe-chat/pull/3182)
|
79
|
-
中正式宣布归档该同步特性,上述问题将不再考虑进行修复。
|
80
|
-
</Callout>
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { ModelParamsSchema } from 'model-bank';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* 默认宽高比,当模型不支持原生宽高比时使用
|
5
|
-
*/
|
6
|
-
export const DEFAULT_ASPECT_RATIO = '1:1';
|
7
|
-
|
8
|
-
export const PRESET_ASPECT_RATIOS = [
|
9
|
-
DEFAULT_ASPECT_RATIO, // '1:1' - 正方形,最常用
|
10
|
-
'16:9', // 现代显示器/电视/视频标准
|
11
|
-
'9:16', // 手机竖屏/短视频
|
12
|
-
'4:3', // 传统显示器/照片
|
13
|
-
'3:4', // 传统竖屏照片
|
14
|
-
'3:2', // 经典照片比例横屏
|
15
|
-
'2:3', // 经典照片比例竖屏
|
16
|
-
];
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Image generation and processing configuration constants
|
20
|
-
*/
|
21
|
-
export const IMAGE_GENERATION_CONFIG = {
|
22
|
-
/**
|
23
|
-
* Maximum cover image size in pixels (longest edge)
|
24
|
-
* Used for generating cover images from source images
|
25
|
-
*/
|
26
|
-
COVER_MAX_SIZE: 256,
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Maximum thumbnail size in pixels (longest edge)
|
30
|
-
* Used for generating thumbnail images from original images
|
31
|
-
*/
|
32
|
-
THUMBNAIL_MAX_SIZE: 512,
|
33
|
-
} as const;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Default dimension constraints for image upload auto-setting
|
37
|
-
* Used when model schema doesn't provide min/max values
|
38
|
-
*/
|
39
|
-
export const DEFAULT_DIMENSION_CONSTRAINTS = {
|
40
|
-
MAX_SIZE: 1024,
|
41
|
-
MIN_SIZE: 512,
|
42
|
-
} as const;
|
43
|
-
|
44
|
-
export const MAX_SEED = 2 ** 31 - 1;
|
45
|
-
|
46
|
-
export const CHAT_MODEL_IMAGE_GENERATION_PARAMS: ModelParamsSchema = {
|
47
|
-
imageUrl: {
|
48
|
-
default: null,
|
49
|
-
},
|
50
|
-
prompt: { default: '' },
|
51
|
-
};
|
@@ -1,53 +0,0 @@
|
|
1
|
-
'use client';
|
2
|
-
|
3
|
-
import { Alert } from '@lobehub/ui';
|
4
|
-
import Link from 'next/link';
|
5
|
-
import { memo } from 'react';
|
6
|
-
import { Trans } from 'react-i18next';
|
7
|
-
import { Flexbox } from 'react-layout-kit';
|
8
|
-
|
9
|
-
import { MAX_WIDTH } from '@/const/layoutTokens';
|
10
|
-
import { WEBRTC_SYNC_DOCUMENTS } from '@/const/url';
|
11
|
-
import { useUserStore } from '@/store/user';
|
12
|
-
import { preferenceSelectors } from '@/store/user/selectors';
|
13
|
-
|
14
|
-
interface ExperimentAlertProps {
|
15
|
-
mobile?: boolean;
|
16
|
-
}
|
17
|
-
const ExperimentAlert = memo<ExperimentAlertProps>(({ mobile }) => {
|
18
|
-
const [hideSyncAlert, updatePreference] = useUserStore((s) => [
|
19
|
-
preferenceSelectors.hideSyncAlert(s),
|
20
|
-
s.updatePreference,
|
21
|
-
]);
|
22
|
-
|
23
|
-
return (
|
24
|
-
!hideSyncAlert && (
|
25
|
-
<Flexbox style={{ maxWidth: MAX_WIDTH }} width={'100%'}>
|
26
|
-
<Alert
|
27
|
-
banner={mobile}
|
28
|
-
closable
|
29
|
-
message={
|
30
|
-
<Trans i18nKey="sync.warning.tip" ns={'setting'}>
|
31
|
-
经过较长一段时间测试,WebRTC 同步可能无法稳定满足通用的数据同步诉求。请自行
|
32
|
-
<Link
|
33
|
-
aria-label={'Webrtc Sync deployment'}
|
34
|
-
href={WEBRTC_SYNC_DOCUMENTS}
|
35
|
-
style={{ color: 'inherit', textDecoration: 'underline' }}
|
36
|
-
target="_blank"
|
37
|
-
>
|
38
|
-
部署信令服务器
|
39
|
-
</Link>
|
40
|
-
后使用。
|
41
|
-
</Trans>
|
42
|
-
}
|
43
|
-
onClose={() => {
|
44
|
-
updatePreference({ hideSyncAlert: true });
|
45
|
-
}}
|
46
|
-
type={'warning'}
|
47
|
-
/>
|
48
|
-
</Flexbox>
|
49
|
-
)
|
50
|
-
);
|
51
|
-
});
|
52
|
-
|
53
|
-
export default ExperimentAlert;
|