mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
refactor: move src/config/modelProviders to model-bank
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { ModelProviderCard, UserModelProviderConfig } from '@lobechat/types';
|
||||
import { ModelProvider } from 'model-bank';
|
||||
|
||||
import * as ProviderCards from '@/config/modelProviders';
|
||||
import * as ProviderCards from 'model-bank/modelProviders';
|
||||
|
||||
const genUserLLMConfig = (specificConfig: Record<any, any>): UserModelProviderConfig => {
|
||||
return Object.keys(ModelProvider).reduce((config, providerKey) => {
|
||||
|
||||
@@ -8,8 +8,8 @@ import type {
|
||||
import { and, asc, desc, eq } from 'drizzle-orm';
|
||||
import { isEmpty } from 'es-toolkit/compat';
|
||||
import { ModelProvider } from 'model-bank';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { merge } from '@/utils/merge';
|
||||
|
||||
import { AiProviderSelectItem, aiModels, aiProviders } from '../schemas';
|
||||
|
||||
@@ -5,9 +5,9 @@ import type {
|
||||
EnabledProvider,
|
||||
} from '@lobechat/types';
|
||||
import { AiProviderModelListItem, EnabledAiModel } from 'model-bank';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { clientDB, initializeDB } from '@/database/client/db';
|
||||
|
||||
import { AiInfraRepos } from './index';
|
||||
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
EnabledAiModel,
|
||||
} from 'model-bank';
|
||||
import * as modelBank from 'model-bank';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
import pMap from 'p-map';
|
||||
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { merge, mergeArrayById } from '@/utils/merge';
|
||||
|
||||
import { AiModelModel } from '../../models/aiModel';
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./modelProviders": "./src/modelProviders/index.ts",
|
||||
"./ai21": "./src/aiModels/ai21.ts",
|
||||
"./ai302": "./src/aiModels/ai302.ts",
|
||||
"./ai360": "./src/aiModels/ai360.ts",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
|
||||
export const root = resolve(__dirname, '../..');
|
||||
|
||||
export interface DataItem {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { ProviderIcon } from '@lobehub/icons';
|
||||
import { uniqBy } from 'es-toolkit/compat';
|
||||
import { LayoutPanelTopIcon } from 'lucide-react';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
|
||||
export const useCategory = () => {
|
||||
const { t } = useTranslation('discover');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
const providerMap: { [key: string]: string } = {};
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { AutoComplete, Markdown } from '@lobehub/ui';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { ModelProvider } from 'model-bank';
|
||||
import { AzureProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormInput, FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { AzureProviderCard } from '@/config/modelProviders';
|
||||
import { aiModelSelectors, aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
|
||||
import { KeyVaultsConfigKey, LLMProviderApiTokenKey, LLMProviderBaseUrlKey } from '../../const';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { ModelProvider } from 'model-bank';
|
||||
import { AzureAIProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormInput, FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { AzureAIProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
|
||||
import { KeyVaultsConfigKey, LLMProviderApiTokenKey, LLMProviderBaseUrlKey } from '../../const';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { Select } from '@lobehub/ui';
|
||||
import { BedrockProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { BedrockProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import { CloudflareProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormInput, FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { CloudflareProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use client';
|
||||
|
||||
import { Select } from '@lobehub/ui';
|
||||
import { ComfyUIProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormInput, FormPassword } from '@/components/FormInput';
|
||||
import KeyValueEditor from '@/components/KeyValueEditor';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { ComfyUIProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
import ClientMode from './ClientMode';
|
||||
import ProviderDetail from './index';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import { Markdown } from '@lobehub/ui';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { GithubProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { GithubProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { NewAPIProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { NewAPIProviderCard } from '@/config/modelProviders';
|
||||
|
||||
import ProviderDetail from '../default';
|
||||
|
||||
const Page = () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { OllamaProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { OllamaProviderCard } from '@/config/modelProviders';
|
||||
|
||||
import ProviderDetail from '../default';
|
||||
import CheckError from './CheckError';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OpenAIProviderCard } from '@/config/modelProviders';
|
||||
import { OpenAIProviderCard } from 'model-bank/modelProviders';
|
||||
|
||||
import { useSettingsContext } from '../../../_layout/ContextProvider';
|
||||
import ProviderDetail from '../default';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import { Markdown, Select } from '@lobehub/ui';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { VertexAIProviderCard } from 'model-bank/modelProviders';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { FormPassword } from '@/components/FormInput';
|
||||
import { SkeletonInput } from '@/components/Skeleton';
|
||||
import { VertexAIProviderCard } from '@/config/modelProviders';
|
||||
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
export const useProviderName = (provider: string) => {
|
||||
// const { t } = useTranslation('modelProvider');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
||||
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
|
||||
|
||||
const locales: Record<`${string}.description`, string> = {};
|
||||
|
||||
|
||||
@@ -1190,7 +1190,7 @@ export class DiscoverService {
|
||||
log('_getProviderList: fetching provider list');
|
||||
const [{ LOBE_DEFAULT_MODEL_LIST }, { DEFAULT_MODEL_PROVIDER_LIST }] = await Promise.all([
|
||||
import('model-bank'),
|
||||
import('@/config/modelProviders'),
|
||||
import('model-bank/modelProviders'),
|
||||
]);
|
||||
const result = DEFAULT_MODEL_PROVIDER_LIST.map((item) => {
|
||||
const models = uniq(
|
||||
@@ -1480,7 +1480,7 @@ export class DiscoverService {
|
||||
log('getModelDetail: params=%O', params);
|
||||
const [{ LOBE_DEFAULT_MODEL_LIST }, { DEFAULT_MODEL_PROVIDER_LIST }] = await Promise.all([
|
||||
import('model-bank'),
|
||||
import('@/config/modelProviders'),
|
||||
import('model-bank/modelProviders'),
|
||||
]);
|
||||
const { identifier } = params;
|
||||
const all = await this._getModelList();
|
||||
|
||||
@@ -369,7 +369,7 @@ class ChatService {
|
||||
provider,
|
||||
});
|
||||
|
||||
const { DEFAULT_MODEL_PROVIDER_LIST } = await import('@/config/modelProviders');
|
||||
const { DEFAULT_MODEL_PROVIDER_LIST } = await import('model-bank/modelProviders');
|
||||
const providerConfig = DEFAULT_MODEL_PROVIDER_LIST.find((item) => item.id === provider);
|
||||
|
||||
const userPreferTransitionMode =
|
||||
|
||||
@@ -344,7 +344,7 @@ export const createAiProviderSlice: StateCreator<
|
||||
shouldFetch ? [AiProviderSwrKey.fetchAiProviderRuntimeState, isLogin] : null,
|
||||
async ([, isLogin]) => {
|
||||
const [{ LOBE_DEFAULT_MODEL_LIST: builtinAiModelList }, { DEFAULT_MODEL_PROVIDER_LIST }] =
|
||||
await Promise.all([import('model-bank'), import('@/config/modelProviders')]);
|
||||
await Promise.all([import('model-bank'), import('model-bank/modelProviders')]);
|
||||
|
||||
if (isLogin) {
|
||||
const data = await aiProviderService.getAiProviderRuntimeState();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isProviderDisableBrowserRequest } from '@/config/modelProviders';
|
||||
import { isProviderDisableBrowserRequest } from 'model-bank/modelProviders';
|
||||
|
||||
import { AIProviderStoreState } from '@/store/aiInfra/initialState';
|
||||
import { AiProviderRuntimeConfig, AiProviderSourceEnum } from '@/types/aiProvider';
|
||||
import { GlobalLLMProviderKey } from '@/types/user/settings';
|
||||
|
||||
Reference in New Issue
Block a user