@lobehub/chat 1.40.4 → 1.42.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/changelog/v1.json +18 -0
  3. package/docs/self-hosting/advanced/auth/next-auth/wechat.mdx +46 -0
  4. package/docs/self-hosting/advanced/auth/next-auth/wechat.zh-CN.mdx +43 -0
  5. package/package.json +3 -3
  6. package/src/app/(backend)/webapi/assistant/store/route.ts +2 -11
  7. package/src/app/(main)/discover/(detail)/provider/[slug]/features/ProviderConfig.tsx +7 -4
  8. package/src/config/app.ts +4 -0
  9. package/src/config/modelProviders/spark.ts +3 -6
  10. package/src/features/MobileTabBar/index.tsx +3 -2
  11. package/src/features/User/UserAvatar.tsx +2 -2
  12. package/src/features/User/UserPanel/useMenu.tsx +5 -20
  13. package/src/hooks/useInterceptingRoutes.test.ts +2 -16
  14. package/src/hooks/useInterceptingRoutes.ts +2 -18
  15. package/src/libs/agent-runtime/qwen/index.test.ts +13 -188
  16. package/src/libs/agent-runtime/qwen/index.ts +47 -126
  17. package/src/libs/agent-runtime/spark/index.test.ts +24 -28
  18. package/src/libs/agent-runtime/spark/index.ts +4 -0
  19. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.test.ts +131 -0
  20. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +14 -3
  21. package/src/libs/agent-runtime/utils/streams/index.ts +1 -0
  22. package/src/libs/agent-runtime/utils/streams/spark.test.ts +199 -0
  23. package/src/libs/agent-runtime/utils/streams/spark.ts +134 -0
  24. package/src/libs/next-auth/sso-providers/index.ts +2 -0
  25. package/src/libs/next-auth/sso-providers/wechat.ts +24 -0
  26. package/src/server/modules/AssistantStore/index.test.ts +5 -5
  27. package/src/server/modules/AssistantStore/index.ts +39 -1
  28. package/src/server/modules/EdgeConfig/index.ts +23 -0
  29. package/src/server/services/discover/index.ts +2 -13
  30. package/src/types/discover.ts +20 -0
  31. package/src/app/@modal/(.)settings/modal/index.tsx +0 -45
  32. package/src/app/@modal/(.)settings/modal/layout.tsx +0 -47
  33. package/src/app/@modal/(.)settings/modal/loading.tsx +0 -5
  34. package/src/app/@modal/(.)settings/modal/page.tsx +0 -19
@@ -0,0 +1,23 @@
1
+ import { EdgeConfigClient, createClient } from '@vercel/edge-config';
2
+
3
+ import { appEnv } from '@/config/app';
4
+
5
+ enum EdgeConfigKeys {
6
+ /**
7
+ * Assistant whitelist
8
+ */
9
+ AssistantWhitelist = 'assistant_whitelist',
10
+ }
11
+
12
+ export class EdgeConfig {
13
+ get client(): EdgeConfigClient {
14
+ if (!appEnv.VERCEL_EDGE_CONFIG) {
15
+ throw new Error('VERCEL_EDGE_CONFIG is not set');
16
+ }
17
+ return createClient(appEnv.VERCEL_EDGE_CONFIG);
18
+ }
19
+
20
+ getAgentWhitelist = async (): Promise<string[] | undefined> => {
21
+ return this.client.get<string[]>(EdgeConfigKeys.AssistantWhitelist);
22
+ };
23
+ }
@@ -50,20 +50,9 @@ export class DiscoverService {
50
50
  };
51
51
 
52
52
  getAssistantList = async (locale: Locales): Promise<DiscoverAssistantItem[]> => {
53
- let res = await fetch(this.assistantStore.getAgentIndexUrl(locale), {
54
- next: { revalidate },
55
- });
56
-
57
- if (!res.ok) {
58
- res = await fetch(this.assistantStore.getAgentIndexUrl(DEFAULT_LANG), {
59
- next: { revalidate },
60
- });
61
- }
62
-
63
- if (!res.ok) return [];
64
-
65
- const json = await res.json();
53
+ const json = await this.assistantStore.getAgentIndex(locale, revalidate);
66
54
 
55
+ // @ts-expect-error 目前类型不一致,未来要统一
67
56
  return json.agents;
68
57
  };
69
58
 
@@ -154,3 +154,23 @@ export interface FilterBy {
154
154
  token?: number;
155
155
  vision?: boolean;
156
156
  }
