@lobehub/chat 1.36.35 → 1.36.37

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 CHANGED
@@ -2,6 +2,40 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.36.37](https://github.com/lobehub/lobe-chat/compare/v1.36.36...v1.36.37)
6
+
7
+ <sup>Released on **2024-12-19**</sup>
8
+
9
+ <br/>
10
+
11
+ <details>
12
+ <summary><kbd>Improvements and Fixes</kbd></summary>
13
+
14
+ </details>
15
+
16
+ <div align="right">
17
+
18
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
19
+
20
+ </div>
21
+
22
+ ### [Version 1.36.36](https://github.com/lobehub/lobe-chat/compare/v1.36.35...v1.36.36)
23
+
24
+ <sup>Released on **2024-12-19**</sup>
25
+
26
+ <br/>
27
+
28
+ <details>
29
+ <summary><kbd>Improvements and Fixes</kbd></summary>
30
+
31
+ </details>
32
+
33
+ <div align="right">
34
+
35
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
36
+
37
+ </div>
38
+
5
39
  ### [Version 1.36.35](https://github.com/lobehub/lobe-chat/compare/v1.36.34...v1.36.35)
6
40
 
7
41
  <sup>Released on **2024-12-18**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,14 @@
1
1
  [
2
+ {
3
+ "children": {},
4
+ "date": "2024-12-19",
5
+ "version": "1.36.37"
6
+ },
7
+ {
8
+ "children": {},
9
+ "date": "2024-12-19",
10
+ "version": "1.36.36"
11
+ },
2
12
  {
3
13
  "children": {
4
14
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.36.35",
3
+ "version": "1.36.37",
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",
@@ -186,7 +186,7 @@
186
186
  "openapi-fetch": "^0.9.8",
187
187
  "partial-json": "^0.1.7",
188
188
  "pdf-parse": "^1.1.1",
189
- "pdfjs-dist": "4.4.168",
189
+ "pdfjs-dist": "4.8.69",
190
190
  "pg": "^8.13.0",
191
191
  "pino": "^9.5.0",
192
192
  "polished": "^4.3.1",
@@ -294,6 +294,16 @@ export class MessageModel {
294
294
  return result[0].count;
295
295
  };
296
296
 
297
+ hasMoreThanN = async (n: number): Promise<boolean> => {
298
+ const result = await this.db
299
+ .select({ id: messages.id })
300
+ .from(messages)
301
+ .where(eq(messages.userId, this.userId))
302
+ .limit(n + 1);
303
+
304
+ return result.length > n;
305
+ };
306
+
297
307
  // **************** Create *************** //
298
308
 
299
309
  create = async (
@@ -95,6 +95,16 @@ export class SessionModel {
95
95
  return result[0].count;
96
96
  };
97
97
 
98
+ hasMoreThanN = async (n: number): Promise<boolean> => {
99
+ const result = await this.db
100
+ .select({ id: sessions.id })
101
+ .from(sessions)
102
+ .where(eq(sessions.userId, this.userId))
103
+ .limit(n + 1);
104
+
105
+ return result.length > n;
106
+ };
107
+
98
108
  // **************** Create *************** //
99
109
 
100
110
  create = async ({
@@ -58,16 +58,17 @@ export const userRouter = router({
58
58
  }
59
59
 
60
60
  const messageModel = new MessageModel(serverDB, ctx.userId);
61
- const messageCount = await messageModel.count();
61
+ const hasMoreThan4Messages = await messageModel.hasMoreThanN(4);
62
62
 
63
63
  const sessionModel = new SessionModel(serverDB, ctx.userId);
64
- const sessionCount = await sessionModel.count();
64
+ const hasAnyMessages = await messageModel.hasMoreThanN(0);
65
+ const hasExtraSession = await sessionModel.hasMoreThanN(1);
65
66
 
66
67
  return {
67
- canEnablePWAGuide: messageCount >= 4,
68
- canEnableTrace: messageCount >= 4,
68
+ canEnablePWAGuide: hasMoreThan4Messages,
69
+ canEnableTrace: hasMoreThan4Messages,
69
70
  // 有消息,或者创建过助手,则认为有 conversation
70
- hasConversation: messageCount > 0 || sessionCount > 1,
71
+ hasConversation: hasAnyMessages || hasExtraSession,
71
72
 
72
73
  // always return true for community version
73
74
  isOnboard: state.isOnboarded || true,