@lobehub/chat 1.119.1 → 1.119.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +5 -0
- package/package.json +5 -3
- 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/aiModel.ts +2 -3
- 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 +2 -2
- 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 +2 -3
- 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 +1 -1
- 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 +1 -1
- 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 +1 -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 +1 -1
- 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 +1 -1
- 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/siliconcloud/index.ts +1 -1
- 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)/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/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/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +2 -5
- 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/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/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/slices/sync/selectors.ts +1 -1
- package/packages/const/src/image.ts +0 -51
- /package/packages/{utils/src → model-runtime/src/utils}/getFallbackModelProperty.test.ts +0 -0
@@ -1,7 +1,6 @@
|
|
1
|
+
import { IMAGE_GENERATION_CONFIG, MAX_SEED } from 'model-bank';
|
1
2
|
import prand from 'pure-rand';
|
2
3
|
|
3
|
-
import { IMAGE_GENERATION_CONFIG, MAX_SEED } from '@/const/image';
|
4
|
-
|
5
4
|
export function generateUniqueSeeds(seedCount: number): number[] {
|
6
5
|
// Use current timestamp as the initial seed
|
7
6
|
const initialSeed = Date.now();
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { LOBE_DEFAULT_MODEL_LIST, openaiChatModels } from 'model-bank';
|
2
|
+
import { AiFullModelCard } from 'model-bank';
|
2
3
|
import { describe, expect, it } from 'vitest';
|
3
4
|
|
4
|
-
import { AiFullModelCard } from '@/types/aiModel';
|
5
|
-
|
6
5
|
import { extractEnabledModels, parseModelString, transformToAiModelList } from './parseModels';
|
7
6
|
|
8
7
|
describe('parseModelString', () => {
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import { getModelPropertyWithFallback } from '@lobechat/model-runtime';
|
1
2
|
import { produce } from 'immer';
|
3
|
+
import { AiFullModelCard, AiModelType } from 'model-bank';
|
2
4
|
|
3
|
-
import { AiFullModelCard, AiModelType } from '@/types/aiModel';
|
4
|
-
|
5
|
-
import { getModelPropertyWithFallback } from './getFallbackModelProperty';
|
6
5
|
import { merge } from './merge';
|
7
6
|
|
8
7
|
/**
|
@@ -4,12 +4,11 @@ import {
|
|
4
4
|
ChatCompletionErrorPayload,
|
5
5
|
ModelRuntime,
|
6
6
|
} from '@lobechat/model-runtime';
|
7
|
-
import { ChatErrorType } from '@lobechat/types';
|
7
|
+
import { ChatErrorType, ClientSecretPayload } from '@lobechat/types';
|
8
8
|
import { getXorPayload } from '@lobechat/utils/server';
|
9
9
|
import { NextRequest } from 'next/server';
|
10
10
|
|
11
11
|
import {
|
12
|
-
ClientSecretPayload,
|
13
12
|
LOBE_CHAT_AUTH_HEADER,
|
14
13
|
LOBE_CHAT_OIDC_AUTH_HEADER,
|
15
14
|
OAUTH_AUTHORIZED,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ModelProvider, ModelRuntime } from '@lobechat/model-runtime';
|
2
|
+
import { LobeVertexAI } from '@lobechat/model-runtime/vertexai';
|
2
3
|
|
3
4
|
import { checkAuth } from '@/app/(backend)/middleware/auth';
|
4
|
-
import { LobeVertexAI } from '@/libs/model-runtime/vertexai';
|
5
5
|
import { safeParseJSON } from '@/utils/safeParseJSON';
|
6
6
|
|
7
7
|
import { POST as UniverseRoute } from '../[provider]/route';
|
@@ -1,9 +1,8 @@
|
|
1
|
-
import { ChatCompletionErrorPayload } from '@lobechat/model-runtime';
|
1
|
+
import { ChatCompletionErrorPayload, TextToImagePayload } from '@lobechat/model-runtime';
|
2
2
|
import { ChatErrorType } from '@lobechat/types';
|
3
3
|
import { NextResponse } from 'next/server';
|
4
4
|
|
5
5
|
import { checkAuth } from '@/app/(backend)/middleware/auth';
|
6
|
-
import { TextToImagePayload } from '@/libs/model-runtime/types';
|
7
6
|
import { initModelRuntimeWithUserPayload } from '@/server/modules/ModelRuntime';
|
8
7
|
import { createErrorResponse } from '@/utils/errorResponse';
|
9
8
|
|
@@ -12,10 +12,9 @@ import {
|
|
12
12
|
PhoneIcon,
|
13
13
|
VideoIcon,
|
14
14
|
} from 'lucide-react';
|
15
|
+
import { AiModelType } from 'model-bank';
|
15
16
|
import { memo } from 'react';
|
16
17
|
|
17
|
-
import { AiModelType } from '@/types/aiModel';
|
18
|
-
|
19
18
|
const icons: Record<AiModelType, LucideIcon> = {
|
20
19
|
chat: MessageSquareTextIcon,
|
21
20
|
embedding: BoltIcon,
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
import { Button, InputNumber, Tooltip } from '@lobehub/ui';
|
4
4
|
import { Dices } from 'lucide-react';
|
5
|
+
import { MAX_SEED } from 'model-bank';
|
5
6
|
import { CSSProperties, memo, useCallback } from 'react';
|
6
7
|
import { useTranslation } from 'react-i18next';
|
7
8
|
import { Flexbox } from 'react-layout-kit';
|
8
9
|
|
9
|
-
import { MAX_SEED } from '@/const/image';
|
10
10
|
import { generateUniqueSeeds } from '@/utils/number';
|
11
11
|
|
12
12
|
export interface SeedNumberInputProps {
|
package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/hooks/useAutoDimensions.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { DEFAULT_DIMENSION_CONSTRAINTS } from '
|
1
|
+
import { DEFAULT_DIMENSION_CONSTRAINTS } from 'model-bank';
|
2
2
|
|
3
|
-
import { constrainDimensions } from '@/app/[variants]/(main)/image/@menu/features/ConfigPanel/utils/dimensionConstraints';
|
4
3
|
import { useImageStore } from '@/store/image';
|
5
|
-
import { imageGenerationConfigSelectors } from '@/store/image/
|
4
|
+
import { imageGenerationConfigSelectors } from '@/store/image/selectors';
|
5
|
+
|
6
|
+
import { constrainDimensions } from '../utils/dimensionConstraints';
|
6
7
|
|
7
8
|
/**
|
8
9
|
* Extract URL and dimensions from callback data (supports both old and new API)
|
package/src/app/[variants]/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx
CHANGED
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|
5
5
|
|
6
6
|
import MaxTokenSlider from '@/components/MaxTokenSlider';
|
7
7
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
8
|
-
import { AiModelType } from '
|
8
|
+
import { AiModelType } from '../../../../../../../../../packages/model-bank/src/types/aiModel';
|
9
9
|
import { ChatModelCard } from '@/types/llm';
|
10
10
|
|
11
11
|
interface ModelConfigFormProps {
|
@@ -10,7 +10,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
10
10
|
import { ModelInfoTags } from '@/components/ModelSelect';
|
11
11
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
12
12
|
import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
|
13
|
-
import { AiModelSourceEnum, AiProviderModelListItem } from '
|
13
|
+
import { AiModelSourceEnum, AiProviderModelListItem } from '../../../../../../../../packages/model-bank/src/types/aiModel';
|
14
14
|
import { formatPriceByCurrency } from '@/utils/format';
|
15
15
|
import {
|
16
16
|
getAudioInputUnitRate,
|
package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/ListItem.tsx
CHANGED
@@ -3,7 +3,7 @@ import { SortableList } from '@lobehub/ui';
|
|
3
3
|
import { memo } from 'react';
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
5
5
|
|
6
|
-
import { AiProviderModelListItem } from '
|
6
|
+
import { AiProviderModelListItem } from '../../../../../../../../../packages/model-bank/src/types/aiModel';
|
7
7
|
|
8
8
|
const ListItem = memo<AiProviderModelListItem>(({ id, displayName }) => {
|
9
9
|
return (
|
package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/index.tsx
CHANGED
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { Flexbox } from 'react-layout-kit';
|
7
7
|
|
8
8
|
import { useAiInfraStore } from '@/store/aiInfra';
|
9
|
-
import { AiProviderModelListItem } from '
|
9
|
+
import { AiProviderModelListItem } from '../../../../../../../../../packages/model-bank/src/types/aiModel';
|
10
10
|
|
11
11
|
import ListItem from './ListItem';
|
12
12
|
|
@@ -15,7 +15,7 @@ import { FC, memo } from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
16
16
|
import { Flexbox } from 'react-layout-kit';
|
17
17
|
|
18
|
-
import { ModelAbilities } from '
|
18
|
+
import { ModelAbilities } from '../../../packages/model-bank/src/types/aiModel';
|
19
19
|
import { AiProviderSourceType } from '@/types/aiProvider';
|
20
20
|
import { ChatModelCard } from '@/types/llm';
|
21
21
|
import { formatTokenNumber } from '@/utils/format';
|
@@ -1,9 +1,6 @@
|
|
1
|
+
import { FewShots, LobeAgentTTSConfig, MetaData, STTServer } from '@lobechat/types';
|
1
2
|
import type { ThemeMode } from 'antd-style';
|
2
|
-
|
3
|
-
import { LobeAgentTTSConfig } from '@/types/agent';
|
4
|
-
import { FewShots, LLMParams } from '@/types/llm';
|
5
|
-
import { MetaData } from '@/types/meta';
|
6
|
-
import { STTServer } from '@/types/user/settings';
|
3
|
+
import { LLMParams } from 'model-bank';
|
7
4
|
|
8
5
|
interface V4LobeAgentConfig {
|
9
6
|
autoCreateTopicThreshold: number;
|
@@ -9,7 +9,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
import { getPrice } from '@/features/Conversation/Extras/Usage/UsageDetail/pricing';
|
10
10
|
import { useGlobalStore } from '@/store/global';
|
11
11
|
import { systemStatusSelectors } from '@/store/global/selectors';
|
12
|
-
import { LobeDefaultAiModelListItem } from '
|
12
|
+
import { LobeDefaultAiModelListItem } from '../../../../../../packages/model-bank/src/types/aiModel';
|
13
13
|
import { getCachedTextInputUnitRate, getWriteCacheInputUnitRate } from '@/utils/pricing';
|
14
14
|
|
15
15
|
export const useStyles = createStyles(({ css, token }) => {
|
@@ -1,12 +1,11 @@
|
|
1
|
-
import { Pricing } from '@/types/aiModel';
|
2
|
-
import { ModelPriceCurrency } from '@/types/llm';
|
3
|
-
import { formatPriceByCurrency } from '@/utils/format';
|
4
1
|
import {
|
2
|
+
formatPriceByCurrency,
|
5
3
|
getCachedTextInputUnitRate,
|
6
4
|
getTextInputUnitRate,
|
7
5
|
getTextOutputUnitRate,
|
8
6
|
getWriteCacheInputUnitRate,
|
9
|
-
} from '
|
7
|
+
} from '@lobechat/utils';
|
8
|
+
import { ModelPriceCurrency, Pricing } from 'model-bank';
|
10
9
|
|
11
10
|
export const getPrice = (pricing: Pricing) => {
|
12
11
|
const inputRate = getTextInputUnitRate(pricing);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
2
2
|
|
3
|
-
import { LobeDefaultAiModelListItem } from '
|
3
|
+
import { LobeDefaultAiModelListItem } from '../../../../../../packages/model-bank/src/types/aiModel';
|
4
4
|
import { ModelTokensUsage } from '@/types/message';
|
5
5
|
|
6
6
|
import { getDetailsToken } from './tokens';
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import type { ModelTokensUsage } from '@lobechat/model-runtime';
|
2
|
+
import { LobeDefaultAiModelListItem } from 'model-bank';
|
3
|
+
|
3
4
|
import { getAudioInputUnitRate, getAudioOutputUnitRate } from '@/utils/pricing';
|
4
5
|
|
5
6
|
import { getPrice } from './pricing';
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
1
2
|
import debug from 'debug';
|
2
3
|
import { NextRequest } from 'next/server';
|
3
4
|
|
4
|
-
import {
|
5
|
+
import { LOBE_CHAT_AUTH_HEADER } from '@/const/auth';
|
5
6
|
import { LobeChatDatabase } from '@/database/type';
|
6
7
|
import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
|
7
8
|
|
@@ -1,12 +1,8 @@
|
|
1
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
1
2
|
import { User } from 'next-auth';
|
2
3
|
import { NextRequest } from 'next/server';
|
3
4
|
|
4
|
-
import {
|
5
|
-
ClientSecretPayload,
|
6
|
-
LOBE_CHAT_AUTH_HEADER,
|
7
|
-
enableClerk,
|
8
|
-
enableNextAuth,
|
9
|
-
} from '@/const/auth';
|
5
|
+
import { LOBE_CHAT_AUTH_HEADER, enableClerk, enableNextAuth } from '@/const/auth';
|
10
6
|
import { ClerkAuth, IClerkAuth } from '@/libs/clerk-auth';
|
11
7
|
|
12
8
|
export interface AuthContext {
|
@@ -1,10 +1,10 @@
|
|
1
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
1
2
|
import { parse } from 'cookie';
|
2
3
|
import debug from 'debug';
|
3
4
|
import { User } from 'next-auth';
|
4
5
|
import { NextRequest } from 'next/server';
|
5
6
|
|
6
7
|
import {
|
7
|
-
ClientSecretPayload,
|
8
8
|
LOBE_CHAT_AUTH_HEADER,
|
9
9
|
LOBE_CHAT_OIDC_AUTH_HEADER,
|
10
10
|
enableClerk,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { ModelProvider } from '@lobechat/model-runtime';
|
2
|
+
import { ProviderConfig } from '@lobechat/types';
|
3
|
+
import { extractEnabledModels, transformToAiModelList } from '@lobechat/utils';
|
2
4
|
import * as AiModels from 'model-bank';
|
5
|
+
import { AiFullModelCard } from 'model-bank';
|
3
6
|
|
4
7
|
import { getLLMConfig } from '@/config/llm';
|
5
|
-
import { AiFullModelCard } from '@/types/aiModel';
|
6
|
-
import { ProviderConfig } from '@/types/user/settings';
|
7
|
-
import { extractEnabledModels, transformToAiModelList } from '@/utils/parseModels';
|
8
8
|
|
9
9
|
interface ProviderSpecificConfig {
|
10
10
|
enabled?: boolean;
|
@@ -21,9 +21,9 @@ import {
|
|
21
21
|
ModelProvider,
|
22
22
|
} from '@lobechat/model-runtime';
|
23
23
|
import { ModelRuntime } from '@lobechat/model-runtime';
|
24
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
24
25
|
import { describe, expect, it, vi } from 'vitest';
|
25
26
|
|
26
|
-
import { ClientSecretPayload } from '@/const/auth';
|
27
27
|
import { LobeStepfunAI } from '@/libs/model-runtime/stepfun';
|
28
28
|
|
29
29
|
import { initModelRuntimeWithUserPayload } from './index';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ModelProvider, ModelRuntime } from '@lobechat/model-runtime';
|
2
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
2
3
|
|
3
4
|
import { getLLMConfig } from '@/config/llm';
|
4
|
-
import { ClientSecretPayload } from '@/const/auth';
|
5
5
|
|
6
6
|
import apiKeyManager from './apiKeyManager';
|
7
7
|
|
@@ -1,9 +1,10 @@
|
|
1
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
1
2
|
import { createTRPCClient, httpLink } from '@trpc/client';
|
2
3
|
import superjson from 'superjson';
|
3
4
|
import urlJoin from 'url-join';
|
4
5
|
|
5
6
|
import { serverDBEnv } from '@/config/db';
|
6
|
-
import {
|
7
|
+
import { LOBE_CHAT_AUTH_HEADER } from '@/const/auth';
|
7
8
|
import { isDesktop } from '@/const/version';
|
8
9
|
import { appEnv } from '@/envs/app';
|
9
10
|
import { createAsyncCallerFactory } from '@/libs/trpc/async';
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { AgentRuntimeErrorType } from '@lobechat/model-runtime';
|
2
|
+
import { AsyncTaskError, AsyncTaskErrorType, AsyncTaskStatus } from '@lobechat/types';
|
1
3
|
import debug from 'debug';
|
2
4
|
import { RuntimeImageGenParams } from 'model-bank';
|
3
5
|
import { z } from 'zod';
|
@@ -5,11 +7,9 @@ import { z } from 'zod';
|
|
5
7
|
import { ASYNC_TASK_TIMEOUT, AsyncTaskModel } from '@/database/models/asyncTask';
|
6
8
|
import { FileModel } from '@/database/models/file';
|
7
9
|
import { GenerationModel } from '@/database/models/generation';
|
8
|
-
import { AgentRuntimeErrorType } from '@/libs/model-runtime/error';
|
9
10
|
import { asyncAuthedProcedure, asyncRouter as router } from '@/libs/trpc/async';
|
10
11
|
import { initModelRuntimeWithUserPayload } from '@/server/modules/ModelRuntime';
|
11
12
|
import { GenerationService } from '@/server/services/generation';
|
12
|
-
import { AsyncTaskError, AsyncTaskErrorType, AsyncTaskStatus } from '@/types/asyncTask';
|
13
13
|
|
14
14
|
const log = debug('lobe-image:async');
|
15
15
|
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
CreateAiModelSchema,
|
13
13
|
ToggleAiModelEnableSchema,
|
14
14
|
UpdateAiModelSchema,
|
15
|
-
} from '
|
15
|
+
} from '../../../../packages/model-bank/src/types/aiModel';
|
16
16
|
import { ProviderConfig } from '@/types/user/settings';
|
17
17
|
|
18
18
|
const aiModelProcedure = authedProcedure.use(serverDatabase).use(async (opts) => {
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import { ClientSecretPayload } from '
|
1
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
2
|
+
|
2
3
|
import { AsyncTaskModel } from '@/database/models/asyncTask';
|
3
4
|
import { FileModel } from '@/database/models/file';
|
4
5
|
import { LobeChatDatabase } from '@/database/type';
|
@@ -1,12 +1,12 @@
|
|
1
|
+
import { parseDataUri } from '@lobechat/model-runtime';
|
1
2
|
import debug from 'debug';
|
2
3
|
import { sha256 } from 'js-sha256';
|
3
4
|
import mime from 'mime';
|
5
|
+
import { IMAGE_GENERATION_CONFIG } from 'model-bank';
|
4
6
|
import { nanoid } from 'nanoid';
|
5
7
|
import sharp from 'sharp';
|
6
8
|
|
7
|
-
import { IMAGE_GENERATION_CONFIG } from '@/const/image';
|
8
9
|
import { LobeChatDatabase } from '@/database/type';
|
9
|
-
import { parseDataUri } from '@/libs/model-runtime/utils/uriParser';
|
10
10
|
import { FileService } from '@/server/services/file';
|
11
11
|
import { calculateThumbnailDimensions } from '@/utils/number';
|
12
12
|
import { getYYYYmmddHHMMss } from '@/utils/time';
|
package/src/services/_auth.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { ModelProvider } from '@lobechat/model-runtime';
|
2
|
+
import { ClientSecretPayload } from '@lobechat/types';
|
2
3
|
|
3
|
-
import {
|
4
|
+
import { LOBE_CHAT_AUTH_HEADER } from '@/const/auth';
|
4
5
|
import { isDeprecatedEdition } from '@/const/version';
|
5
6
|
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
6
7
|
import { useUserStore } from '@/store/user';
|
@@ -1,7 +1,7 @@
|
|
1
|
+
import { AiProviderModelListItem } from 'model-bank';
|
1
2
|
import { describe, expect, it, vi } from 'vitest';
|
2
3
|
|
3
4
|
import { lambdaClient } from '@/libs/trpc/client';
|
4
|
-
import { AiProviderModelListItem } from '@/types/aiModel';
|
5
5
|
|
6
6
|
import { ServerService } from './server';
|
7
7
|
|
package/src/services/chat.ts
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
ChatCompletionErrorPayload,
|
4
4
|
ModelProvider,
|
5
5
|
ModelRuntime,
|
6
|
+
parseDataUri,
|
6
7
|
} from '@lobechat/model-runtime';
|
7
8
|
import { BuiltinSystemRolePrompts, filesPrompts } from '@lobechat/prompts';
|
8
9
|
import { ChatErrorType, TracePayload, TraceTagMap } from '@lobechat/types';
|
@@ -15,7 +16,6 @@ import { INBOX_GUIDE_SYSTEMROLE } from '@/const/guide';
|
|
15
16
|
import { INBOX_SESSION_ID } from '@/const/session';
|
16
17
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
17
18
|
import { isDeprecatedEdition, isDesktop, isServerMode } from '@/const/version';
|
18
|
-
import { parseDataUri } from '@/libs/model-runtime/utils/uriParser';
|
19
19
|
import { getAgentStoreState } from '@/store/agent';
|
20
20
|
import { agentChatConfigSelectors } from '@/store/agent/selectors';
|
21
21
|
import { aiModelSelectors, aiProviderSelectors, getAiInfraStoreState } from '@/store/aiInfra';
|
package/src/services/upload.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
+
import { isDesktop, isServerMode } from '@lobechat/const';
|
2
|
+
import { parseDataUri } from '@lobechat/model-runtime';
|
3
|
+
import { uuid } from '@lobechat/utils';
|
1
4
|
import dayjs from 'dayjs';
|
2
5
|
import { sha256 } from 'js-sha256';
|
3
6
|
|
4
7
|
import { fileEnv } from '@/config/file';
|
5
|
-
import { isDesktop, isServerMode } from '@/const/version';
|
6
|
-
import { parseDataUri } from '@/libs/model-runtime/utils/uriParser';
|
7
8
|
import { edgeClient } from '@/libs/trpc/client';
|
8
9
|
import { API_ENDPOINTS } from '@/services/_url';
|
9
10
|
import { clientS3Storage } from '@/services/file/ClientS3';
|
10
11
|
import { FileMetadata, UploadBase64ToS3Result } from '@/types/files';
|
11
12
|
import { FileUploadState, FileUploadStatus } from '@/types/files/upload';
|
12
|
-
import { uuid } from '@/utils/uuid';
|
13
13
|
|
14
14
|
export const UPLOAD_NETWORK_ERROR = 'NetWorkError';
|
15
15
|
|
@@ -15,7 +15,7 @@ import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
|
|
15
15
|
import { KnowledgeItem } from '@/types/knowledgeBase';
|
16
16
|
import { merge } from '@/utils/merge';
|
17
17
|
|
18
|
-
import { AgentStore } from '../../store';
|
18
|
+
import type { AgentStore } from '../../store';
|
19
19
|
import { agentSelectors } from './selectors';
|
20
20
|
|
21
21
|
/**
|
@@ -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
|
|