157
+
158
+ interface AgentIndexItem {
159
+ author: string;
160
+ createAt: string;
161
+ createdAt: string;
162
+ homepage: string;
163
+ identifier: string;
164
+ meta: {
165
+ avatar: string;
166
+ category: string;
167
+ description: string;
168
+ tags: string[];
169
+ title: string;
170
+ };
171
+ }
172
+
173
+ export interface AgentStoreIndex {
174
+ agents: AgentIndexItem[];
175
+ schemaVersion: number;
176
+ }
@@ -1,45 +0,0 @@
1
- 'use client';
2
-
3
- import dynamic from 'next/dynamic';
4
- import { memo } from 'react';
5
-
6
- import { useQuery } from '@/hooks/useQuery';
7
- import { SettingsTabs } from '@/store/global/initialState';
8
-
9
- import Skeleton from './loading';
10
-
11
- const loading = () => <Skeleton />;
12
-
13
- const Common = dynamic(() => import('@/app/(main)/settings/common'), { loading, ssr: false });
14
- const SystemAgent = dynamic(() => import('@/app/(main)/settings/system-agent'), {
15
- loading,
16
- ssr: false,
17
- });
18
- const About = dynamic(() => import('@/app/(main)/settings/about'), { loading, ssr: false });
19
- const LLM = dynamic(() => import('@/app/(main)/settings/llm'), { loading, ssr: false });
20
- const TTS = dynamic(() => import('@/app/(main)/settings/tts'), { loading, ssr: false });
21
- const Agent = dynamic(() => import('@/app/(main)/settings/agent'), { loading, ssr: false });
22
- const Sync = dynamic(() => import('@/app/(main)/settings/sync'), { loading, ssr: false });
23
-
24
- interface SettingsModalProps {
25
- browser?: string;
26
- mobile?: boolean;
27
- os?: string;
28
- }
29
-
30
- const SettingsModal = memo<SettingsModalProps>(({ browser, os, mobile }) => {
31
- const { tab = SettingsTabs.Common } = useQuery();
32
- return (
33
- <>
34
- {tab === SettingsTabs.Common && <Common />}
35
- {tab === SettingsTabs.SystemAgent && <SystemAgent />}
36
- {tab === SettingsTabs.Sync && <Sync browser={browser} mobile={mobile} os={os} />}
37
- {tab === SettingsTabs.LLM && <LLM />}
38
- {tab === SettingsTabs.TTS && <TTS />}
39
- {tab === SettingsTabs.Agent && <Agent />}
40
- {tab === SettingsTabs.About && <About mobile={mobile} />}
41
- </>
42
- );
43
- });
44
-
45
- export default SettingsModal;
@@ -1,47 +0,0 @@
1
- 'use client';
2
-
3
- import { Skeleton, Tag } from 'antd';
4
- import dynamic from 'next/dynamic';
5
- import { PropsWithChildren, memo } from 'react';
6
- import { useTranslation } from 'react-i18next';
7
-
8
- import { useActiveSettingsKey } from '@/hooks/useActiveSettingsKey';
9
- import { SettingsTabs } from '@/store/global/initialState';
10
-
11
- import ModalLayout from '../../_layout/ModalLayout';
12
- import SettingModalLayout from '../../_layout/SettingModalLayout';
13
-
14
- const CategoryContent = dynamic(
15
- () => import('@/app/(main)/settings/@category/features/CategoryContent'),
16
- { loading: () => <Skeleton paragraph={{ rows: 6 }} title={false} />, ssr: false },
17
- );
18
- const UpgradeAlert = dynamic(() => import('@/app/(main)/settings/features/UpgradeAlert'), {
19
- ssr: false,
20
- });
21
-
22
- const Layout = memo<PropsWithChildren>(({ children }) => {
23
- const { t } = useTranslation('setting');
24
- const activeKey = useActiveSettingsKey();
25
- return (
26
- <ModalLayout>
27
- <SettingModalLayout
28
- activeTitle={
29
- <>
30
- {t(`tab.${activeKey}`)}
31
- {activeKey === SettingsTabs.Sync && <Tag color={'gold'}>{t('tab.experiment')}</Tag>}
32
- </>
33
- }
34
- category={
35
- <>
36
- <CategoryContent modal />
37
- <UpgradeAlert />
38
- </>
39
- }
40
- >
41
- {children}
42
- </SettingModalLayout>
43
- </ModalLayout>
44
- );
45
- });
46
-
47
- export default Layout;
@@ -1,5 +0,0 @@
1
- import { Skeleton } from 'antd';
2
-
3
- export default () => {
4
- return <Skeleton paragraph={{ rows: 6 }} style={{ paddingBlock: 16 }} />;
5
- };
@@ -1,19 +0,0 @@
1
- import { gerServerDeviceInfo, isMobileDevice } from '@/utils/server/responsive';
2
-
3
- import SettingsModal from './index';
4
-
5
- /**
6
- * @description: Settings Modal (intercepting route: /settings/modal )
7
- * @refs: https://github.com/lobehub/lobe-chat/discussions/2295#discussioncomment-9290942
8
- */
9
-
10
- const Page = async () => {
11
- const isMobile = await isMobileDevice();
12
- const { os, browser } = await gerServerDeviceInfo();
13
-
14
- return <SettingsModal browser={browser} mobile={isMobile} os={os} />;
15
- };
16
-
17
- Page.displayName = 'SettingModal';
18
-
19
- export default Page;