@lobehub/chat 1.1.4 → 1.1.6

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 (36) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/docs/self-hosting/advanced/model-list.mdx +1 -1
  5. package/package.json +2 -2
  6. package/src/app/(main)/(mobile)/me/(home)/__tests__/UserBanner.test.tsx +1 -1
  7. package/src/app/(main)/(mobile)/me/(home)/features/UserBanner.tsx +1 -1
  8. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +1 -1
  9. package/src/app/api/webhooks/clerk/route.ts +6 -86
  10. package/src/app/trpc/tools/[trpc]/route.ts +28 -0
  11. package/src/config/__tests__/analytics.test.ts +0 -23
  12. package/src/config/analytics.ts +9 -95
  13. package/src/config/auth.ts +3 -23
  14. package/src/config/llm.ts +3 -42
  15. package/src/database/server/migrations/0003_naive_echo.sql +46 -0
  16. package/src/database/server/migrations/meta/0003_snapshot.json +1823 -0
  17. package/src/database/server/migrations/meta/_journal.json +7 -0
  18. package/src/database/server/models/__tests__/user.test.ts +3 -3
  19. package/src/database/server/models/user.ts +4 -4
  20. package/src/database/server/schemas/lobechat.ts +56 -5
  21. package/src/features/User/{UserLoginOrSignup.tsx → UserLoginOrSignup/Community.tsx} +1 -1
  22. package/src/features/User/UserLoginOrSignup/index.tsx +1 -0
  23. package/src/features/User/UserPanel/LangButton.tsx +3 -3
  24. package/src/features/User/UserPanel/ThemeButton.tsx +3 -3
  25. package/src/server/routers/edge/config/index.test.ts +0 -14
  26. package/src/server/routers/lambda/importer.ts +1 -3
  27. package/src/server/routers/lambda/user.ts +21 -14
  28. package/src/server/routers/tools/index.ts +7 -0
  29. package/src/server/services/user/index.ts +96 -0
  30. package/src/services/__tests__/chat.test.ts +9 -2
  31. package/src/services/chat.ts +4 -0
  32. package/src/types/user/settings/keyVaults.ts +1 -0
  33. package/vitest.config.ts +7 -1
  34. /package/src/{database/server → server}/modules/DataImporter/__tests__/fixtures/messages.json +0 -0
  35. /package/src/{database/server → server}/modules/DataImporter/__tests__/index.test.ts +0 -0
  36. /package/src/{database/server → server}/modules/DataImporter/index.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,64 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.1.6](https://github.com/lobehub/lobe-chat/compare/v1.1.5...v1.1.6)
6
+
7
+ <sup>Released on **2024-06-23**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor the server db implement.
12
+
13
+ #### 🐛 Bug Fixes
14
+
15
+ - **misc**: Fix incorrect baseURL for Groq in client mode.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### Code refactoring
23
+
24
+ - **misc**: Refactor the server db implement, closes [#2991](https://github.com/lobehub/lobe-chat/issues/2991) ([fa78599](https://github.com/lobehub/lobe-chat/commit/fa78599))
25
+
26
+ #### What's fixed
27
+
28
+ - **misc**: Fix incorrect baseURL for Groq in client mode, closes [#2747](https://github.com/lobehub/lobe-chat/issues/2747) ([af14225](https://github.com/lobehub/lobe-chat/commit/af14225))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
38
+ ### [Version 1.1.5](https://github.com/lobehub/lobe-chat/compare/v1.1.4...v1.1.5)
39
+
40
+ <sup>Released on **2024-06-23**</sup>
41
+
42
+ #### ♻ Code Refactoring
43
+
44
+ - **misc**: Remove deprecated env.
45
+
46
+ <br/>
47
+
48
+ <details>
49
+ <summary><kbd>Improvements and Fixes</kbd></summary>
50
+
51
+ #### Code refactoring
52
+
53
+ - **misc**: Remove deprecated env, closes [#2983](https://github.com/lobehub/lobe-chat/issues/2983) ([15a681f](https://github.com/lobehub/lobe-chat/commit/15a681f))
54
+
55
+ </details>
56
+
57
+ <div align="right">
58
+
59
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
60
+
61
+ </div>
62
+
5
63
  ### [Version 1.1.4](https://github.com/lobehub/lobe-chat/compare/v1.1.3...v1.1.4)
6
64
 
7
65
  <sup>Released on **2024-06-22**</sup>
package/README.md CHANGED
@@ -233,7 +233,7 @@ In addition, these plugins are not limited to news aggregation, but can also ext
233
233
  | [Search1API](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **fatwang2** on **2024-05-06**</sup> | Search aggregation service, specifically designed for LLMs<br/>`web` `search` |
234
234
  | [Search Google via Serper](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Barry** on **2024-04-30**</sup> | Google search engine via Serper.dev free API (2500x🆓/month)<br/>`web` `search` |
235
235
 
236
- > 📊 Total plugins: [<kbd>**53**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
236
+ > 📊 Total plugins: [<kbd>**52**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
237
237
 
238
238
  <!-- PLUGIN LIST -->
239
239
 
package/README.zh-CN.md CHANGED
@@ -225,7 +225,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
225
225
  | [Search1API](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **fatwang2** on **2024-05-06**</sup> | 搜索聚合服务,专为 LLMs 设计<br/>`web` `search` |
226
226
  | [通过 Serper 搜索 Google](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Barry** on **2024-04-30**</sup> | 通过 Serper.dev 免费 API 进行 Google 搜索引擎(每月 2500 次🆓)<br/>`网络` `搜索` |
227
227
 
228
- > 📊 Total plugins: [<kbd>**53**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
228
+ > 📊 Total plugins: [<kbd>**52**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
229
229
 
230
230
  <!-- PLUGIN LIST -->
231
231
 
@@ -12,7 +12,7 @@ tags:
12
12
 
13
13
  # Model List
14
14
 
15
- LobeChat supports customizing the model list during deployment. You can use `+` to add a model, `-` to hide a model, and use `model name=display name<extension configuration>` to customize the display name of a model, separated by English commas. The basic syntax is as follows:
15
+ LobeChat supports customizing the model list during deployment. This configuration is done in the environment for each [model provider](/docs/self-hosting/environment-variables/model-provider). You can use `+` to add a model, `-` to hide a model, and use `model name=display name<extension configuration>` to customize the display name of a model, separated by English commas. The basic syntax is as follows:
16
16
 
17
17
  ```text
18
18
  id=displayName<maxToken:vision:fc:file>,model2,model3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
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",
@@ -225,7 +225,7 @@
225
225
  "@types/semver": "^7.5.8",
226
226
  "@types/systemjs": "^6.13.5",
227
227
  "@types/ua-parser-js": "^0.7.39",
228
- "@types/uuid": "^9.0.8",
228
+ "@types/uuid": "^10.0.0",
229
229
  "@types/ws": "^8.5.10",
230
230
  "@umijs/lint": "^4.2.13",
231
231
  "@vitest/coverage-v8": "~1.2.2",
@@ -20,7 +20,7 @@ vi.mock('@/features/User/DataStatistics', () => ({
20
20
  default: vi.fn(() => <div>Mocked DataStatistics</div>),
21
21
  }));
22
22
 
23
- vi.mock('@/features/User/UserLoginOrSignup', () => ({
23
+ vi.mock('@/features/User/UserLoginOrSignup/Community', () => ({
24
24
  default: vi.fn(() => <div>Mocked UserLoginOrSignup</div>),
25
25
  }));
26
26
 
@@ -7,7 +7,7 @@ import { Flexbox } from 'react-layout-kit';
7
7
  import { enableAuth } from '@/const/auth';
8
8
  import DataStatistics from '@/features/User/DataStatistics';
9
9
  import UserInfo from '@/features/User/UserInfo';
10
- import UserLoginOrSignup from '@/features/User/UserLoginOrSignup';
10
+ import UserLoginOrSignup from '@/features/User/UserLoginOrSignup/Community';
11
11
  import { useUserStore } from '@/store/user';
12
12
  import { authSelectors } from '@/store/user/selectors';
13
13
 
@@ -61,7 +61,7 @@ const useStyles = createStyles(({ css, prefixCls, responsive, token }) => ({
61
61
  `,
62
62
  }));
63
63
 
64
- export interface ProviderConfigProps extends Omit<ModelProviderCard, 'id'> {
64
+ export interface ProviderConfigProps extends Omit<ModelProviderCard, 'id' | 'chatModels'> {
65
65
  apiKeyItems?: FormItemProps[];
66
66
  canDeactivate?: boolean;
67
67
  checkerItem?: FormItemProps;
@@ -1,10 +1,9 @@
1
- import { UserJSON } from '@clerk/backend';
2
1
  import { NextResponse } from 'next/server';
3
2
 
4
3
  import { authEnv } from '@/config/auth';
5
4
  import { isServerMode } from '@/const/version';
6
- import { UserModel } from '@/database/server/models/user';
7
5
  import { pino } from '@/libs/logger';
6
+ import { UserService } from '@/server/services/user';
8
7
 
9
8
  import { validateRequest } from './validateRequest';
10
9
 
@@ -12,86 +11,6 @@ if (authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH && isServerMode && !authEnv.CLERK_WEBH
12
11
  throw new Error('`CLERK_WEBHOOK_SECRET` environment variable is missing');
13
12
  }
14
13
 
15
- const createUser = async (id: string, params: UserJSON) => {
16
- pino.info('creating user due to clerk webhook');
17
-
18
- const userModel = new UserModel();
19
-
20
- // Check if user already exists
21
- const res = await userModel.findById(id);
22
-
23
- // If user already exists, skip creating a new user
24
- if (res)
25
- return NextResponse.json(
26
- { message: 'user not created due to user already existing in the database', success: false },
27
- { status: 200 },
28
- );
29
-
30
- const email = params.email_addresses.find((e) => e.id === params.primary_email_address_id);
31
- const phone = params.phone_numbers.find((e) => e.id === params.primary_phone_number_id);
32
-
33
- await userModel.createUser({
34
- avatar: params.image_url,
35
- clerkCreatedAt: new Date(params.created_at),
36
- email: email?.email_address,
37
- firstName: params.first_name,
38
- id,
39
- lastName: params.last_name,
40
- phone: phone?.phone_number,
41
- username: params.username,
42
- });
43
-
44
- return NextResponse.json({ message: 'user created', success: true }, { status: 200 });
45
- };
46
-
47
- const deleteUser = async (id?: string) => {
48
- if (id) {
49
- pino.info('delete user due to clerk webhook');
50
- const userModel = new UserModel();
51
-
52
- await userModel.deleteUser(id);
53
-
54
- return NextResponse.json({ message: 'user deleted' }, { status: 200 });
55
- } else {
56
- pino.warn('clerk sent a delete user request, but no user ID was included in the payload');
57
- return NextResponse.json({ message: 'ok' }, { status: 200 });
58
- }
59
- };
60
-
61
- const updateUser = async (id: string, params: UserJSON) => {
62
- pino.info('updating user due to clerk webhook');
63
-
64
- const userModel = new UserModel();
65
-
66
- // Check if user already exists
67
- const res = await userModel.findById(id);
68
-
69
- // If user not exists, skip update the user
70
- if (!res)
71
- return NextResponse.json(
72
- {
73
- message: "user not updated due to the user don't existing in the database",
74
- success: false,
75
- },
76
- { status: 200 },
77
- );
78
-
79
- const email = params.email_addresses.find((e) => e.id === params.primary_email_address_id);
80
- const phone = params.phone_numbers.find((e) => e.id === params.primary_phone_number_id);
81
-
82
- await userModel.updateUser(id, {
83
- avatar: params.image_url,
84
- email: email?.email_address,
85
- firstName: params.first_name,
86
- id,
87
- lastName: params.last_name,
88
- phone: phone?.phone_number,
89
- username: params.username,
90
- });
91
-
92
- return NextResponse.json({ message: 'user updated', success: true }, { status: 200 });
93
- };
94
-
95
14
  export const POST = async (req: Request): Promise<NextResponse> => {
96
15
  const payload = await validateRequest(req, authEnv.CLERK_WEBHOOK_SECRET!);
97
16
 
@@ -106,22 +25,23 @@ export const POST = async (req: Request): Promise<NextResponse> => {
106
25
 
107
26
  pino.trace(`clerk webhook payload: ${{ data, type }}`);
108
27
 
28
+ const userService = new UserService();
109
29
  switch (type) {
110
30
  case 'user.created': {
111
- return createUser(data.id, data);
31
+ return userService.createUser(data.id, data);
112
32
  }
113
33
  case 'user.deleted': {
114
- return deleteUser(data.id);
34
+ return userService.deleteUser(data.id);
115
35
  }
116
36
  case 'user.updated': {
117
- return updateUser(data.id, data);
37
+ return userService.updateUser(data.id, data);
118
38
  }
119
39
 
120
40
  default: {
121
41
  pino.warn(
122
42
  `${req.url} received event type "${type}", but no handler is defined for this type`,
123
43
  );
124
- return NextResponse.json({ error: `uncreognised payload type: ${type}` }, { status: 400 });
44
+ return NextResponse.json({ error: `unrecognised payload type: ${type}` }, { status: 400 });
125
45
  }
126
46
  // case 'user.updated':
127
47
  // break;
@@ -0,0 +1,28 @@
1
+ import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
2
+ import type { NextRequest } from 'next/server';
3
+
4
+ import { pino } from '@/libs/logger';
5
+ import { createContext } from '@/server/context';
6
+ import { toolsRouter } from '@/server/routers/tools';
7
+
8
+ export const maxDuration = 120;
9
+
10
+ const handler = (req: NextRequest) =>
11
+ fetchRequestHandler({
12
+ /**
13
+ * @link https://trpc.io/docs/v11/context
14
+ */
15
+ createContext: () => createContext(req),
16
+
17
+ endpoint: '/trpc/tools',
18
+
19
+ onError: ({ error, path, type }) => {
20
+ pino.info(`Error in tRPC handler (tools) on path: ${path}, type: ${type}`);
21
+ console.error(error);
22
+ },
23
+
24
+ req,
25
+ router: toolsRouter,
26
+ });
27
+
28
+ export { handler as GET, handler as POST };
@@ -44,27 +44,4 @@ describe('getAnalyticsConfig', () => {
44
44
  GOOGLE_ANALYTICS_MEASUREMENT_ID: 'ga_id',
45
45
  });
46
46
  });
47
-
48
- it('should use deprecated env vars and log warnings', () => {
49
- process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN = 'deprecated.com';
50
- process.env.NEXT_PUBLIC_POSTHOG_KEY = 'deprecated_key';
51
- process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID = 'deprecated_id';
52
-
53
- const config = getAnalyticsConfig();
54
-
55
- expect(config.ENABLED_PLAUSIBLE_ANALYTICS).toBeTruthy();
56
- expect(config.ENABLED_POSTHOG_ANALYTICS).toBeTruthy();
57
- expect(config.ENABLED_UMAMI_ANALYTICS).toBeTruthy();
58
-
59
- expect(console.warn).toHaveBeenCalledTimes(3);
60
- expect(console.warn).toHaveBeenCalledWith(
61
- 'NEXT_PUBLIC_PLAUSIBLE_DOMAIN is deprecated. Please use PLAUSIBLE_DOMAIN instead. We will remove it in LobeChat 1.0',
62
- );
63
- expect(console.warn).toHaveBeenCalledWith(
64
- 'NEXT_PUBLIC_POSTHOG_KEY is deprecated. Please use POSTHOG_KEY instead. We will remove it in LobeChat 1.0',
65
- );
66
- expect(console.warn).toHaveBeenCalledWith(
67
- 'NEXT_PUBLIC_UMAMI_WEBSITE_ID is deprecated. Please use UMAMI_WEBSITE_ID instead. We will remove it in LobeChat 1.0',
68
- );
69
- });
70
47
  });
@@ -2,82 +2,7 @@
2
2
  import { createEnv } from '@t3-oss/env-nextjs';
3
3
  import { z } from 'zod';
4
4
 
5
- declare global {
6
- // eslint-disable-next-line @typescript-eslint/no-namespace
7
- namespace NodeJS {
8
- interface ProcessEnv {
9
- /**
10
- * @deprecated
11
- */
12
- NEXT_PUBLIC_ANALYTICS_PLAUSIBLE?: string;
13
- /**
14
- * @deprecated
15
- */
16
- NEXT_PUBLIC_ANALYTICS_POSTHOG: string;
17
- /**
18
- * @deprecated
19
- */
20
- NEXT_PUBLIC_PLAUSIBLE_DOMAIN?: string;
21
-
22
- /**
23
- * @deprecated
24
- */
25
- NEXT_PUBLIC_PLAUSIBLE_SCRIPT_BASE_URL?: string;
26
- /**
27
- * @deprecated
28
- */
29
- NEXT_PUBLIC_POSTHOG_HOST: string;
30
- /**
31
- * @deprecated
32
- */
33
- NEXT_PUBLIC_POSTHOG_KEY: string;
34
-
35
- /**
36
- * @deprecated
37
- */
38
- NEXT_PUBLIC_UMAMI_SCRIPT_URL?: string;
39
- /**
40
- * @deprecated
41
- */
42
- NEXT_PUBLIC_UMAMI_WEBSITE_ID?: string;
43
- }
44
- }
45
- }
46
-
47
5
  export const getAnalyticsConfig = () => {
48
- if (process.env.NEXT_PUBLIC_PLAUSIBLE_SCRIPT_BASE_URL) {
49
- console.warn(
50
- 'NEXT_PUBLIC_PLAUSIBLE_SCRIPT_BASE_URL is deprecated. Please use PLAUSIBLE_SCRIPT_BASE_URL instead. We will remove it in LobeChat 1.0',
51
- );
52
- }
53
- if (process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN) {
54
- console.warn(
55
- 'NEXT_PUBLIC_PLAUSIBLE_DOMAIN is deprecated. Please use PLAUSIBLE_DOMAIN instead. We will remove it in LobeChat 1.0',
56
- );
57
- }
58
-
59
- if (process.env.NEXT_PUBLIC_POSTHOG_KEY) {
60
- console.warn(
61
- 'NEXT_PUBLIC_POSTHOG_KEY is deprecated. Please use POSTHOG_KEY instead. We will remove it in LobeChat 1.0',
62
- );
63
- }
64
- if (process.env.NEXT_PUBLIC_POSTHOG_HOST) {
65
- console.warn(
66
- 'NEXT_PUBLIC_POSTHOG_HOST is deprecated. Please use POSTHOG_HOST instead. We will remove it in LobeChat 1.0',
67
- );
68
- }
69
-
70
- if (process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL) {
71
- console.warn(
72
- 'NEXT_PUBLIC_UMAMI_SCRIPT_URL is deprecated. Please use UMAMI_SCRIPT_URL instead. We will remove it in LobeChat 1.0',
73
- );
74
- }
75
- if (process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID) {
76
- console.warn(
77
- 'NEXT_PUBLIC_UMAMI_WEBSITE_ID is deprecated. Please use UMAMI_WEBSITE_ID instead. We will remove it in LobeChat 1.0',
78
- );
79
- }
80
-
81
6
  return createEnv({
82
7
  server: {
83
8
  ENABLED_PLAUSIBLE_ANALYTICS: z.boolean(),
@@ -104,31 +29,20 @@ export const getAnalyticsConfig = () => {
104
29
  },
105
30
  runtimeEnv: {
106
31
  // Plausible Analytics
107
- ENABLED_PLAUSIBLE_ANALYTICS:
108
- !!process.env.PLAUSIBLE_DOMAIN || !!process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN,
109
- PLAUSIBLE_DOMAIN: process.env.PLAUSIBLE_DOMAIN || process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN,
110
- PLAUSIBLE_SCRIPT_BASE_URL:
111
- process.env.PLAUSIBLE_SCRIPT_BASE_URL ||
112
- process.env.NEXT_PUBLIC_PLAUSIBLE_SCRIPT_BASE_URL ||
113
- 'https://plausible.io',
32
+ ENABLED_PLAUSIBLE_ANALYTICS: !!process.env.PLAUSIBLE_DOMAIN,
33
+ PLAUSIBLE_DOMAIN: process.env.PLAUSIBLE_DOMAIN,
34
+ PLAUSIBLE_SCRIPT_BASE_URL: process.env.PLAUSIBLE_SCRIPT_BASE_URL || 'https://plausible.io',
114
35
 
115
36
  // Posthog Analytics
116
- ENABLED_POSTHOG_ANALYTICS: !!process.env.POSTHOG_KEY || !!process.env.NEXT_PUBLIC_POSTHOG_KEY,
117
- POSTHOG_KEY: process.env.POSTHOG_KEY || process.env.NEXT_PUBLIC_POSTHOG_KEY,
118
- POSTHOG_HOST:
119
- process.env.POSTHOG_HOST ||
120
- process.env.NEXT_PUBLIC_POSTHOG_HOST ||
121
- 'https://app.posthog.com',
37
+ ENABLED_POSTHOG_ANALYTICS: !!process.env.POSTHOG_KEY,
38
+ POSTHOG_KEY: process.env.POSTHOG_KEY,
39
+ POSTHOG_HOST: process.env.POSTHOG_HOST || 'https://app.posthog.com',
122
40
  DEBUG_POSTHOG_ANALYTICS: process.env.DEBUG_POSTHOG_ANALYTICS === '1',
123
41
 
124
42
  // Umami Analytics
125
- ENABLED_UMAMI_ANALYTICS:
126
- !!process.env.UMAMI_WEBSITE_ID || !!process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID,
127
- UMAMI_SCRIPT_URL:
128
- process.env.UMAMI_SCRIPT_URL ||
129
- process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL ||
130
- 'https://analytics.umami.is/script.js',
131
- UMAMI_WEBSITE_ID: process.env.UMAMI_WEBSITE_ID || process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID,
43
+ ENABLED_UMAMI_ANALYTICS: !!process.env.UMAMI_WEBSITE_ID,
44
+ UMAMI_SCRIPT_URL: process.env.UMAMI_SCRIPT_URL || 'https://analytics.umami.is/script.js',
45
+ UMAMI_WEBSITE_ID: process.env.UMAMI_WEBSITE_ID,
132
46
 
133
47
  // Clarity Analytics
134
48
  ENABLED_CLARITY_ANALYTICS: !!process.env.CLARITY_PROJECT_ID,
@@ -12,15 +12,8 @@ declare global {
12
12
  CLERK_WEBHOOK_SECRET?: string;
13
13
 
14
14
  // ===== Next Auth ===== //
15
- /**
16
- * @deprecated
17
- */
18
- ENABLE_OAUTH_SSO?: string;
19
15
  NEXT_AUTH_SECRET?: string;
20
- /**
21
- * @deprecated
22
- */
23
- SSO_PROVIDERS?: string;
16
+
24
17
  NEXT_AUTH_SSO_PROVIDERS?: string;
25
18
 
26
19
  AUTH0_CLIENT_ID?: string;
@@ -50,18 +43,6 @@ declare global {
50
43
  }
51
44
 
52
45
  export const getAuthConfig = () => {
53
- if (process.env.ENABLE_OAUTH_SSO) {
54
- console.warn(
55
- '`ENABLE_OAUTH_SSO` is deprecated and will be removed in LobeChat 1.0. just set `NEXT_AUTH_SECRET` enough',
56
- );
57
- }
58
-
59
- if (process.env.SSO_PROVIDERS) {
60
- console.warn(
61
- '`SSO_PROVIDERS` is deprecated and will be removed in LobeChat 1.0. Please replace with `NEXT_AUTH_SSO_PROVIDERS`',
62
- );
63
- }
64
-
65
46
  return createEnv({
66
47
  client: {
67
48
  NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().optional(),
@@ -114,9 +95,8 @@ export const getAuthConfig = () => {
114
95
  CLERK_WEBHOOK_SECRET: process.env.CLERK_WEBHOOK_SECRET,
115
96
 
116
97
  // Next Auth
117
- NEXT_PUBLIC_ENABLE_NEXT_AUTH:
118
- !!process.env.NEXT_AUTH_SECRET || !!process.env.ENABLE_OAUTH_SSO,
119
- NEXT_AUTH_SSO_PROVIDERS: process.env.NEXT_AUTH_SSO_PROVIDERS || process.env.SSO_PROVIDERS,
98
+ NEXT_PUBLIC_ENABLE_NEXT_AUTH: !!process.env.NEXT_AUTH_SECRET,
99
+ NEXT_AUTH_SSO_PROVIDERS: process.env.NEXT_AUTH_SSO_PROVIDERS,
120
100
  NEXT_AUTH_SECRET: process.env.NEXT_AUTH_SECRET,
121
101
 
122
102
  // Auth0
package/src/config/llm.ts CHANGED
@@ -2,45 +2,7 @@
2
2
  import { createEnv } from '@t3-oss/env-nextjs';
3
3
  import { z } from 'zod';
4
4
 
5
- declare global {
6
- // eslint-disable-next-line @typescript-eslint/no-namespace
7
- namespace NodeJS {
8
- interface ProcessEnv {
9
- /**
10
- * @deprecated
11
- */
12
- CUSTOM_MODELS?: string;
13
- /**
14
- * @deprecated
15
- */
16
- OLLAMA_CUSTOM_MODELS?: string;
17
- /**
18
- * @deprecated
19
- */
20
- OPENROUTER_CUSTOM_MODELS?: string;
21
- }
22
- }
23
- }
24
-
25
5
  export const getLLMConfig = () => {
26
- if (process.env.CUSTOM_MODELS) {
27
- console.warn(
28
- 'DEPRECATED: `CUSTOM_MODELS` is deprecated, please use `OPENAI_MODEL_LIST` instead, we will remove `CUSTOM_MODELS` in the LobeChat 1.0',
29
- );
30
- }
31
-
32
- if (process.env.OLLAMA_CUSTOM_MODELS) {
33
- console.warn(
34
- 'DEPRECATED: `OLLAMA_CUSTOM_MODELS` is deprecated, please use `OLLAMA_MODEL_LIST` instead, we will remove `OLLAMA_CUSTOM_MODELS` in the LobeChat 1.0',
35
- );
36
- }
37
-
38
- if (process.env.OPENROUTER_CUSTOM_MODELS) {
39
- console.warn(
40
- 'DEPRECATED: `OPENROUTER_CUSTOM_MODELS` is deprecated, please use `OPENROUTER_MODEL_LIST` instead, we will remove `OPENROUTER_CUSTOM_MODELS` in the LobeChat 1.0',
41
- );
42
- }
43
-
44
6
  // region format: iad1,sfo1
45
7
  let regions: string[] = [];
46
8
  if (process.env.OPENAI_FUNCTION_REGIONS) {
@@ -127,7 +89,7 @@ export const getLLMConfig = () => {
127
89
  ENABLED_OPENAI: process.env.ENABLED_OPENAI !== '0',
128
90
  OPENAI_API_KEY: process.env.OPENAI_API_KEY,
129
91
  OPENAI_PROXY_URL: process.env.OPENAI_PROXY_URL,
130
- OPENAI_MODEL_LIST: process.env.OPENAI_MODEL_LIST || process.env.CUSTOM_MODELS,
92
+ OPENAI_MODEL_LIST: process.env.OPENAI_MODEL_LIST,
131
93
  OPENAI_FUNCTION_REGIONS: regions as any,
132
94
 
133
95
  ENABLED_AZURE_OPENAI: !!process.env.AZURE_API_KEY,
@@ -162,8 +124,7 @@ export const getLLMConfig = () => {
162
124
 
163
125
  ENABLED_OPENROUTER: !!process.env.OPENROUTER_API_KEY,
164
126
  OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
165
- OPENROUTER_MODEL_LIST:
166
- process.env.OPENROUTER_MODEL_LIST || process.env.OPENROUTER_CUSTOM_MODELS,
127
+ OPENROUTER_MODEL_LIST: process.env.OPENROUTER_MODEL_LIST,
167
128
 
168
129
  ENABLED_TOGETHERAI: !!process.env.TOGETHERAI_API_KEY,
169
130
  TOGETHERAI_API_KEY: process.env.TOGETHERAI_API_KEY,
@@ -187,7 +148,7 @@ export const getLLMConfig = () => {
187
148
 
188
149
  ENABLED_OLLAMA: process.env.ENABLED_OLLAMA !== '0',
189
150
  OLLAMA_PROXY_URL: process.env.OLLAMA_PROXY_URL || '',
190
- OLLAMA_MODEL_LIST: process.env.OLLAMA_MODEL_LIST || process.env.OLLAMA_CUSTOM_MODELS,
151
+ OLLAMA_MODEL_LIST: process.env.OLLAMA_MODEL_LIST,
191
152
 
192
153
  ENABLED_QWEN: !!process.env.QWEN_API_KEY,
193
154
  QWEN_API_KEY: process.env.QWEN_API_KEY,
@@ -0,0 +1,46 @@
1
+ CREATE TABLE IF NOT EXISTS "user_budgets" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "free_budget_id" text,
4
+ "free_budget_key" text,
5
+ "subscription_budget_id" text,
6
+ "subscription_budget_key" text,
7
+ "package_budget_id" text,
8
+ "package_budget_key" text,
9
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
10
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE TABLE IF NOT EXISTS "user_subscriptions" (
14
+ "id" text PRIMARY KEY NOT NULL,
15
+ "user_id" text NOT NULL,
16
+ "stripe_id" text,
17
+ "currency" text,
18
+ "pricing" integer,
19
+ "billing_paid_at" integer,
20
+ "billing_cycle_start" integer,
21
+ "billing_cycle_end" integer,
22
+ "cancel_at_period_end" boolean,
23
+ "cancel_at" integer,
24
+ "next_billing" jsonb,
25
+ "plan" text,
26
+ "recurring" text,
27
+ "storage_limit" integer,
28
+ "status" integer,
29
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
30
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
31
+ );
32
+ --> statement-breakpoint
33
+ ALTER TABLE "users" ALTER COLUMN "preference" DROP DEFAULT;--> statement-breakpoint
34
+ DO $$ BEGIN
35
+ ALTER TABLE "user_budgets" ADD CONSTRAINT "user_budgets_id_users_id_fk" FOREIGN KEY ("id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
36
+ EXCEPTION
37
+ WHEN duplicate_object THEN null;
38
+ END $$;
39
+ --> statement-breakpoint
40
+ DO $$ BEGIN
41
+ ALTER TABLE "user_subscriptions" ADD CONSTRAINT "user_subscriptions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
42
+ EXCEPTION
43
+ WHEN duplicate_object THEN null;
44
+ END $$;
45
+ --> statement-breakpoint
46
+ ALTER TABLE "users" DROP COLUMN IF EXISTS "key";