@lobehub/chat 0.82.5 → 0.82.7
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 +51 -0
- package/docs/Environment-Variable.md +0 -13
- package/docs/Environment-Variable.zh-CN.md +0 -11
- package/next.config.mjs +0 -18
- package/package.json +2 -2
- package/src/{pages/api/openai/chat.api.ts → app/api/openai/chat/route.ts} +6 -6
- package/src/{pages/api → app/api/openai}/createChatCompletion.ts +1 -1
- package/src/{pages/api/openai/models.api.ts → app/api/openai/models/route.ts} +3 -3
- package/src/app/api/plugins/route.ts +7 -0
- package/src/app/chat/features/Header/ShareButton/Inner.tsx +1 -1
- package/src/services/_url.ts +3 -12
- package/src/pages/api/plugins.api.ts +0 -9
- /package/src/{pages → app}/api/auth.ts +0 -0
- /package/src/{pages → app}/api/openai/createAzureOpenai.ts +0 -0
- /package/src/{pages → app}/api/openai/createOpenai.ts +0 -0
- /package/src/{pages/api/error.ts → app/api/openai/errorResponse.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.82.7](https://github.com/lobehub/lobe-chat/compare/v0.82.6...v0.82.7)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-09-30**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor the api router to app route handlers.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor the api router to app route handlers, closes [#254](https://github.com/lobehub/lobe-chat/issues/254) ([f032112](https://github.com/lobehub/lobe-chat/commit/f032112))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.82.6](https://github.com/lobehub/lobe-chat/compare/v0.82.5...v0.82.6)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-09-29**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Fix share default config, pin openai to fix type error.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Fix share default config ([e00d6bf](https://github.com/lobehub/lobe-chat/commit/e00d6bf))
|
|
46
|
+
- **misc**: Pin openai to fix type error ([5af4050](https://github.com/lobehub/lobe-chat/commit/5af4050))
|
|
47
|
+
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
<div align="right">
|
|
51
|
+
|
|
52
|
+
[](#readme-top)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
5
56
|
### [Version 0.82.5](https://github.com/lobehub/lobe-chat/compare/v0.82.4...v0.82.5)
|
|
6
57
|
|
|
7
58
|
<sup>Released on **2023-09-29**</sup>
|
|
@@ -19,8 +19,6 @@ LobeChat provides additional configuration options during deployment, which can
|
|
|
19
19
|
- [`AGENTS_INDEX_URL`](#agents_index_url)
|
|
20
20
|
- [Data Analytics](#data-analytics)
|
|
21
21
|
- [Posthog Analytics](#posthog-analytics)
|
|
22
|
-
- [Development Environment](#development-environment)
|
|
23
|
-
- [`DEV_API_END_PORT_URL`](#dev_api_end_port_url)
|
|
24
22
|
|
|
25
23
|
## General Variables
|
|
26
24
|
|
|
@@ -130,16 +128,5 @@ If you need to use Azure OpenAI to provide model services, you can refer to the
|
|
|
130
128
|
- Default: -
|
|
131
129
|
- Example: `1`
|
|
132
130
|
|
|
133
|
-
<br/>
|
|
134
|
-
|
|
135
|
-
## Development Environment
|
|
136
|
-
|
|
137
|
-
### `DEV_API_END_PORT_URL`
|
|
138
|
-
|
|
139
|
-
- Type: Optional
|
|
140
|
-
- Description: Define the proxy address of the LobeChat server request forwarding. Using this variable can conveniently forward requests to the line during development. See [configuration code](https://github.com/lobehub/lobe-chat/blob/main/next.config.mjs#L29-L38)
|
|
141
|
-
- Default: -
|
|
142
|
-
- Example: `https://chat-preview.lobehub.com`
|
|
143
|
-
|
|
144
131
|
[azure-api-verion-url]: https://docs.microsoft.com/zh-cn/azure/developer/javascript/api-reference/es-modules/azure-sdk/ai-translation/translationconfiguration?view=azure-node-latest#api-version
|
|
145
132
|
[openai-api-page]: https://platform.openai.com/account/api-keys
|
|
@@ -21,8 +21,6 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
21
21
|
- [Vercel Analytics](#vercel-analytics)
|
|
22
22
|
- [Mixpanel Analytics](#mixpanel-analytics)
|
|
23
23
|
- [Posthog Analytics](#posthog-analytics)
|
|
24
|
-
- [开发环境](#开发环境)
|
|
25
|
-
- [`DEV_API_END_PORT_URL`](#dev_api_end_port_url)
|
|
26
24
|
|
|
27
25
|
## 通用变量
|
|
28
26
|
|
|
@@ -169,15 +167,6 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
169
167
|
- 默认值: -
|
|
170
168
|
- 示例:`1`
|
|
171
169
|
|
|
172
|
-
## 开发环境
|
|
173
|
-
|
|
174
|
-
### `DEV_API_END_PORT_URL`
|
|
175
|
-
|
|
176
|
-
- 类型:可选
|
|
177
|
-
- 描述:定义 LobeChat 服务端请求转发的代理地址,使用该变量可以方便开发时将请求转发到线上。详见[配置代码](https://github.com/lobehub/lobe-chat/blob/main/next.config.mjs#L29-L38)
|
|
178
|
-
- 默认值:-
|
|
179
|
-
- 示例:`https://chat-preview.lobehub.com`
|
|
180
|
-
|
|
181
170
|
[azure-api-verion-url]: https://docs.microsoft.com/zh-cn/azure/developer/javascript/api-reference/es-modules/azure-sdk/ai-translation/translationconfiguration?view=azure-node-latest#api-version
|
|
182
171
|
[mixpanel-analytics-url]: https://mixpanel.com
|
|
183
172
|
[mixpanel-project-url]: https://mixpanel.com/settings/project
|
package/next.config.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import nextPWA from 'next-pwa';
|
|
2
2
|
|
|
3
3
|
const isProd = process.env.NODE_ENV === 'production';
|
|
4
|
-
const DEV_API_END_PORT_URL = process.env.DEV_API_END_PORT_URL || '';
|
|
5
4
|
|
|
6
5
|
const withPWA = nextPWA({
|
|
7
6
|
dest: 'public',
|
|
@@ -12,7 +11,6 @@ const withPWA = nextPWA({
|
|
|
12
11
|
/** @type {import('next').NextConfig} */
|
|
13
12
|
const nextConfig = {
|
|
14
13
|
reactStrictMode: true,
|
|
15
|
-
pageExtensions: ['tsx', 'api.ts'],
|
|
16
14
|
// not sure why antd-style cause multi ThemeProvider instance
|
|
17
15
|
// So we need to transpile it to lib mode
|
|
18
16
|
transpilePackages: ['@lobehub/ui', 'antd-style'],
|
|
@@ -25,22 +23,6 @@ const nextConfig = {
|
|
|
25
23
|
return config;
|
|
26
24
|
},
|
|
27
25
|
|
|
28
|
-
async rewrites() {
|
|
29
|
-
return [
|
|
30
|
-
{
|
|
31
|
-
source: '/api/openai/chat-dev',
|
|
32
|
-
destination: `${DEV_API_END_PORT_URL}/api/openai/chat`,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
source: '/api/openai/models-dev',
|
|
36
|
-
destination: `${DEV_API_END_PORT_URL}/api/openai/models`,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
source: '/api/plugins-dev',
|
|
40
|
-
destination: `${DEV_API_END_PORT_URL}/api/plugins`,
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
},
|
|
44
26
|
env: {
|
|
45
27
|
AGENTS_INDEX_URL: process.env.AGENTS_INDEX_URL,
|
|
46
28
|
PLUGINS_INDEX_URL: process.env.PLUGINS_INDEX_URL,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.82.
|
|
3
|
+
"version": "0.82.7",
|
|
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",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"mixpanel-browser": "^2",
|
|
92
92
|
"nanoid": "^5",
|
|
93
93
|
"next": "^13.5.3",
|
|
94
|
-
"openai": "
|
|
94
|
+
"openai": "~4.10.0",
|
|
95
95
|
"polished": "^4",
|
|
96
96
|
"posthog-js": "^1",
|
|
97
97
|
"react": "^18",
|
|
@@ -5,15 +5,15 @@ import { getOpenAIAuthFromRequest } from '@/const/fetch';
|
|
|
5
5
|
import { ErrorType } from '@/types/fetch';
|
|
6
6
|
import { OpenAIStreamPayload } from '@/types/openai';
|
|
7
7
|
|
|
8
|
-
import { checkAuth } from '
|
|
8
|
+
import { checkAuth } from '../../auth';
|
|
9
|
+
import { createAzureOpenai } from '../createAzureOpenai';
|
|
9
10
|
import { createChatCompletion } from '../createChatCompletion';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { createOpenai } from './createOpenai';
|
|
11
|
+
import { createOpenai } from '../createOpenai';
|
|
12
|
+
import { createErrorResponse } from '../errorResponse';
|
|
13
13
|
|
|
14
14
|
export const runtime = 'edge';
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export const POST = async (req: Request) => {
|
|
17
17
|
const payload = (await req.json()) as OpenAIStreamPayload;
|
|
18
18
|
|
|
19
19
|
const { apiKey, accessCode, endpoint, useAzure, apiVersion } = getOpenAIAuthFromRequest(req);
|
|
@@ -36,4 +36,4 @@ export default async function handler(req: Request) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return createChatCompletion({ openai, payload });
|
|
39
|
-
}
|
|
39
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
|
2
2
|
import OpenAI from 'openai';
|
|
3
3
|
|
|
4
|
-
import { createErrorResponse } from '@/
|
|
4
|
+
import { createErrorResponse } from '@/app/api/openai/errorResponse';
|
|
5
5
|
import { ChatErrorType } from '@/types/fetch';
|
|
6
6
|
import { OpenAIStreamPayload } from '@/types/openai';
|
|
7
7
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getOpenAIAuthFromRequest } from '@/const/fetch';
|
|
2
2
|
|
|
3
|
-
import { createOpenai } from '
|
|
3
|
+
import { createOpenai } from '../createOpenai';
|
|
4
4
|
|
|
5
5
|
export const runtime = 'edge';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export const POST = async (req: Request) => {
|
|
8
8
|
const { apiKey, endpoint } = getOpenAIAuthFromRequest(req);
|
|
9
9
|
|
|
10
10
|
const openAI = createOpenai(apiKey, endpoint);
|
|
@@ -14,4 +14,4 @@ export default async function handler(req: Request) {
|
|
|
14
14
|
const modelList = res.data.map((i) => i.id);
|
|
15
15
|
|
|
16
16
|
return new Response(JSON.stringify(modelList));
|
|
17
|
-
}
|
|
17
|
+
};
|
|
@@ -21,7 +21,7 @@ const Inner = memo(() => {
|
|
|
21
21
|
const [withSystemRole, setWithSystemRole] = useState(false);
|
|
22
22
|
const [withPluginInfo, setWithPluginInfo] = useState(false);
|
|
23
23
|
const [withBackground, setWithBackground] = useState(true);
|
|
24
|
-
const [withFooter, setWithFooter] = useState(
|
|
24
|
+
const [withFooter, setWithFooter] = useState(false);
|
|
25
25
|
const [imageType, setImageType] = useState<ImageType>(ImageType.JPG);
|
|
26
26
|
const [tab, setTab] = useState<Tab>(Tab.Screenshot);
|
|
27
27
|
const { t } = useTranslation('common');
|
package/src/services/_url.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
const isDev = process.env.NODE_ENV === 'development';
|
|
2
|
-
|
|
3
|
-
const prefix = isDev ? '-dev' : '';
|
|
4
|
-
|
|
5
1
|
export const URLS = {
|
|
6
|
-
plugins: '/api/plugins'
|
|
2
|
+
plugins: '/api/plugins',
|
|
7
3
|
};
|
|
8
4
|
|
|
9
5
|
export const OPENAI_URLS = {
|
|
10
|
-
chat: '/api/openai/chat'
|
|
11
|
-
models: '/api/openai/models'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const AZURE_OPENAI_URLS = {
|
|
15
|
-
chat: '/api/azure-openai/chat' + prefix,
|
|
16
|
-
models: '/api/azure-openai/models' + prefix,
|
|
6
|
+
chat: '/api/openai/chat',
|
|
7
|
+
models: '/api/openai/models',
|
|
17
8
|
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createLobeChatPluginGateway } from '@lobehub/chat-plugins-gateway';
|
|
2
|
-
|
|
3
|
-
import { PLUGINS_INDEX_URL } from '@/const/url';
|
|
4
|
-
|
|
5
|
-
export const config = {
|
|
6
|
-
runtime: 'edge',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default createLobeChatPluginGateway({ pluginsIndexUrl: PLUGINS_INDEX_URL });
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|