@lobehub/chat 0.85.0 → 0.85.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/.github/workflows/sync.yml +2 -0
- package/CHANGELOG.md +50 -0
- package/locales/en_US/error.json +4 -3
- package/locales/ja_JP/error.json +4 -3
- package/locales/ko_KR/error.json +4 -3
- package/locales/ru_RU/error.json +4 -3
- package/locales/zh_CN/error.json +3 -2
- package/locales/zh_TW/error.json +4 -3
- package/package.json +1 -1
- package/src/app/api/auth.ts +2 -2
- package/src/app/api/openai/chat/route.ts +19 -5
- package/src/app/api/openai/createAzureOpenai.ts +4 -1
- package/src/app/api/openai/createOpenai.ts +6 -6
- package/src/app/api/openai/errorResponse.ts +1 -0
- package/src/app/chat/features/Conversation/ChatList/Error/OpenAPIKey.tsx +12 -0
- package/src/app/chat/features/Conversation/ChatList/Error/OpenAiBizError.tsx +4 -9
- package/src/app/chat/features/Conversation/ChatList/Error/index.tsx +5 -0
- package/src/app/welcome/features/Banner/index.tsx +16 -17
- package/src/const/layoutTokens.ts +1 -1
- package/src/layout/AppLayout.mobile.tsx +1 -0
- package/src/locales/default/error.ts +2 -1
- package/src/types/fetch.ts +3 -4
|
@@ -47,6 +47,8 @@ jobs:
|
|
|
47
47
|
|
|
48
48
|
由于 [LobeChat][lobechat] 上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,请查看 [详细教程][tutorial-zh-CN]
|
|
49
49
|
|
|
50
|
+

