@lobehub/chat 0.126.3 โ 0.126.5
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 +67 -0
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/package.json +2 -1
- package/src/app/layout.tsx +4 -0
- package/src/app/settings/common/Common.tsx +4 -4
- package/src/app/settings/llm/page.tsx +2 -5
- package/src/const/url.ts +3 -0
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +11 -6
- package/src/features/Conversation/Error/OAuthForm.tsx +4 -4
- package/src/hooks/useOAuthSession.ts +24 -0
- package/src/layout/GlobalLayout/index.tsx +21 -11
- package/src/libs/agent-runtime/moonshot/index.ts +1 -3
- package/src/middleware.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,73 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.126.5](https://github.com/lobehub/lobe-chat/compare/v0.126.4...v0.126.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-02-12**</sup>
|
|
8
|
+
|
|
9
|
+
#### โป Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor with the auth code.
|
|
12
|
+
|
|
13
|
+
#### ๐ Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **misc**: Fix middleware auth console error.
|
|
16
|
+
|
|
17
|
+
<br/>
|
|
18
|
+
|
|
19
|
+
<details>
|
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
21
|
+
|
|
22
|
+
#### Code refactoring
|
|
23
|
+
|
|
24
|
+
- **misc**: Refactor with the auth code ([8cee01f](https://github.com/lobehub/lobe-chat/commit/8cee01f))
|
|
25
|
+
|
|
26
|
+
#### What's fixed
|
|
27
|
+
|
|
28
|
+
- **misc**: Fix middleware auth console error ([ad3ade8](https://github.com/lobehub/lobe-chat/commit/ad3ade8))
|
|
29
|
+
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
<div align="right">
|
|
33
|
+
|
|
34
|
+
[](#readme-top)
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
### [Version 0.126.4](https://github.com/lobehub/lobe-chat/compare/v0.126.3...v0.126.4)
|
|
39
|
+
|
|
40
|
+
<sup>Released on **2024-02-11**</sup>
|
|
41
|
+
|
|
42
|
+
#### โป Code Refactoring
|
|
43
|
+
|
|
44
|
+
- **misc**: Update Model provider request url.
|
|
45
|
+
|
|
46
|
+
#### ๐ Bug Fixes
|
|
47
|
+
|
|
48
|
+
- **misc**: Fix auth error in console, fix token tag usage display.
|
|
49
|
+
|
|
50
|
+
<br/>
|
|
51
|
+
|
|
52
|
+
<details>
|
|
53
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
54
|
+
|
|
55
|
+
#### Code refactoring
|
|
56
|
+
|
|
57
|
+
- **misc**: Update Model provider request url ([b64acc0](https://github.com/lobehub/lobe-chat/commit/b64acc0))
|
|
58
|
+
|
|
59
|
+
#### What's fixed
|
|
60
|
+
|
|
61
|
+
- **misc**: Fix auth error in console ([8e7ee82](https://github.com/lobehub/lobe-chat/commit/8e7ee82))
|
|
62
|
+
- **misc**: Fix token tag usage display ([6e7134b](https://github.com/lobehub/lobe-chat/commit/6e7134b))
|
|
63
|
+
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
<div align="right">
|
|
67
|
+
|
|
68
|
+
[](#readme-top)
|
|
69
|
+
|
|
70
|
+
</div>
|
|
71
|
+
|
|
5
72
|
### [Version 0.126.3](https://github.com/lobehub/lobe-chat/compare/v0.126.2...v0.126.3)
|
|
6
73
|
|
|
7
74
|
<sup>Released on **2024-02-09**</sup>
|
package/README.md
CHANGED
|
@@ -225,14 +225,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
|
|
|
225
225
|
|
|
226
226
|
<!-- AGENT LIST -->
|
|
227
227
|
|
|
228
|
-
| Recent Submits
|
|
229
|
-
|
|
|
230
|
-
| [
|
|
231
|
-
| [
|
|
232
|
-
| [
|
|
233
|
-
| [
|
|
234
|
-
|
|
235
|
-
> ๐ Total agents: [<kbd>**
|
|
228
|
+
| Recent Submits | Description |
|
|
229
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| [Product Review](https://chat-preview.lobehub.com/market?agent=product-reviews)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-11**</sup> | Expert in creating persuasive product testimonials highlighting the benefits and value proposition of \[your product/service].<br/>`ecommerce` |
|
|
231
|
+
| [Tarot Reader](https://chat-preview.lobehub.com/market?agent=augur)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-02-10**</sup> | Specializes in tarot reading and interpreting tarot cards<br/>`tarot-reading` `interpretation` `advice` |
|
|
232
|
+
| [Happy Loong Year](https://chat-preview.lobehub.com/market?agent=happy-loong-year)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2024-02-10**</sup> | Loong Year's Assistant combines traditional and modern elements to create interesting New Year blessings.<br/>`new-years-greetings` `creativity` `copywriting` `dragon-year` |
|
|
233
|
+
| [Vocabulary Wizard](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating vocabulary lists and MCQ tests<br/>`vocabulary` `academic-word-list` `language-learning` `testing` |
|
|
234
|
+
|
|
235
|
+
> ๐ Total agents: [<kbd>**173**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
236
236
|
|
|
237
237
|
<!-- AGENT LIST -->
|
|
238
238
|
|
package/README.zh-CN.md
CHANGED
|
@@ -205,14 +205,14 @@ LobeChat ็ๆไปถ็ๆ็ณป็ปๆฏๅ
ถๆ ธๅฟๅ่ฝ็้่ฆๆฉๅฑ๏ผๅฎๆๅคงๅฐ
|
|
|
205
205
|
|
|
206
206
|
<!-- AGENT LIST -->
|
|
207
207
|
|
|
208
|
-
| ๆ่ฟๆฐๅข
|
|
209
|
-
|
|
|
210
|
-
| [
|
|
211
|
-
| [
|
|
212
|
-
| [
|
|
213
|
-
| [
|
|
214
|
-
|
|
215
|
-
> ๐ Total agents: [<kbd>**
|
|
208
|
+
| ๆ่ฟๆฐๅข | ๅฉๆ่ฏดๆ |
|
|
209
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
210
|
+
| [ไบงๅ่ฏไปท](https://chat-preview.lobehub.com/market?agent=product-reviews)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-11**</sup> | ๆ
้ฟๆฐๅๆ่ฏดๆๅ็ไบงๅๆจ่๏ผ็ชๅบ \[ๆจ็ไบงๅ / ๆๅก] ็ไผๅฟๅไปทๅผไธปๅผ ใ<br/>`็ตๅญๅๅก` |
|
|
211
|
+
| [ๅก็ฝๅ ๅๅธ](https://chat-preview.lobehub.com/market?agent=augur)<br/><sup>By **[CLOT-LIU](https://github.com/CLOT-LIU)** on **2024-02-10**</sup> | ๆ
้ฟๅก็ฝๅ ๅ๏ผไผๅฏนๅก็ฝ็่ฟ่ก่งฃ่ฏป<br/>`ๅก็ฝๅ ๅ` `่งฃ่ฏป` `ๅปบ่ฎฎ` |
|
|
212
|
+
| [ๆฐๅนดๅฟซไน](https://chat-preview.lobehub.com/market?agent=happy-loong-year)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2024-02-10**</sup> | ้พๅนดๆๅนดๅฐๅฉๆ๏ผ็ปๅไผ ็ปไธ็ฐไปฃๅ
็ด ๏ผๅ้ ๆ่ถฃ็้พๅนด็ฅ็ฆ่ฏญใ<br/>`ๆๅนด็ฅ็ฆ` `ๅๆ` `ๆๆก` `้พๅนด` |
|
|
213
|
+
| [่ฏๆฑๅคงๅธ](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | ๆ
้ฟ็ๆ่ฏๆฑๅ่กจๅๅค้กน้ๆฉๆต่ฏ<br/>`่ฏๆฑ` `ๅญฆๆฏ่ฏๆฑ่กจ` `่ฏญ่จๅญฆไน ` `ๆต่ฏ` |
|
|
214
|
+
|
|
215
|
+
> ๐ Total agents: [<kbd>**173**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
216
216
|
|
|
217
217
|
<!-- AGENT LIST -->
|
|
218
218
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.126.
|
|
3
|
+
"version": "0.126.5",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@ant-design/icons": "^5",
|
|
76
|
+
"@auth/core": "^0.26.3",
|
|
76
77
|
"@aws-sdk/client-bedrock-runtime": "^3.503.1",
|
|
77
78
|
"@azure/openai": "^1.0.0-beta.11",
|
|
78
79
|
"@cfworker/json-schema": "^1",
|
package/src/app/layout.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { PropsWithChildren } from 'react';
|
|
|
4
4
|
import { isRtlLang } from 'rtl-detect';
|
|
5
5
|
|
|
6
6
|
import Analytics from '@/components/Analytics';
|
|
7
|
+
import { getServerConfig } from '@/config/server';
|
|
7
8
|
import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
|
|
8
9
|
import {
|
|
9
10
|
LOBE_THEME_APPEARANCE,
|
|
@@ -14,6 +15,8 @@ import Layout from '@/layout/GlobalLayout';
|
|
|
14
15
|
|
|
15
16
|
import StyleRegistry from './StyleRegistry';
|
|
16
17
|
|
|
18
|
+
const { ENABLE_OAUTH_SSO } = getServerConfig();
|
|
19
|
+
|
|
17
20
|
const RootLayout = ({ children }: PropsWithChildren) => {
|
|
18
21
|
// get default theme config to use with ssr
|
|
19
22
|
const cookieStore = cookies();
|
|
@@ -32,6 +35,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
|
|
|
32
35
|
defaultLang={lang?.value}
|
|
33
36
|
defaultNeutralColor={neutralColor?.value as any}
|
|
34
37
|
defaultPrimaryColor={primaryColor?.value as any}
|
|
38
|
+
enableOAuthSSO={ENABLE_OAUTH_SSO}
|
|
35
39
|
>
|
|
36
40
|
{children}
|
|
37
41
|
</Layout>
|
|
@@ -2,7 +2,7 @@ import { Form, type ItemGroup, SelectWithImg, SliderWithInput } from '@lobehub/u
|
|
|
2
2
|
import { Form as AntForm, App, Button, Input, Select } from 'antd';
|
|
3
3
|
import isEqual from 'fast-deep-equal';
|
|
4
4
|
import { AppWindow, Monitor, Moon, Palette, Sun } from 'lucide-react';
|
|
5
|
-
import { signIn, signOut
|
|
5
|
+
import { signIn, signOut } from 'next-auth/react';
|
|
6
6
|
import { memo, useCallback, useEffect } from 'react';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
|
|
@@ -10,6 +10,7 @@ import { FORM_STYLE } from '@/const/layoutTokens';
|
|
|
10
10
|
import { DEFAULT_SETTINGS } from '@/const/settings';
|
|
11
11
|
import { imageUrl } from '@/const/url';
|
|
12
12
|
import AvatarWithUpload from '@/features/AvatarWithUpload';
|
|
13
|
+
import { useOAuthSession } from '@/hooks/useOAuthSession';
|
|
13
14
|
import { localeOptions } from '@/locales/resources';
|
|
14
15
|
import { useChatStore } from '@/store/chat';
|
|
15
16
|
import { useFileStore } from '@/store/file';
|
|
@@ -32,8 +33,7 @@ const Common = memo<SettingsCommonProps>(({ showAccessCodeConfig, showOAuthLogin
|
|
|
32
33
|
const { t } = useTranslation('setting');
|
|
33
34
|
const [form] = AntForm.useForm();
|
|
34
35
|
|
|
35
|
-
const {
|
|
36
|
-
const isOAuthLoggedIn = status === 'authenticated' && session && session.user;
|
|
36
|
+
const { user, isOAuthLoggedIn } = useOAuthSession();
|
|
37
37
|
|
|
38
38
|
const [clearSessions, clearSessionGroups] = useSessionStore((s) => [
|
|
39
39
|
s.clearSessions,
|
|
@@ -227,7 +227,7 @@ const Common = memo<SettingsCommonProps>(({ showAccessCodeConfig, showOAuthLogin
|
|
|
227
227
|
</Button>
|
|
228
228
|
),
|
|
229
229
|
desc: isOAuthLoggedIn
|
|
230
|
-
? `${
|
|
230
|
+
? `${user?.email} ${t('settingSystem.oauth.info.desc')}`
|
|
231
231
|
: t('settingSystem.oauth.signin.desc'),
|
|
232
232
|
hidden: !showOAuthLogin,
|
|
233
233
|
label: isOAuthLoggedIn
|
|
@@ -6,6 +6,7 @@ import { Trans, useTranslation } from 'react-i18next';
|
|
|
6
6
|
|
|
7
7
|
import Footer from '@/app/settings/features/Footer';
|
|
8
8
|
import PageTitle from '@/components/PageTitle';
|
|
9
|
+
import { MORE_MODEL_PROVIDER_REQUEST_URL } from '@/const/url';
|
|
9
10
|
import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
|
|
10
11
|
import { SettingsTabs } from '@/store/global/initialState';
|
|
11
12
|
|
|
@@ -30,11 +31,7 @@ export default memo(() => {
|
|
|
30
31
|
<Footer>
|
|
31
32
|
<Trans i18nKey="llm.waitingForMore" ns={'setting'}>
|
|
32
33
|
ๆดๅคๆจกๅๆญฃๅจ
|
|
33
|
-
<Link
|
|
34
|
-
aria-label={'todo'}
|
|
35
|
-
href="https://github.com/lobehub/lobe-chat/issues/151"
|
|
36
|
-
target="_blank"
|
|
37
|
-
>
|
|
34
|
+
<Link aria-label={'todo'} href={MORE_MODEL_PROVIDER_REQUEST_URL} target="_blank">
|
|
38
35
|
่ฎกๅๆฅๅ
ฅ
|
|
39
36
|
</Link>
|
|
40
37
|
ไธญ ๏ผๆฌ่ฏทๆๅพ
โจ
|
package/src/const/url.ts
CHANGED
|
@@ -15,6 +15,9 @@ export const DISCORD = 'https://discord.gg/AYFPHvv2jT';
|
|
|
15
15
|
|
|
16
16
|
export const PLUGINS_INDEX_URL = 'https://chat-plugins.lobehub.com';
|
|
17
17
|
|
|
18
|
+
export const MORE_MODEL_PROVIDER_REQUEST_URL =
|
|
19
|
+
'https://github.com/lobehub/lobe-chat/discussions/1284';
|
|
20
|
+
|
|
18
21
|
export const AGENTS_INDEX_GITHUB = 'https://github.com/lobehub/lobe-chat-agents';
|
|
19
22
|
export const AGENTS_INDEX_GITHUB_ISSUE = urlJoin(AGENTS_INDEX_GITHUB, 'issues/new');
|
|
20
23
|
|
|
@@ -30,10 +30,11 @@ const Token = memo(() => {
|
|
|
30
30
|
agentSelectors.currentAgentModel(s) as LanguageModel,
|
|
31
31
|
]);
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const maxTokens = useGlobalStore(modelProviderSelectors.modelMaxToken(model));
|
|
34
34
|
|
|
35
|
+
// Tool usage token
|
|
36
|
+
const canUseTool = useGlobalStore(modelProviderSelectors.modelEnabledFunctionCall(model));
|
|
35
37
|
const plugins = useSessionStore(agentSelectors.currentAgentPlugins);
|
|
36
|
-
|
|
37
38
|
const toolsString = useToolStore((s) => {
|
|
38
39
|
const pluginSystemRoles = toolSelectors.enabledSystemRoles(plugins)(s);
|
|
39
40
|
const schemaNumber = toolSelectors
|
|
@@ -43,13 +44,17 @@ const Token = memo(() => {
|
|
|
43
44
|
|
|
44
45
|
return pluginSystemRoles + schemaNumber;
|
|
45
46
|
});
|
|
47
|
+
const toolsToken = useTokenCount(canUseTool ? toolsString : '');
|
|
46
48
|
|
|
49
|
+
// Chat usage token
|
|
47
50
|
const inputTokenCount = useTokenCount(input);
|
|
51
|
+
|
|
48
52
|
const chatsToken = useTokenCount(messageString) + inputTokenCount;
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
// SystemRole token
|
|
51
55
|
const systemRoleToken = useTokenCount(systemRole);
|
|
52
56
|
|
|
57
|
+
// Total token
|
|
53
58
|
const totalToken = systemRoleToken + toolsToken + chatsToken;
|
|
54
59
|
return (
|
|
55
60
|
<Tooltip
|
|
@@ -74,18 +79,18 @@ const Token = memo(() => {
|
|
|
74
79
|
</Flexbox>
|
|
75
80
|
<Flexbox horizontal justify={'space-between'} style={{ marginTop: 8 }}>
|
|
76
81
|
<span>{t('tokenDetails.total')}</span>
|
|
77
|
-
<span>{format(
|
|
82
|
+
<span>{format(maxTokens)}</span>
|
|
78
83
|
</Flexbox>
|
|
79
84
|
<Flexbox horizontal justify={'space-between'}>
|
|
80
85
|
<span>{t('tokenDetails.rest')}</span>
|
|
81
|
-
<span>{format(
|
|
86
|
+
<span>{format(maxTokens - totalToken)}</span>
|
|
82
87
|
</Flexbox>
|
|
83
88
|
</Flexbox>
|
|
84
89
|
}
|
|
85
90
|
>
|
|
86
91
|
<TokenTag
|
|
87
92
|
displayMode={'used'}
|
|
88
|
-
maxValue={
|
|
93
|
+
maxValue={maxTokens}
|
|
89
94
|
style={{ marginLeft: 8 }}
|
|
90
95
|
text={{
|
|
91
96
|
overload: t('tokenTag.overload'),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Icon } from '@lobehub/ui';
|
|
2
2
|
import { App, Button } from 'antd';
|
|
3
3
|
import { ScanFace } from 'lucide-react';
|
|
4
|
-
import { signIn, signOut
|
|
4
|
+
import { signIn, signOut } from 'next-auth/react';
|
|
5
5
|
import { memo, useCallback } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
|
+
import { useOAuthSession } from '@/hooks/useOAuthSession';
|
|
9
10
|
import { useChatStore } from '@/store/chat';
|
|
10
11
|
|
|
11
12
|
import { FormAction } from './style';
|
|
@@ -13,8 +14,7 @@ import { FormAction } from './style';
|
|
|
13
14
|
const OAuthForm = memo<{ id: string }>(({ id }) => {
|
|
14
15
|
const { t } = useTranslation('error');
|
|
15
16
|
|
|
16
|
-
const {
|
|
17
|
-
const isOAuthLoggedIn = status === 'authenticated' && session && session.user;
|
|
17
|
+
const { user, isOAuthLoggedIn } = useOAuthSession();
|
|
18
18
|
|
|
19
19
|
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
20
20
|
|
|
@@ -38,7 +38,7 @@ const OAuthForm = memo<{ id: string }>(({ id }) => {
|
|
|
38
38
|
avatar={isOAuthLoggedIn ? 'โ
' : '๐ต๏ธโโ๏ธ'}
|
|
39
39
|
description={
|
|
40
40
|
isOAuthLoggedIn
|
|
41
|
-
? `${t('unlock.oauth.welcome')} ${
|
|
41
|
+
? `${t('unlock.oauth.welcome')} ${user?.name}`
|
|
42
42
|
: t('unlock.oauth.description')
|
|
43
43
|
}
|
|
44
44
|
title={isOAuthLoggedIn ? t('unlock.oauth.success') : t('unlock.oauth.title')}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { User } from '@auth/core/types';
|
|
2
|
+
import { SessionContextValue, useSession } from 'next-auth/react';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
interface OAuthSession {
|
|
6
|
+
isOAuthLoggedIn: boolean;
|
|
7
|
+
user?: User | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const useOAuthSession = () => {
|
|
11
|
+
let authSession: SessionContextValue | null;
|
|
12
|
+
try {
|
|
13
|
+
// refs: https://github.com/lobehub/lobe-chat/pull/1286
|
|
14
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
15
|
+
authSession = useSession();
|
|
16
|
+
} catch {
|
|
17
|
+
authSession = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { data: session, status } = authSession || {};
|
|
21
|
+
const isOAuthLoggedIn = (status === 'authenticated' && session && !!session.user) || false;
|
|
22
|
+
|
|
23
|
+
return useMemo<OAuthSession>(() => ({ isOAuthLoggedIn, user: session?.user }), [session, status]);
|
|
24
|
+
};
|
|
@@ -46,19 +46,29 @@ const Container = memo<PropsWithChildren>(({ children }) => {
|
|
|
46
46
|
|
|
47
47
|
interface GlobalLayoutProps extends AppThemeProps {
|
|
48
48
|
defaultLang?: string;
|
|
49
|
+
enableOAuthSSO?: boolean;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const GlobalLayout = ({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
const GlobalLayout = ({
|
|
53
|
+
children,
|
|
54
|
+
defaultLang,
|
|
55
|
+
enableOAuthSSO = false,
|
|
56
|
+
...theme
|
|
57
|
+
}: GlobalLayoutProps) => {
|
|
58
|
+
const content = (
|
|
59
|
+
<AppTheme {...theme}>
|
|
60
|
+
<Locale defaultLang={defaultLang}>
|
|
61
|
+
<StoreHydration />
|
|
62
|
+
<Container>{children}</Container>
|
|
63
|
+
<DebugUI />
|
|
64
|
+
</Locale>
|
|
65
|
+
</AppTheme>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return enableOAuthSSO ? (
|
|
69
|
+
<SessionProvider basePath={API_ENDPOINTS.oauth}>{content}</SessionProvider>
|
|
70
|
+
) : (
|
|
71
|
+
content
|
|
62
72
|
);
|
|
63
73
|
};
|
|
64
74
|
|
|
@@ -20,9 +20,7 @@ export class LobeMoonshotAI implements LobeRuntimeAI {
|
|
|
20
20
|
constructor(apiKey?: string, baseURL: string = DEFAULT_BASE_URL) {
|
|
21
21
|
if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidMoonshotAPIKey);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this._llm = new OpenAI({ apiKey, baseURL, defaultHeaders: header });
|
|
23
|
+
this._llm = new OpenAI({ apiKey, baseURL });
|
|
26
24
|
this.baseURL = this._llm.baseURL;
|
|
27
25
|
}
|
|
28
26
|
|
package/src/middleware.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
// export { auth as middleware } from './app/api/next-auth';
|
|
2
1
|
import { NextResponse } from 'next/server';
|
|
3
2
|
|
|
3
|
+
import { getServerConfig } from '@/config/server';
|
|
4
|
+
|
|
4
5
|
import { auth } from './app/api/auth/next-auth';
|
|
5
6
|
import { OAUTH_AUTHORIZED } from './const/auth';
|
|
6
7
|
|
|
7
8
|
export const config = {
|
|
8
9
|
matcher: '/api/:path*',
|
|
9
10
|
};
|
|
11
|
+
const defaultMiddleware = () => NextResponse.next();
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
const withAuthMiddleware = auth((req) => {
|
|
12
14
|
// Just check if session exists
|
|
13
15
|
const session = req.auth;
|
|
14
16
|
const isLoggedIn = !!session;
|
|
@@ -23,3 +25,7 @@ export default auth((req) => {
|
|
|
23
25
|
},
|
|
24
26
|
});
|
|
25
27
|
});
|
|
28
|
+
|
|
29
|
+
const { ENABLE_OAUTH_SSO } = getServerConfig();
|
|
30
|
+
|
|
31
|
+
export default !ENABLE_OAUTH_SSO ? defaultMiddleware : withAuthMiddleware;
|