@lobehub/lobehub 2.0.0-next.1 → 2.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/changelog/v1.json +18 -0
  3. package/package.json +1 -1
  4. package/packages/const/src/models.ts +13 -0
  5. package/packages/model-bank/src/aiModels/azure.ts +155 -0
  6. package/packages/model-bank/src/aiModels/bedrock.ts +44 -0
  7. package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +1 -1
  8. package/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts +33 -3
  9. package/packages/model-runtime/src/core/parameterResolver.ts +3 -0
  10. package/packages/model-runtime/src/providers/azureOpenai/index.ts +2 -1
  11. package/src/app/(backend)/oidc/consent/route.ts +0 -1
  12. package/src/app/[variants]/(main)/settings/_layout/SettingsContent.tsx +0 -3
  13. package/src/features/AgentSetting/AgentPlugin/index.tsx +20 -12
  14. package/src/app/[variants]/(main)/settings/llm/ProviderList/Azure/index.tsx +0 -93
  15. package/src/app/[variants]/(main)/settings/llm/ProviderList/Bedrock/index.tsx +0 -70
  16. package/src/app/[variants]/(main)/settings/llm/ProviderList/Cloudflare/index.tsx +0 -39
  17. package/src/app/[variants]/(main)/settings/llm/ProviderList/Github/index.tsx +0 -52
  18. package/src/app/[variants]/(main)/settings/llm/ProviderList/HuggingFace/index.tsx +0 -52
  19. package/src/app/[variants]/(main)/settings/llm/ProviderList/Ollama/index.tsx +0 -20
  20. package/src/app/[variants]/(main)/settings/llm/ProviderList/OpenAI/index.tsx +0 -17
  21. package/src/app/[variants]/(main)/settings/llm/ProviderList/providers.tsx +0 -132
  22. package/src/app/[variants]/(main)/settings/llm/components/Checker.tsx +0 -118
  23. package/src/app/[variants]/(main)/settings/llm/components/ProviderConfig/index.tsx +0 -303
  24. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +0 -98
  25. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelConfigModal/Form.tsx +0 -104
  26. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelConfigModal/index.tsx +0 -77
  27. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +0 -105
  28. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/Option.tsx +0 -68
  29. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/index.tsx +0 -146
  30. package/src/app/[variants]/(main)/settings/llm/const.ts +0 -20
  31. package/src/app/[variants]/(main)/settings/llm/features/Footer.tsx +0 -35
  32. package/src/app/[variants]/(main)/settings/llm/index.tsx +0 -30
  33. package/src/app/[variants]/(main)/settings/llm/type.ts +0 -5
