@lobehub/chat 0.122.9 → 0.123.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/.env.example +22 -2
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +25 -0
- package/README.md +11 -9
- package/README.zh-CN.md +11 -9
- package/docs/Deployment/Environment-Variable.md +65 -23
- package/docs/Deployment/Environment-Variable.zh-CN.md +64 -22
- package/locales/ar/chat.json +12 -1
- package/locales/ar/common.json +16 -0
- package/locales/ar/error.json +35 -6
- package/locales/ar/setting.json +53 -6
- package/locales/de-DE/chat.json +12 -1
- package/locales/de-DE/common.json +16 -0
- package/locales/de-DE/error.json +35 -6
- package/locales/de-DE/setting.json +53 -6
- package/locales/en-US/chat.json +13 -2
- package/locales/en-US/common.json +16 -0
- package/locales/en-US/error.json +35 -6
- package/locales/en-US/setting.json +53 -6
- package/locales/es-ES/chat.json +12 -1
- package/locales/es-ES/common.json +16 -0
- package/locales/es-ES/error.json +35 -6
- package/locales/es-ES/setting.json +53 -6
- package/locales/fr-FR/chat.json +13 -2
- package/locales/fr-FR/common.json +16 -0
- package/locales/fr-FR/error.json +35 -6
- package/locales/fr-FR/setting.json +53 -6
- package/locales/it-IT/chat.json +12 -1
- package/locales/it-IT/common.json +16 -0
- package/locales/it-IT/error.json +35 -6
- package/locales/it-IT/setting.json +53 -6
- package/locales/ja-JP/chat.json +12 -1
- package/locales/ja-JP/common.json +16 -0
- package/locales/ja-JP/error.json +35 -6
- package/locales/ja-JP/setting.json +53 -6
- package/locales/ko-KR/chat.json +12 -1
- package/locales/ko-KR/common.json +16 -0
- package/locales/ko-KR/error.json +35 -6
- package/locales/ko-KR/setting.json +53 -6
- package/locales/nl-NL/chat.json +12 -1
- package/locales/nl-NL/common.json +16 -0
- package/locales/nl-NL/error.json +35 -6
- package/locales/nl-NL/setting.json +53 -6
- package/locales/pl-PL/chat.json +12 -1
- package/locales/pl-PL/common.json +16 -0
- package/locales/pl-PL/error.json +35 -6
- package/locales/pl-PL/setting.json +53 -6
- package/locales/pt-BR/chat.json +12 -1
- package/locales/pt-BR/common.json +16 -0
- package/locales/pt-BR/error.json +35 -6
- package/locales/pt-BR/setting.json +53 -6
- package/locales/ru-RU/chat.json +12 -1
- package/locales/ru-RU/common.json +16 -0
- package/locales/ru-RU/error.json +35 -6
- package/locales/ru-RU/setting.json +53 -6
- package/locales/tr-TR/chat.json +12 -1
- package/locales/tr-TR/common.json +16 -0
- package/locales/tr-TR/error.json +35 -6
- package/locales/tr-TR/setting.json +53 -6
- package/locales/vi-VN/chat.json +12 -1
- package/locales/vi-VN/common.json +16 -0
- package/locales/vi-VN/error.json +35 -6
- package/locales/vi-VN/setting.json +53 -6
- package/locales/zh-CN/chat.json +12 -1
- package/locales/zh-CN/common.json +16 -0
- package/locales/zh-CN/error.json +34 -5
- package/locales/zh-CN/setting.json +59 -12
- package/locales/zh-TW/chat.json +12 -1
- package/locales/zh-TW/common.json +16 -0
- package/locales/zh-TW/error.json +35 -6
- package/locales/zh-TW/setting.json +53 -6
- package/next.config.mjs +8 -2
- package/package.json +8 -1
- package/src/app/api/chat/[provider]/agentRuntime.ts +129 -0
- package/src/app/api/chat/[provider]/route.ts +64 -0
- package/src/app/api/chat/auth.ts +42 -0
- package/src/app/api/chat/google/route.ts +86 -0
- package/src/app/api/config/route.ts +6 -1
- package/src/app/api/config.ts +3 -3
- package/src/app/api/errorResponse.test.ts +8 -8
- package/src/app/api/errorResponse.ts +43 -6
- package/src/app/api/openai/createBizOpenAI/createAzureOpenai.ts +1 -1
- package/src/app/api/openai/createBizOpenAI/createOpenai.ts +1 -1
- package/src/app/api/openai/createBizOpenAI/index.ts +2 -2
- package/src/app/chat/(desktop)/features/ChatHeader.tsx +6 -4
- package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +13 -3
- package/src/app/chat/(desktop)/features/ChatInput/Header/index.tsx +16 -24
- package/src/app/chat/(desktop)/features/SideBar/index.tsx +1 -0
- package/src/app/chat/features/ChatHeader/ShareButton/Preview.tsx +3 -3
- package/src/app/chat/features/SessionListContent/List/Item/index.tsx +2 -3
- package/src/app/settings/llm/Azure/index.tsx +145 -0
- package/src/app/settings/llm/Bedrock/index.tsx +109 -0
- package/src/app/settings/llm/{LLM/Checker.tsx → Checker.tsx} +11 -14
- package/src/app/settings/llm/Google/index.tsx +74 -0
- package/src/app/settings/llm/{LLM → OpenAI}/index.tsx +26 -44
- package/src/app/settings/llm/Zhipu/index.tsx +78 -0
- package/src/app/settings/llm/const.ts +13 -0
- package/src/app/settings/llm/page.tsx +42 -2
- package/src/app/settings/llm/useSyncSettings.ts +23 -0
- package/src/chains/__tests__/langDetect.test.ts +2 -2
- package/src/chains/__tests__/pickEmoji.test.ts +2 -2
- package/src/chains/langDetect.ts +2 -2
- package/src/chains/pickEmoji.ts +2 -2
- package/src/chains/summaryAgentName.ts +2 -2
- package/src/chains/summaryDescription.ts +2 -2
- package/src/chains/summaryTags.ts +2 -2
- package/src/chains/summaryTitle.ts +2 -2
- package/src/chains/translate.ts +2 -2
- package/src/components/ModelIcon/index.tsx +37 -0
- package/src/components/ModelProviderIcon/index.tsx +44 -0
- package/src/components/ModelSelect/index.tsx +133 -0
- package/src/components/ModelTag/ModelIcon.tsx +35 -0
- package/src/components/ModelTag/index.tsx +13 -0
- package/src/config/modelProviders/bedrock.ts +43 -0
- package/src/config/modelProviders/google.ts +20 -0
- package/src/config/modelProviders/index.ts +18 -0
- package/src/config/modelProviders/openai.ts +102 -0
- package/src/config/modelProviders/zhipu.ts +34 -0
- package/src/config/{server.ts → server/app.ts} +1 -24
- package/src/config/server/index.ts +13 -0
- package/src/config/server/provider.ts +78 -0
- package/src/const/auth.ts +30 -0
- package/src/const/fetch.ts +3 -0
- package/src/const/settings.ts +24 -4
- package/src/database/core/migrations/migrateSettingsToUser/index.test.ts +2 -1
- package/src/database/core/migrations/migrateSettingsToUser/index.ts +1 -18
- package/src/database/core/migrations/migrateSettingsToUser/type.ts +100 -0
- package/src/database/models/message.ts +3 -1
- package/src/database/schemas/message.ts +1 -0
- package/src/database/schemas/session.ts +1 -0
- package/src/features/AgentSetting/AgentConfig/ModelSelect.tsx +71 -0
- package/src/features/AgentSetting/AgentConfig/index.tsx +171 -161
- package/src/features/AgentSetting/AgentConfig/useSyncConfig.ts +23 -0
- package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +39 -0
- package/src/features/AgentSetting/AgentPrompt/index.tsx +4 -26
- package/src/features/AgentSetting/store/index.ts +10 -2
- package/src/features/ChatInput/ActionBar/FileUpload.tsx +11 -4
- package/src/features/ChatInput/ActionBar/ModelSwitch.tsx +56 -14
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +42 -7
- package/src/features/ChatInput/ActionBar/Token/index.tsx +5 -2
- package/src/features/ChatInput/ActionBar/Tools/index.tsx +11 -1
- package/src/features/ChatInput/useChatInput.ts +5 -1
- package/src/features/Conversation/Error/APIKeyForm/Bedrock.tsx +80 -0
- package/src/features/Conversation/Error/APIKeyForm/Google.tsx +61 -0
- package/src/features/Conversation/Error/APIKeyForm/OpenAI.tsx +63 -0
- package/src/features/Conversation/Error/APIKeyForm/Zhipu.tsx +62 -0
- package/src/features/Conversation/Error/APIKeyForm/index.tsx +72 -0
- package/src/features/Conversation/Error/AccessCodeForm.tsx +63 -0
- package/src/features/Conversation/Error/ErrorJsonViewer.tsx +26 -0
- package/src/features/Conversation/Error/InvalidAPIKey.tsx +16 -0
- package/src/features/Conversation/Error/InvalidAccessCode.tsx +50 -0
- package/src/features/Conversation/Error/OpenAiBizError.tsx +9 -17
- package/src/features/Conversation/Error/{Plugin/PluginSettings.tsx → PluginSettings.tsx} +8 -3
- package/src/features/Conversation/Error/index.tsx +75 -70
- package/src/features/Conversation/Error/style.tsx +9 -3
- package/src/features/Conversation/Extras/Assistant.tsx +2 -3
- package/src/features/Conversation/Plugins/Inspector/index.tsx +8 -2
- package/src/features/Conversation/components/ChatItem/index.tsx +9 -24
- package/src/features/Conversation/types/index.tsx +2 -5
- package/src/hooks/_header.ts +35 -0
- package/src/libs/agent-runtime/BaseAI.ts +9 -0
- package/src/libs/agent-runtime/azureOpenai/index.ts +72 -0
- package/src/libs/agent-runtime/bedrock/index.ts +134 -0
- package/src/libs/agent-runtime/error.ts +26 -0
- package/src/libs/agent-runtime/google/index.ts +160 -0
- package/src/libs/agent-runtime/index.ts +9 -0
- package/src/libs/agent-runtime/openai/index.test.ts +176 -0
- package/src/libs/agent-runtime/openai/index.ts +107 -0
- package/src/libs/agent-runtime/types/chat.ts +119 -0
- package/src/libs/agent-runtime/types/index.ts +2 -0
- package/src/libs/agent-runtime/types/type.ts +34 -0
- package/src/libs/agent-runtime/utils/createError.ts +10 -0
- package/src/libs/agent-runtime/utils/debugStream.ts +18 -0
- package/src/libs/agent-runtime/utils/env.ts +1 -0
- package/src/libs/agent-runtime/utils/handleOpenAIError.ts +39 -0
- package/src/libs/agent-runtime/utils/uriParser.ts +16 -0
- package/src/libs/agent-runtime/zhipu/authToken.ts +22 -0
- package/src/libs/agent-runtime/zhipu/index.ts +125 -0
- package/src/locales/default/chat.ts +12 -2
- package/src/locales/default/common.ts +16 -0
- package/src/locales/default/error.ts +42 -5
- package/src/locales/default/setting.ts +61 -12
- package/src/services/__tests__/chat.test.ts +8 -2
- package/src/services/__tests__/message.test.ts +1 -1
- package/src/services/_auth.ts +106 -0
- package/src/services/_header.ts +1 -0
- package/src/services/_url.ts +0 -2
- package/src/services/chat.ts +32 -14
- package/src/store/chat/slices/message/action.ts +9 -6
- package/src/store/global/slices/common/action.ts +8 -2
- package/src/store/global/slices/settings/action.test.ts +2 -2
- package/src/store/global/slices/settings/action.ts +11 -4
- package/src/store/global/slices/settings/selectors/__snapshots__/modelProvider.test.ts.snap +242 -78
- package/src/store/global/slices/settings/selectors/__snapshots__/selectors.test.ts.snap +2 -0
- package/src/store/global/slices/settings/selectors/modelProvider.test.ts +171 -47
- package/src/store/global/slices/settings/selectors/modelProvider.ts +136 -43
- package/src/store/session/slices/agent/selectors.test.ts +0 -48
- package/src/store/session/slices/agent/selectors.ts +7 -12
- package/src/types/agent/index.ts +6 -2
- package/src/types/fetch.ts +4 -2
- package/src/types/files.ts +3 -3
- package/src/types/llm.ts +27 -0
- package/src/types/message/index.ts +7 -3
- package/src/types/openai/chat.ts +6 -11
- package/src/types/settings/index.ts +1 -0
- package/src/types/settings/modelProvider.ts +37 -1
- package/src/utils/__snapshots__/parseModels.test.ts.snap +63 -0
- package/src/utils/parseModels.test.ts +24 -0
- package/src/utils/parseModels.ts +37 -0
- package/src/app/api/openai/chat/createChatCompletion.test.ts +0 -166
- package/src/app/api/openai/chat/createChatCompletion.ts +0 -76
- package/src/app/api/openai/chat/route.ts +0 -19
- package/src/app/api/openai/models/route.ts +0 -17
- package/src/app/settings/llm/LLM/ModelList.tsx +0 -51
- package/src/app/settings/llm/LLM/getModelList.ts +0 -9
- package/src/app/settings/llm/index.tsx +0 -36
- package/src/const/llm.ts +0 -32
- package/src/features/Conversation/Error/ApiKeyForm.tsx +0 -87
- package/src/features/Conversation/Error/ErrorActionContainer.tsx +0 -23
- package/src/features/Conversation/Error/InvalidAccess.tsx +0 -90
- package/src/features/Conversation/Error/OpenAPIKey.tsx +0 -13
- package/src/features/Conversation/Error/Plugin/PluginError.tsx +0 -30
- package/src/services/modelList.ts +0 -15
- /package/src/app/chat/(desktop)/features/ChatInput/{Header → Footer}/DragUpload.tsx +0 -0
- /package/src/{app/api/openai/chat → libs/agent-runtime/utils}/desensitizeUrl.test.ts +0 -0
- /package/src/{app/api/openai/chat → libs/agent-runtime/utils}/desensitizeUrl.ts +0 -0
- /package/src/types/{translate.ts → message/translate.ts} +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Icon } from '@lobehub/ui';
|
|
2
|
-
import { Button, Input } from 'antd';
|
|
3
|
-
import { Network } from 'lucide-react';
|
|
4
|
-
import { memo, useState } from 'react';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { Center, Flexbox } from 'react-layout-kit';
|
|
7
|
-
|
|
8
|
-
import { useChatStore } from '@/store/chat';
|
|
9
|
-
import { useGlobalStore } from '@/store/global';
|
|
10
|
-
import { modelProviderSelectors } from '@/store/global/selectors';
|
|
11
|
-
|
|
12
|
-
import { FormAction } from './style';
|
|
13
|
-
|
|
14
|
-
const APIKeyForm = memo<{ id: string }>(({ id }) => {
|
|
15
|
-
const { t } = useTranslation('error');
|
|
16
|
-
const [showProxy, setShow] = useState(false);
|
|
17
|
-
|
|
18
|
-
const [apiKey, proxyUrl, setConfig] = useGlobalStore((s) => [
|
|
19
|
-
modelProviderSelectors.openAIAPI(s),
|
|
20
|
-
modelProviderSelectors.openAIProxyUrl(s),
|
|
21
|
-
s.setOpenAIConfig,
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Center gap={16} style={{ maxWidth: 300 }}>
|
|
28
|
-
<FormAction
|
|
29
|
-
avatar={'🔑'}
|
|
30
|
-
description={t('unlock.apikey.description')}
|
|
31
|
-
title={t('unlock.apikey.title')}
|
|
32
|
-
>
|
|
33
|
-
<Input.Password
|
|
34
|
-
autoComplete={'new-password'}
|
|
35
|
-
onChange={(e) => {
|
|
36
|
-
setConfig({ OPENAI_API_KEY: e.target.value });
|
|
37
|
-
}}
|
|
38
|
-
placeholder={'sk-*****************************************'}
|
|
39
|
-
type={'block'}
|
|
40
|
-
value={apiKey}
|
|
41
|
-
/>
|
|
42
|
-
{showProxy ? (
|
|
43
|
-
<Input
|
|
44
|
-
onChange={(e) => {
|
|
45
|
-
setConfig({ endpoint: e.target.value });
|
|
46
|
-
}}
|
|
47
|
-
placeholder={'https://api.openai.com/v1'}
|
|
48
|
-
type={'block'}
|
|
49
|
-
value={proxyUrl}
|
|
50
|
-
/>
|
|
51
|
-
) : (
|
|
52
|
-
<Button
|
|
53
|
-
icon={<Icon icon={Network} />}
|
|
54
|
-
onClick={() => {
|
|
55
|
-
setShow(true);
|
|
56
|
-
}}
|
|
57
|
-
type={'text'}
|
|
58
|
-
>
|
|
59
|
-
{t('unlock.apikey.addProxyUrl')}
|
|
60
|
-
</Button>
|
|
61
|
-
)}
|
|
62
|
-
</FormAction>
|
|
63
|
-
<Flexbox gap={12} width={'100%'}>
|
|
64
|
-
<Button
|
|
65
|
-
block
|
|
66
|
-
onClick={() => {
|
|
67
|
-
resend(id);
|
|
68
|
-
deleteMessage(id);
|
|
69
|
-
}}
|
|
70
|
-
style={{ marginTop: 8 }}
|
|
71
|
-
type={'primary'}
|
|
72
|
-
>
|
|
73
|
-
{t('unlock.confirm')}
|
|
74
|
-
</Button>
|
|
75
|
-
<Button
|
|
76
|
-
onClick={() => {
|
|
77
|
-
deleteMessage(id);
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{t('unlock.closeMessage')}
|
|
81
|
-
</Button>
|
|
82
|
-
</Flexbox>
|
|
83
|
-
</Center>
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export default APIKeyForm;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createStyles } from 'antd-style';
|
|
2
|
-
import { ReactNode, memo } from 'react';
|
|
3
|
-
import { Center } from 'react-layout-kit';
|
|
4
|
-
|
|
5
|
-
const useStyles = createStyles(({ css, token }) => ({
|
|
6
|
-
container: css`
|
|
7
|
-
background: ${token.colorBgContainer};
|
|
8
|
-
border: 1px solid ${token.colorSplit};
|
|
9
|
-
border-radius: 8px;
|
|
10
|
-
`,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const ErrorActionContainer = memo<{ children: ReactNode }>(({ children }) => {
|
|
14
|
-
const { styles } = useStyles();
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Center className={styles.container} gap={24} padding={24}>
|
|
18
|
-
{children}
|
|
19
|
-
</Center>
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export default ErrorActionContainer;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Icon } from '@lobehub/ui';
|
|
2
|
-
import { Button, Input, Segmented } from 'antd';
|
|
3
|
-
import { AsteriskSquare, KeySquare } from 'lucide-react';
|
|
4
|
-
import { memo, useState } from 'react';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { Flexbox } from 'react-layout-kit';
|
|
7
|
-
|
|
8
|
-
import { useChatStore } from '@/store/chat';
|
|
9
|
-
import { useGlobalStore } from '@/store/global';
|
|
10
|
-
import { settingsSelectors } from '@/store/global/selectors';
|
|
11
|
-
|
|
12
|
-
import { RenderErrorMessage } from '../types';
|
|
13
|
-
import APIKeyForm from './ApiKeyForm';
|
|
14
|
-
import { ErrorActionContainer, FormAction } from './style';
|
|
15
|
-
|
|
16
|
-
enum Tab {
|
|
17
|
-
Api = 'api',
|
|
18
|
-
Password = 'password',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const InvalidAccess: RenderErrorMessage['Render'] = memo(({ id }) => {
|
|
22
|
-
const { t } = useTranslation('error');
|
|
23
|
-
const [mode, setMode] = useState<Tab>(Tab.Password);
|
|
24
|
-
const [password, setSettings] = useGlobalStore((s) => [
|
|
25
|
-
settingsSelectors.currentSettings(s).password,
|
|
26
|
-
s.setSettings,
|
|
27
|
-
]);
|
|
28
|
-
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<ErrorActionContainer>
|
|
32
|
-
<Segmented
|
|
33
|
-
block
|
|
34
|
-
onChange={(value) => setMode(value as Tab)}
|
|
35
|
-
options={[
|
|
36
|
-
{
|
|
37
|
-
icon: <Icon icon={AsteriskSquare} />,
|
|
38
|
-
label: t('password', { ns: 'common' }),
|
|
39
|
-
value: Tab.Password,
|
|
40
|
-
},
|
|
41
|
-
{ icon: <Icon icon={KeySquare} />, label: 'OpenAI API Key', value: Tab.Api },
|
|
42
|
-
]}
|
|
43
|
-
style={{ width: '100%' }}
|
|
44
|
-
value={mode}
|
|
45
|
-
/>
|
|
46
|
-
<Flexbox gap={24}>
|
|
47
|
-
{mode === Tab.Password && (
|
|
48
|
-
<>
|
|
49
|
-
<FormAction
|
|
50
|
-
avatar={'🗳'}
|
|
51
|
-
description={t('unlock.password.description')}
|
|
52
|
-
title={t('unlock.password.title')}
|
|
53
|
-
>
|
|
54
|
-
<Input.Password
|
|
55
|
-
autoComplete={'new-password'}
|
|
56
|
-
onChange={(e) => {
|
|
57
|
-
setSettings({ password: e.target.value });
|
|
58
|
-
}}
|
|
59
|
-
placeholder={t('unlock.password.placeholder')}
|
|
60
|
-
type={'block'}
|
|
61
|
-
value={password}
|
|
62
|
-
/>
|
|
63
|
-
</FormAction>
|
|
64
|
-
<Flexbox gap={12}>
|
|
65
|
-
<Button
|
|
66
|
-
onClick={() => {
|
|
67
|
-
resend(id);
|
|
68
|
-
deleteMessage(id);
|
|
69
|
-
}}
|
|
70
|
-
type={'primary'}
|
|
71
|
-
>
|
|
72
|
-
{t('unlock.confirm')}
|
|
73
|
-
</Button>
|
|
74
|
-
<Button
|
|
75
|
-
onClick={() => {
|
|
76
|
-
deleteMessage(id);
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
|
-
{t('unlock.closeMessage')}
|
|
80
|
-
</Button>
|
|
81
|
-
</Flexbox>
|
|
82
|
-
</>
|
|
83
|
-
)}
|
|
84
|
-
{mode === Tab.Api && <APIKeyForm id={id} />}
|
|
85
|
-
</Flexbox>
|
|
86
|
-
</ErrorActionContainer>
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
export default InvalidAccess;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { RenderErrorMessage } from '../types';
|
|
4
|
-
import APIKeyForm from './ApiKeyForm';
|
|
5
|
-
import { ErrorActionContainer } from './style';
|
|
6
|
-
|
|
7
|
-
const OpenAPIKey: RenderErrorMessage['Render'] = memo(({ id }) => (
|
|
8
|
-
<ErrorActionContainer>
|
|
9
|
-
<APIKeyForm id={id} />
|
|
10
|
-
</ErrorActionContainer>
|
|
11
|
-
));
|
|
12
|
-
|
|
13
|
-
export default OpenAPIKey;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Highlighter } from '@lobehub/ui';
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
import { Flexbox } from 'react-layout-kit';
|
|
4
|
-
|
|
5
|
-
import { RenderErrorMessage } from '../../types';
|
|
6
|
-
|
|
7
|
-
interface OpenAIError {
|
|
8
|
-
code: 'invalid_api_key' | string;
|
|
9
|
-
message: string;
|
|
10
|
-
param?: any;
|
|
11
|
-
type: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface OpenAIErrorResponse {
|
|
15
|
-
error: OpenAIError;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const PluginError: RenderErrorMessage['Render'] = memo(({ error, id }) => {
|
|
19
|
-
const errorBody: OpenAIErrorResponse = (error as any)?.body;
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Flexbox id={id} style={{ maxWidth: 600 }}>
|
|
23
|
-
<Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
|
|
24
|
-
{JSON.stringify(errorBody, null, 2)}
|
|
25
|
-
</Highlighter>
|
|
26
|
-
</Flexbox>
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export default PluginError;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LanguageModelWhiteList } from '@/const/llm';
|
|
2
|
-
|
|
3
|
-
import { createHeaderWithOpenAI } from './_header';
|
|
4
|
-
import { OPENAI_URLS } from './_url';
|
|
5
|
-
|
|
6
|
-
export const fetchModelList = async (): Promise<string[]> => {
|
|
7
|
-
const res = await fetch(OPENAI_URLS.models, {
|
|
8
|
-
headers: createHeaderWithOpenAI(),
|
|
9
|
-
method: 'POST',
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const modelList: string[] = await res.json();
|
|
13
|
-
|
|
14
|
-
return LanguageModelWhiteList.filter((i) => modelList.includes(i));
|
|
15
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|