|
|
51
|
+
|
|
50
52
|
[lobechat]: https://github.com/lobehub/lobe-chat
|
|
51
53
|
[tutorial-zh-CN]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN
|
|
52
54
|
[tutorial-en-US]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.85.2](https://github.com/lobehub/lobe-chat/compare/v0.85.1...v0.85.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-10-10**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Add apikey form when there is no default api key in env.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Add apikey form when there is no default api key in env, closes [#290](https://github.com/lobehub/lobe-chat/issues/290) ([2c907e9](https://github.com/lobehub/lobe-chat/commit/2c907e9))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.85.1](https://github.com/lobehub/lobe-chat/compare/v0.85.0...v0.85.1)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-10-10**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Fix mobile safearea (fix.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Fix mobile safearea (fix, closes [#211](https://github.com/lobehub/lobe-chat/issues/211) ([68775b8](https://github.com/lobehub/lobe-chat/commit/68775b8))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 0.85.0](https://github.com/lobehub/lobe-chat/compare/v0.84.0...v0.85.0)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2023-10-10**</sup>
|
package/locales/en_US/error.json
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"PluginApiNotFound": "Sorry, the API does not exist in the plugin's manifest. Please check if your request method matches the plugin manifest API",
|
|
26
26
|
"PluginApiParamsError": "Sorry, the input parameter validation for the plugin request failed. Please check if the input parameters match the API description",
|
|
27
27
|
"PluginSettingsInvalid": "This plugin needs to be correctly configured before it can be used. Please check if your configuration is correct",
|
|
28
|
-
"PluginServerError": "Plugin server request returned an error. Please check your plugin manifest file, plugin configuration, or server implementation based on the error information below"
|
|
28
|
+
"PluginServerError": "Plugin server request returned an error. Please check your plugin manifest file, plugin configuration, or server implementation based on the error information below",
|
|
29
|
+
"NoAPIKey": "OpenAI API Key is empty, please add a custom OpenAI API Key"
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"title": "Use Custom API Key",
|
|
34
|
+
"description": "Enter your OpenAI API Key to start the conversation. The application will not record your API Key."
|
|
34
35
|
},
|
|
35
36
|
"confirm": "Confirm and Retry",
|
|
36
37
|
"password": {
|
package/locales/ja_JP/error.json
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"PluginMarketIndexInvalid": "申し訳ありませんが、プラグインのインデックスの検証に失敗しました。インデックスファイルの形式が正しいかどうかを確認してください",
|
|
26
26
|
"PluginManifestNotFound": "申し訳ありませんが、サーバーでプラグインのマニフェストファイル (manifest.json) が見つかりませんでした。プラグインのマニフェストファイルのアドレスが正しいかどうかを確認してください",
|
|
27
27
|
"PluginManifestInvalid": "申し訳ありませんが、このプラグインのマニフェストの検証に失敗しました。マニフェストの形式が正しいかどうかを確認してください",
|
|
28
|
-
"PluginApiNotFound": "申し訳ありませんが、プラグインのマニフェストに指定されたAPIが見つかりませんでした。リクエストメソッドとプラグインのマニフェストのAPIが一致しているかどうかを確認してください"
|
|
28
|
+
"PluginApiNotFound": "申し訳ありませんが、プラグインのマニフェストに指定されたAPIが見つかりませんでした。リクエストメソッドとプラグインのマニフェストのAPIが一致しているかどうかを確認してください",
|
|
29
|
+
"NoAPIKey": "OpenAI APIキーが空です。カスタムOpenAI APIキーを追加してください。"
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"title": "カスタムAPIキーの使用",
|
|
34
|
+
"description": "OpenAI APIキーを入力すると、会話を開始できます。アプリはあなたのAPIキーを記録しません。"
|
|
34
35
|
},
|
|
35
36
|
"closeMessage": "ヒントを閉じる",
|
|
36
37
|
"confirm": "確認して再試行",
|
package/locales/ko_KR/error.json
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"PluginSettingsInvalid": "플러그인을 사용하려면 올바른 구성이 필요합니다. 구성이 올바른지 확인해주세요.",
|
|
26
26
|
"PluginServerError": "플러그인 서버 요청이 오류로 반환되었습니다. 플러그인 설명 파일, 플러그인 구성 또는 서버 구현을 확인해주세요.",
|
|
27
27
|
"InvalidAccessCode": "암호가 올바르지 않거나 비어 있습니다. 올바른 액세스 암호를 입력하거나 사용자 지정 OpenAI API 키를 추가해주세요.",
|
|
28
|
-
"OpenAIBizError": "OpenAI 서비스 요청 중 오류가 발생했습니다. 아래 정보를 확인하고 문제를 해결하거나 다시 시도해주세요."
|
|
28
|
+
"OpenAIBizError": "OpenAI 서비스 요청 중 오류가 발생했습니다. 아래 정보를 확인하고 문제를 해결하거나 다시 시도해주세요.",
|
|
29
|
+
"NoAPIKey": "OpenAI API 키가 비어 있습니다. 사용자 정의 OpenAI API 키를 추가해주세요."
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"title": "사용자 정의 API 키 사용",
|
|
34
|
+
"description": "OpenAI API 키를 입력하면 대화를 시작할 수 있습니다. 애플리케이션은 API 키를 기록하지 않습니다."
|
|
34
35
|
},
|
|
35
36
|
"closeMessage": "알림 닫기",
|
|
36
37
|
"confirm": "확인 및 다시 시도",
|
package/locales/ru_RU/error.json
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"PluginApiNotFound": "К сожалению, API не существует в манифесте плагина. Пожалуйста, проверьте, соответствует ли ваш метод запроса API манифеста плагина",
|
|
26
26
|
"PluginApiParamsError": "К сожалению, проверка входных параметров для запроса плагина не удалась. Пожалуйста, проверьте, соответствуют ли входные параметры описанию API",
|
|
27
27
|
"PluginSettingsInvalid": "Этот плагин необходимо правильно настроить, прежде чем его можно будет использовать. Пожалуйста, проверьте правильность вашей конфигурации",
|
|
28
|
-
"PluginServerError": "Запрос сервера плагина возвратил ошибку. Проверьте файл манифеста плагина, конфигурацию плагина или реализацию сервера на основе информации об ошибке ниже"
|
|
28
|
+
"PluginServerError": "Запрос сервера плагина возвратил ошибку. Проверьте файл манифеста плагина, конфигурацию плагина или реализацию сервера на основе информации об ошибке ниже",
|
|
29
|
+
"NoAPIKey": "Ключ OpenAI API пуст, пожалуйста, добавьте свой собственный ключ OpenAI API"
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"title": "Использовать собственный ключ API",
|
|
34
|
+
"description": "Введите свой ключ API OpenAI, чтобы начать сеанс. Приложение не будет сохранять ваш ключ API."
|
|
34
35
|
},
|
|
35
36
|
"confirm": "Подтвердить и повторить попытку",
|
|
36
37
|
"password": {
|
package/locales/zh_CN/error.json
CHANGED
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"PluginSettingsInvalid": "该插件需要正确配置后才可以使用,请检查你的配置是否正确",
|
|
26
26
|
"PluginServerError": "插件服务端请求返回出错,请检查根据下面的报错信息检查你的插件描述文件、插件配置或服务端实现",
|
|
27
27
|
"InvalidAccessCode": "密码不正确或为空,请输入正确的访问密码,或者添加自定义 OpenAI API Key",
|
|
28
|
-
"OpenAIBizError": "请求 OpenAI 服务出错,请根据以下信息排查或重试"
|
|
28
|
+
"OpenAIBizError": "请求 OpenAI 服务出错,请根据以下信息排查或重试",
|
|
29
|
+
"NoAPIKey": "OpenAI API Key 为空,请添加自定义 OpenAI API Key"
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"description": "输入你的 OpenAI API Key
|
|
33
|
+
"description": "输入你的 OpenAI API Key 即可开始会话。应用不会记录你的 API Key",
|
|
33
34
|
"title": "使用自定义 API Key"
|
|
34
35
|
},
|
|
35
36
|
"closeMessage": "关闭提示",
|
package/locales/zh_TW/error.json
CHANGED
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
"PluginApiNotFound": "抱歉,外掛描述檔案中不存在該 API。請檢查您的請求方法與外掛清單 API 是否相符",
|
|
26
26
|
"PluginApiParamsError": "抱歉,該外掛請求的輸入參數驗證失敗。請檢查輸入參數與 API 描述資訊是否相符",
|
|
27
27
|
"PluginSettingsInvalid": "該外掛需要正確設定後才可以使用。請檢查您的設定是否正確",
|
|
28
|
-
"PluginServerError": "外掛伺服器請求回傳錯誤。請根據下面的錯誤資訊檢查您的外掛描述檔案、外掛設定或伺服器實作"
|
|
28
|
+
"PluginServerError": "外掛伺服器請求回傳錯誤。請根據下面的錯誤資訊檢查您的外掛描述檔案、外掛設定或伺服器實作",
|
|
29
|
+
"NoAPIKey": "OpenAI API 金鑰為空,請添加自訂 OpenAI API 金鑰"
|
|
29
30
|
},
|
|
30
31
|
"unlock": {
|
|
31
32
|
"apikey": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"title": "使用自定義 API Key",
|
|
34
|
+
"description": "輸入你的 OpenAI API Key 即可開始會話。應用程式不會記錄你的 API Key"
|
|
34
35
|
},
|
|
35
36
|
"confirm": "確認並重試",
|
|
36
37
|
"password": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.2",
|
|
4
4
|
"description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
package/src/app/api/auth.ts
CHANGED
|
@@ -9,12 +9,12 @@ interface AuthConfig {
|
|
|
9
9
|
export const checkAuth = ({ apiKey, accessCode }: AuthConfig) => {
|
|
10
10
|
const { ACCESS_CODE } = getServerConfig();
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// if apiKey exist
|
|
13
13
|
if (apiKey) {
|
|
14
14
|
return { auth: true };
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// if accessCode doesn't exist
|
|
18
18
|
if (!ACCESS_CODE) return { auth: true };
|
|
19
19
|
|
|
20
20
|
if (accessCode !== ACCESS_CODE) {
|
|
@@ -2,7 +2,7 @@ import OpenAI from 'openai';
|
|
|
2
2
|
|
|
3
3
|
import { getServerConfig } from '@/config/server';
|
|
4
4
|
import { getOpenAIAuthFromRequest } from '@/const/fetch';
|
|
5
|
-
import { ErrorType } from '@/types/fetch';
|
|
5
|
+
import { ChatErrorType, ErrorType } from '@/types/fetch';
|
|
6
6
|
import { OpenAIStreamPayload } from '@/types/openai';
|
|
7
7
|
|
|
8
8
|
import { checkAuth } from '../../auth';
|
|
@@ -29,10 +29,24 @@ export const POST = async (req: Request) => {
|
|
|
29
29
|
const { USE_AZURE_OPENAI } = getServerConfig();
|
|
30
30
|
const useAzureOpenAI = useAzure || USE_AZURE_OPENAI;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
try {
|
|
33
|
+
if (useAzureOpenAI) {
|
|
34
|
+
openai = createAzureOpenai({
|
|
35
|
+
apiVersion,
|
|
36
|
+
endpoint,
|
|
37
|
+
model: payload.model,
|
|
38
|
+
userApiKey: apiKey,
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
openai = createOpenai(apiKey, endpoint);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if ((error as Error).cause === ChatErrorType.NoAPIKey) {
|
|
45
|
+
return createErrorResponse(ChatErrorType.NoAPIKey);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.error(error); // log error to trace it
|
|
49
|
+
return createErrorResponse(ChatErrorType.InternalServerError);
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
return createChatCompletion({ openai, payload });
|
|
@@ -2,6 +2,7 @@ import OpenAI, { ClientOptions } from 'openai';
|
|
|
2
2
|
import urlJoin from 'url-join';
|
|
3
3
|
|
|
4
4
|
import { getServerConfig } from '@/config/server';
|
|
5
|
+
import { ChatErrorType } from '@/types/fetch';
|
|
5
6
|
|
|
6
7
|
// 创建 Azure OpenAI 实例
|
|
7
8
|
export const createAzureOpenai = (params: {
|
|
@@ -17,7 +18,9 @@ export const createAzureOpenai = (params: {
|
|
|
17
18
|
|
|
18
19
|
const defaultApiVersion = AZURE_API_VERSION || '2023-08-01-preview';
|
|
19
20
|
const apiVersion = !params.apiVersion ? defaultApiVersion : params.apiVersion;
|
|
20
|
-
const apiKey = !params.userApiKey ? AZURE_API_KEY
|
|
21
|
+
const apiKey = !params.userApiKey ? AZURE_API_KEY : params.userApiKey;
|
|
22
|
+
|
|
23
|
+
if (!apiKey) throw new Error('AZURE_API_KEY is empty', { cause: ChatErrorType.NoAPIKey });
|
|
21
24
|
|
|
22
25
|
const config: ClientOptions = {
|
|
23
26
|
apiKey,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import OpenAI
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
2
|
|
|
3
3
|
import { getServerConfig } from '@/config/server';
|
|
4
|
+
import { ChatErrorType } from '@/types/fetch';
|
|
4
5
|
|
|
5
6
|
// 创建 OpenAI 实例
|
|
6
7
|
export const createOpenai = (userApiKey: string | null, endpoint?: string | null) => {
|
|
@@ -8,10 +9,9 @@ export const createOpenai = (userApiKey: string | null, endpoint?: string | null
|
|
|
8
9
|
|
|
9
10
|
const baseURL = endpoint ? endpoint : OPENAI_PROXY_URL ? OPENAI_PROXY_URL : undefined;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
apiKey: !userApiKey ? OPENAI_API_KEY : userApiKey,
|
|
13
|
-
baseURL,
|
|
14
|
-
};
|
|
12
|
+
const apiKey = !userApiKey ? OPENAI_API_KEY : userApiKey;
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
if (!apiKey) throw new Error('OPENAI_API_KEY is empty', { cause: ChatErrorType.NoAPIKey });
|
|
15
|
+
|
|
16
|
+
return new OpenAI({ apiKey, baseURL });
|
|
17
17
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
import APIKeyForm from './ApiKeyForm';
|
|
4
|
+
import { ErrorActionContainer } from './style';
|
|
5
|
+
|
|
6
|
+
const OpenAPIKey = memo<{ id: string }>(({ id }) => (
|
|
7
|
+
<ErrorActionContainer>
|
|
8
|
+
<APIKeyForm id={id} />
|
|
9
|
+
</ErrorActionContainer>
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
export default OpenAPIKey;
|
|
@@ -2,8 +2,8 @@ import { Highlighter } from '@lobehub/ui';
|
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { Flexbox } from 'react-layout-kit';
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import OpenAPIKey from './OpenAPIKey';
|
|
6
|
+
import { useStyles } from './style';
|
|
7
7
|
|
|
8
8
|
interface OpenAIError {
|
|
9
9
|
code: 'invalid_api_key' | string;
|
|
@@ -21,13 +21,8 @@ const OpenAiBizError = memo<{ content: OpenAIErrorResponse; id: string }>(({ con
|
|
|
21
21
|
|
|
22
22
|
const errorCode = content.error?.code;
|
|
23
23
|
|
|
24
|
-
if (errorCode === 'invalid_api_key') {
|
|
25
|
-
|
|
26
|
-
<ErrorActionContainer>
|
|
27
|
-
<APIKeyForm id={id} />
|
|
28
|
-
</ErrorActionContainer>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
24
|
+
if (errorCode === 'invalid_api_key') return <OpenAPIKey id={id} />;
|
|
25
|
+
|
|
31
26
|
return (
|
|
32
27
|
<Flexbox className={styles.container} style={{ maxWidth: 600 }}>
|
|
33
28
|
<Highlighter language={'json'}>{JSON.stringify(content, null, 2)}</Highlighter>
|
|
@@ -5,6 +5,7 @@ import { ChatMessage } from '@/types/chatMessage';
|
|
|
5
5
|
import { ChatErrorType, ErrorType } from '@/types/fetch';
|
|
6
6
|
|
|
7
7
|
import InvalidAccess from './InvalidAccess';
|
|
8
|
+
import OpenAPIKey from './OpenAPIKey';
|
|
8
9
|
import OpenAiBizError from './OpenAiBizError';
|
|
9
10
|
import PluginError from './Plugin/PluginError';
|
|
10
11
|
import PluginSettings from './Plugin/PluginSettings';
|
|
@@ -36,6 +37,10 @@ export const renderErrorMessage: RenderErrorMessage = (error, message: ChatMessa
|
|
|
36
37
|
return <InvalidAccess id={message.id} />;
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
case ChatErrorType.NoAPIKey: {
|
|
41
|
+
return <OpenAPIKey id={message.id} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
case ChatErrorType.OpenAIBizError: {
|
|
40
45
|
return <OpenAiBizError content={(error as any).body} id={message.id} />;
|
|
41
46
|
}
|
|
@@ -4,12 +4,10 @@ import { Icon } from '@lobehub/ui';
|
|
|
4
4
|
import { useSize } from 'ahooks';
|
|
5
5
|
import { Button, Upload } from 'antd';
|
|
6
6
|
import { SendHorizonal } from 'lucide-react';
|
|
7
|
-
import Link from 'next/link';
|
|
8
7
|
import { memo, useCallback, useRef } from 'react';
|
|
9
8
|
import { useTranslation } from 'react-i18next';
|
|
10
9
|
import { Flexbox } from 'react-layout-kit';
|
|
11
10
|
|
|
12
|
-
import { SESSION_CHAT_URL } from '@/const/url';
|
|
13
11
|
import { useImportConfig } from '@/hooks/useImportConfig';
|
|
14
12
|
import { useSessionStore } from '@/store/session';
|
|
15
13
|
|
|
@@ -23,8 +21,12 @@ const Banner = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
|
23
21
|
const width = domSize?.width || 1024;
|
|
24
22
|
const { t } = useTranslation('welcome');
|
|
25
23
|
const { styles } = useStyles();
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const [switchSession, switchBackToChat, router, isMobile] = useSessionStore((s) => [
|
|
25
|
+
s.switchSession,
|
|
26
|
+
s.switchBackToChat,
|
|
27
|
+
s.router,
|
|
28
|
+
s.isMobile,
|
|
29
|
+
]);
|
|
28
30
|
const handleImport = useCallback((e: any) => {
|
|
29
31
|
importConfig(e);
|
|
30
32
|
switchSession();
|
|
@@ -47,20 +49,17 @@ const Banner = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
|
47
49
|
{t('button.import')}
|
|
48
50
|
</Button>
|
|
49
51
|
</Upload>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
onClick={(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}}
|
|
52
|
+
<Button
|
|
53
|
+
block={mobile}
|
|
54
|
+
onClick={() => (isMobile ? router?.push('/chat') : switchBackToChat())}
|
|
55
|
+
size={'large'}
|
|
56
|
+
type={'primary'}
|
|
56
57
|
>
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</Button>
|
|
63
|
-
</Link>
|
|
58
|
+
<Flexbox align={'center'} gap={4} horizontal justify={'center'}>
|
|
59
|
+
{t('button.start')}
|
|
60
|
+
<Icon icon={SendHorizonal} />
|
|
61
|
+
</Flexbox>
|
|
62
|
+
</Button>
|
|
64
63
|
</Flexbox>
|
|
65
64
|
</>
|
|
66
65
|
);
|
|
@@ -2,7 +2,7 @@ import type { FormProps } from '@lobehub/ui';
|
|
|
2
2
|
|
|
3
3
|
export const HEADER_HEIGHT = 64;
|
|
4
4
|
export const MOBILE_NABBAR_HEIGHT = 44;
|
|
5
|
-
export const MOBILE_TABBAR_HEIGHT =
|
|
5
|
+
export const MOBILE_TABBAR_HEIGHT = 60;
|
|
6
6
|
export const CHAT_TEXTAREA_HEIGHT = 200;
|
|
7
7
|
export const CHAT_TEXTAREA_HEIGHT_MOBILE = 120;
|
|
8
8
|
export const CHAT_SIDEBAR_WIDTH = 280;
|
|
@@ -32,11 +32,12 @@ export default {
|
|
|
32
32
|
|
|
33
33
|
InvalidAccessCode: '密码不正确或为空,请输入正确的访问密码,或者添加自定义 OpenAI API Key',
|
|
34
34
|
OpenAIBizError: '请求 OpenAI 服务出错,请根据以下信息排查或重试',
|
|
35
|
+
NoAPIKey: 'OpenAI API Key 为空,请添加自定义 OpenAI API Key',
|
|
35
36
|
/* eslint-enable */
|
|
36
37
|
},
|
|
37
38
|
unlock: {
|
|
38
39
|
apikey: {
|
|
39
|
-
description: '输入你的 OpenAI API Key
|
|
40
|
+
description: '输入你的 OpenAI API Key 即可开始会话。应用不会记录你的 API Key',
|
|
40
41
|
title: '使用自定义 API Key',
|
|
41
42
|
},
|
|
42
43
|
closeMessage: '关闭提示',
|
package/src/types/fetch.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
export const ChatErrorType = {
|
|
3
3
|
// ******* 业务错误语义 ******* //
|
|
4
4
|
|
|
5
|
-
// 密码无效
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
OpenAIBizError: 'OpenAIBizError',
|
|
5
|
+
InvalidAccessCode: 'InvalidAccessCode', // 密码无效
|
|
6
|
+
OpenAIBizError: 'OpenAIBizError', // OpenAI 返回的业务错误
|
|
7
|
+
NoAPIKey: 'NoAPIKey',
|
|
9
8
|
|
|
10
9
|
// ******* 客户端错误 ******* //
|
|
11
10
|
BadRequest: 400,
|