@@ -1,39 +0,0 @@
1
- 'use client';
2
-
3
- import { Input, InputPassword } from '@lobehub/ui';
4
- import { useTranslation } from 'react-i18next';
5
-
6
- import { CloudflareProviderCard } from '@/config/modelProviders';
7
- import { GlobalLLMProviderKey } from '@/types/user/settings';
8
-
9
- import { KeyVaultsConfigKey } from '../../const';
10
- import { ProviderItem } from '../../type';
11
-
12
- const providerKey: GlobalLLMProviderKey = 'cloudflare';
13
-
14
- export const useCloudflareProvider = (): ProviderItem => {
15
- const { t } = useTranslation('modelProvider');
16
-
17
- return {
18
- ...CloudflareProviderCard,
19
- apiKeyItems: [
20
- {
21
- children: (
22
- <InputPassword
23
- autoComplete={'new-password'}
24
- placeholder={t(`${providerKey}.apiKey.placeholder`)}
25
- />
26
- ),
27
- desc: t(`${providerKey}.apiKey.desc`),
28
- label: t(`${providerKey}.apiKey.title`),
29
- name: [KeyVaultsConfigKey, providerKey, 'apiKey'],
30
- },
31
- {
32
- children: <Input placeholder={t(`${providerKey}.baseURLOrAccountID.placeholder`)} />,
33
- desc: t(`${providerKey}.baseURLOrAccountID.desc`),
34
- label: t(`${providerKey}.baseURLOrAccountID.title`),
35
- name: [KeyVaultsConfigKey, providerKey, 'baseURLOrAccountID'],
36
- },
37
- ],
38
- };
39
- };
@@ -1,52 +0,0 @@
1
- 'use client';
2
-
3
- import { InputPassword, Markdown } from '@lobehub/ui';
4
- import { createStyles } from 'antd-style';
5
- import { useTranslation } from 'react-i18next';
6
-
7
- import { GithubProviderCard } from '@/config/modelProviders';
8
- import { GlobalLLMProviderKey } from '@/types/user/settings';
9
-
10
- import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
11
- import { ProviderItem } from '../../type';
12
-
13
- const useStyles = createStyles(({ css, token }) => ({
14
- markdown: css`
15
- p {
16
- color: ${token.colorTextDescription} !important;
17
- }
18
- `,
19
- tip: css`
20
- font-size: 12px;
21
- color: ${token.colorTextDescription};
22
- `,
23
- }));
24
-
25
- const providerKey: GlobalLLMProviderKey = 'github';
26
-
27
- // Same as OpenAIProvider, but replace API Key with Github Personal Access Token
28
- export const useGithubProvider = (): ProviderItem => {
29
- const { t } = useTranslation('modelProvider');
30
- const { styles } = useStyles();
31
-
32
- return {
33
- ...GithubProviderCard,
34
- apiKeyItems: [
35
- {
36
- children: (
37
- <InputPassword
38
- autoComplete={'new-password'}
39
- placeholder={t(`${providerKey}.personalAccessToken.placeholder`)}
40
- />
41
- ),
42
- desc: (
43
- <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
44
- {t(`${providerKey}.personalAccessToken.desc`)}
45
- </Markdown>
46
- ),
47
- label: t(`${providerKey}.personalAccessToken.title`),
48
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
49
- },
50
- ],
51
- };
52
- };
@@ -1,52 +0,0 @@
1
- 'use client';
2
-
3
- import { GlobalLLMProviderKey } from '@lobechat/types';
4
- import { InputPassword, Markdown } from '@lobehub/ui';
5
- import { createStyles } from 'antd-style';
6
- import { useTranslation } from 'react-i18next';
7
-
8
- import { HuggingFaceProviderCard } from '@/config/modelProviders';
9
-
10
- import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
11
- import { ProviderItem } from '../../type';
12
-
13
- const useStyles = createStyles(({ css, token }) => ({
14
- markdown: css`
15
- p {
16
- color: ${token.colorTextDescription} !important;
17
- }
18
- `,
19
- tip: css`
20
- font-size: 12px;
21
- color: ${token.colorTextDescription};
22
- `,
23
- }));
24
-
25
- const providerKey: GlobalLLMProviderKey = 'huggingface';
26
-
27
- // Same as OpenAIProvider, but replace API Key with HuggingFace Access Token
28
- export const useHuggingFaceProvider = (): ProviderItem => {
29
- const { t } = useTranslation('modelProvider');
30
- const { styles } = useStyles();
31
-
32
- return {
33
- ...HuggingFaceProviderCard,
34
- apiKeyItems: [
35
- {
36
- children: (
37
- <InputPassword
38
- autoComplete={'new-password'}
39
- placeholder={t(`${providerKey}.accessToken.placeholder`)}
40
- />
41
- ),
42
- desc: (
43
- <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
44
- {t(`${providerKey}.accessToken.desc`)}
45
- </Markdown>
46
- ),
47
- label: t(`${providerKey}.accessToken.title`),
48
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
49
- },
50
- ],
51
- };
52
- };
@@ -1,20 +0,0 @@
1
- 'use client';
2
-
3
- import { useTranslation } from 'react-i18next';
4
-
5
- import { OllamaProviderCard } from '@/config/modelProviders';
6
-
7
- import { ProviderItem } from '../../type';
8
-
9
- export const useOllamaProvider = (): ProviderItem => {
10
- const { t } = useTranslation('modelProvider');
11
-
12
- return {
13
- ...OllamaProviderCard,
14
- proxyUrl: {
15
- desc: t('ollama.endpoint.desc'),
16
- placeholder: 'http://127.0.0.1:11434',
17
- title: t('ollama.endpoint.title'),
18
- },
19
- };
20
- };
@@ -1,17 +0,0 @@
1
- 'use client';
2
-
3
- import { OpenAIProviderCard } from '@/config/modelProviders';
4
- import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
5
-
6
- import { ProviderItem } from '../../type';
7
-
8
- export const useOpenAIProvider = (): ProviderItem => {
9
- const { showOpenAIProxyUrl, showOpenAIApiKey } = useServerConfigStore(featureFlagsSelectors);
10
- return {
11
- ...OpenAIProviderCard,
12
- proxyUrl: showOpenAIProxyUrl && {
13
- placeholder: 'https://api.openai.com/v1',
14
- },
15
- showApiKey: showOpenAIApiKey,
16
- };
17
- };
@@ -1,132 +0,0 @@
1
- import { useMemo } from 'react';
2
-
3
- import {
4
- Ai21ProviderCard,
5
- Ai302ProviderCard,
6
- Ai360ProviderCard,
7
- AkashChatProviderCard,
8
- AnthropicProviderCard,
9
- BaichuanProviderCard,
10
- CohereProviderCard,
11
- DeepSeekProviderCard,
12
- FireworksAIProviderCard,
13
- GiteeAIProviderCard,
14
- GoogleProviderCard,
15
- GroqProviderCard,
16
- HigressProviderCard,
17
- HunyuanProviderCard,
18
- InfiniAIProviderCard,
19
- InternLMProviderCard,
20
- JinaProviderCard,
21
- MinimaxProviderCard,
22
- MistralProviderCard,
23
- MoonshotProviderCard,
24
- NovitaProviderCard,
25
- NvidiaProviderCard,
26
- OllamaCloudProviderCard,
27
- OpenRouterProviderCard,
28
- PPIOProviderCard,
29
- PerplexityProviderCard,
30
- QiniuProviderCard,
31
- QwenProviderCard,
32
- SambaNovaProviderCard,
33
- Search1APIProviderCard,
34
- SenseNovaProviderCard,
35
- SiliconCloudProviderCard,
36
- SparkProviderCard,
37
- StepfunProviderCard,
38
- TaichuProviderCard,
39
- TogetherAIProviderCard,
40
- UpstageProviderCard,
41
- V0ProviderCard,
42
- VLLMProviderCard,
43
- WenxinProviderCard,
44
- XAIProviderCard,
45
- XinferenceProviderCard,
46
- ZeroOneProviderCard,
47
- ZhiPuProviderCard,
48
- } from '@/config/modelProviders';
49
-
50
- import { ProviderItem } from '../type';
51
- import { useAzureProvider } from './Azure';
52
- import { useBedrockProvider } from './Bedrock';
53
- import { useCloudflareProvider } from './Cloudflare';
54
- import { useGithubProvider } from './Github';
55
- import { useHuggingFaceProvider } from './HuggingFace';
56
- import { useOllamaProvider } from './Ollama';
57
- import { useOpenAIProvider } from './OpenAI';
58
-
59
- export const useProviderList = (): ProviderItem[] => {
60
- const AzureProvider = useAzureProvider();
61
- const OllamaProvider = useOllamaProvider();
62
- const OpenAIProvider = useOpenAIProvider();
63
- const BedrockProvider = useBedrockProvider();
64
- const CloudflareProvider = useCloudflareProvider();
65
- const GithubProvider = useGithubProvider();
66
- const HuggingFaceProvider = useHuggingFaceProvider();
67
-
68
- return useMemo(
69
- () => [
70
- OpenAIProvider,
71
- AzureProvider,
72
- OllamaProvider,
73
- VLLMProviderCard,
74
- XinferenceProviderCard,
75
- AnthropicProviderCard,
76
- BedrockProvider,
77
- GoogleProviderCard,
78
- DeepSeekProviderCard,
79
- HuggingFaceProvider,
80
- OpenRouterProviderCard,
81
- CloudflareProvider,
82
- GithubProvider,
83
- NovitaProviderCard,
84
- TogetherAIProviderCard,
85
- FireworksAIProviderCard,
86
- GroqProviderCard,
87
- NvidiaProviderCard,
88
- PerplexityProviderCard,
89
- MistralProviderCard,
90
- Ai21ProviderCard,
91
- UpstageProviderCard,
92
- XAIProviderCard,
93
- JinaProviderCard,
94
- SambaNovaProviderCard,
95
- Search1APIProviderCard,
96
- CohereProviderCard,
97
- V0ProviderCard,
98
- QiniuProviderCard,
99
- QwenProviderCard,
100
- WenxinProviderCard,
101
- HunyuanProviderCard,
102
- SparkProviderCard,
103
- ZhiPuProviderCard,
104
- ZeroOneProviderCard,
105
- SenseNovaProviderCard,
106
- StepfunProviderCard,
107
- MoonshotProviderCard,
108
- BaichuanProviderCard,
109
- MinimaxProviderCard,
110
- Ai360ProviderCard,
111
- TaichuProviderCard,
112
- InternLMProviderCard,
113
- SiliconCloudProviderCard,
114
- HigressProviderCard,
115
- GiteeAIProviderCard,
116
- PPIOProviderCard,
117
- InfiniAIProviderCard,
118
- AkashChatProviderCard,
119
- Ai302ProviderCard,
120
- OllamaCloudProviderCard,
121
- ],
122
- [
123
- AzureProvider,
124
- OllamaProvider,
125
- OpenAIProvider,
126
- BedrockProvider,
127
- CloudflareProvider,
128
- GithubProvider,
129
- HuggingFaceProvider,
130
- ],
131
- );
132
- };
@@ -1,118 +0,0 @@
1
- 'use client';
2
-
3
- import { CheckCircleFilled } from '@ant-design/icons';
4
- import { ChatMessageError, TraceNameMap } from '@lobechat/types';
5
- import { Alert, Button, Highlighter } from '@lobehub/ui';
6
- import { useTheme } from 'antd-style';
7
- import { memo, useState } from 'react';
8
- import { useTranslation } from 'react-i18next';
9
- import { Flexbox } from 'react-layout-kit';
10
-
11
- import { useIsMobile } from '@/hooks/useIsMobile';
12
- import { useProviderName } from '@/hooks/useProviderName';
13
- import { chatService } from '@/services/chat';
14
-
15
- interface ConnectionCheckerProps {
16
- model: string;
17
- provider: string;
18
- }
19
-
20
- const Error = memo<{ error: ChatMessageError }>(({ error }) => {
21
- const { t } = useTranslation('error');
22
- const providerName = useProviderName(error.body?.provider);
23
-
24
- return (
25
- <Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
26
- <Alert
27
- banner
28
- extra={
29
- <Flexbox>
30
- <Highlighter actionIconSize={'small'} language={'json'} variant={'borderless'}>
31
- {JSON.stringify(error.body || error, null, 2)}
32
- </Highlighter>
33
- </Flexbox>
34
- }
35
- message={t(`response.${error.type}` as any, { provider: providerName })}
36
- showIcon
37
- type={'error'}
38
- />
39
- </Flexbox>
40
- );
41
- });
42
-
43
- const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
44
- const { t } = useTranslation('setting');
45
-
46
- const [loading, setLoading] = useState(false);
47
- const [pass, setPass] = useState(false);
48
-
49
- const theme = useTheme();
50
- const [error, setError] = useState<ChatMessageError | undefined>();
51
-
52
- const checkConnection = async () => {
53
- let isError = false;
54
-
55
- await chatService.fetchPresetTaskResult({
56
- onError: (_, rawError) => {
57
- setError(rawError);
58
- setPass(false);
59
- isError = true;
60
- },
61
- onFinish: async (value) => {
62
- if (!isError && value) {
63
- setError(undefined);
64
- setPass(true);
65
- } else {
66
- setPass(false);
67
- setError({
68
- body: value,
69
- message: t('response.ConnectionCheckFailed', { ns: 'error' }),
70
- type: 'ConnectionCheckFailed',
71
- });
72
- }
73
- },
74
- onLoadingChange: (loading) => {
75
- setLoading(loading);
76
- },
77
- params: {
78
- messages: [
79
- {
80
- content: '你好',
81
- role: 'user',
82
- },
83
- ],
84
- model,
85
- provider,
86
- },
87
- trace: {
88
- sessionId: `connection:${provider}`,
89
- topicId: model,
90
- traceName: TraceNameMap.ConnectivityChecker,
91
- },
92
- });
93
- };
94
- const isMobile = useIsMobile();
95
-
96
- return (
97
- <Flexbox align={isMobile ? 'flex-start' : 'flex-end'} gap={8}>
98
- <Flexbox align={'center'} direction={isMobile ? 'horizontal-reverse' : 'horizontal'} gap={12}>
99
- {pass && (
100
- <Flexbox gap={4} horizontal>
101
- <CheckCircleFilled
102
- style={{
103
- color: theme.colorSuccess,
104
- }}
105
- />
106
- {t('llm.checker.pass')}
107
- </Flexbox>
108
- )}
109
- <Button loading={loading} onClick={checkConnection}>
110
- {t('llm.checker.button')}
111
- </Button>
112
- </Flexbox>
113
- {error && <Error error={error} />}
114
- </Flexbox>
115
- );
116
- });
117
-
118
- export default Checker;