@lobehub/chat 1.5.0 → 1.5.2

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,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.5.2](https://github.com/lobehub/lobe-chat/compare/v1.5.1...v1.5.2)
6
+
7
+ <sup>Released on **2024-07-17**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix session not reorder after send message.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix session not reorder after send message, closes [#3239](https://github.com/lobehub/lobe-chat/issues/3239) ([7245a08](https://github.com/lobehub/lobe-chat/commit/7245a08))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.5.1](https://github.com/lobehub/lobe-chat/compare/v1.5.0...v1.5.1)
31
+
32
+ <sup>Released on **2024-07-17**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Improve brand url.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Improve brand url, closes [#3238](https://github.com/lobehub/lobe-chat/issues/3238) ([eef066f](https://github.com/lobehub/lobe-chat/commit/eef066f))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 1.5.0](https://github.com/lobehub/lobe-chat/compare/v1.4.3...v1.5.0)
6
56
 
7
57
  <sup>Released on **2024-07-17**</sup>
package/README.md CHANGED
@@ -265,14 +265,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
265
265
 
266
266
  <!-- AGENT LIST -->
267
267
 
268
- | Recent Submits | Description |
269
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
270
- | [Foreign Trade High EQ Response](https://chat-preview.lobehub.com/market?agent=reply-agent)<br/><sup>By **[zhushen12580](https://github.com/zhushen12580)** on **2024-07-13**</sup> | My goal is to provide professional responses with high emotional intelligence to help solve various foreign trade-related issues.<br/>`polishing` `high-eq` `response` |
271
- | [Ducky Programming Assistant](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | Ducky Programming Assistant<br/>`programming` |
272
- | [AOSP Source Code Expert](https://chat-preview.lobehub.com/market?agent=aosp-development)<br/><sup>By **[viruscoding](https://github.com/viruscoding)** on **2024-06-24**</sup> | An expert in AOSP (Android Open Source Project) for Android, with a deep understanding and analytical ability of the latest AOSP source code.<br/>`aosp` |
273
- | [Fastapi Project Development Assistant](https://chat-preview.lobehub.com/market?agent=fastapi-development)<br/><sup>By **[xwxw098](https://github.com/xwxw098)** on **2024-06-19**</sup> | Proficient in Python modular development, skilled in using FastAPI, PostgreSQL, Tortoise-ORM, and other technologies, able to provide clear code structure and detailed comments for large projects.<br/>`fast-api` `python` `modular-development` |
274
-
275
- > 📊 Total agents: [<kbd>**295**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
268
+ | Recent Submits | Description |
269
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
270
+ | [Convert SQL Table Structure to Dao and Mapper](https://chat-preview.lobehub.com/market?agent=my-batis-generator)<br/><sup>By **[MeYoung](https://github.com/MeYoung)** on **2024-07-17**</sup> | Generate entity class and MyBatis Mapper based on a table structure<br/>`sql` `sql` `mybatis` |
271
+ | [Foreign Trade High EQ Response](https://chat-preview.lobehub.com/market?agent=reply-agent)<br/><sup>By **[zhushen12580](https://github.com/zhushen12580)** on **2024-07-13**</sup> | My goal is to provide professional responses with high emotional intelligence to help solve various foreign trade-related issues.<br/>`polishing` `high-eq` `response` |
272
+ | [Ducky Programming Assistant](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | Ducky Programming Assistant<br/>`programming` |
273
+ | [B1 Level German Conversation Partner](https://chat-preview.lobehub.com/market?agent=deutsche-b-1)<br/><sup>By **[tayhe](https://github.com/tayhe)** on **2024-07-08**</sup> | Provides fluent German conversation partners for B1 level learners<br/>`language-exchange` `learning-support` `education` `german-learning` |
274
+
275
+ > 📊 Total agents: [<kbd>**298**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
276
276
 
277
277
  <!-- AGENT LIST -->
278
278
 
package/README.zh-CN.md CHANGED
@@ -254,14 +254,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
254
254
 
255
255
  <!-- AGENT LIST -->
256
256
 
257
- | 最近新增 | 助手说明 |
258
- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
259
- | [外贸高情商回复](https://chat-preview.lobehub.com/market?agent=reply-agent)<br/><sup>By **[zhushen12580](https://github.com/zhushen12580)** on **2024-07-13**</sup> | 我的目标是提供具有高情商的专业回复,帮助解决各种外贸相关的问题。<br/>`润色` `高情商` `回复` |
260
- | [小黄鸭编程助手](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | 小黄鸭编程助手<br/>`programming` |
261
- | [AOSP 源码专家](https://chat-preview.lobehub.com/market?agent=aosp-development)<br/><sup>By **[viruscoding](https://github.com/viruscoding)** on **2024-06-24**</sup> | 一位精通 AOSP(Android Open Source Project)安卓的专家,对最新 AOSP 源代码有着深入的理解和分析能力。<br/>`aosp` |
262
- | [Fastapi 项目开发助手](https://chat-preview.lobehub.com/market?agent=fastapi-development)<br/><sup>By **[xwxw098](https://github.com/xwxw098)** on **2024-06-19**</sup> | 擅长 Python 模块化开发,熟练运用 FastAPI、PostgreSQL、Tortoise-ORM 等技术栈,能为大型项目提供清晰的代码结构并添加详细注释。<br/>`fast-api` `python` `模块化开发` |
263
-
264
- > 📊 Total agents: [<kbd>**295**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
257
+ | 最近新增 | 助手说明 |
258
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
259
+ | [SQL 表结构转 Dao 和 Mapper](https://chat-preview.lobehub.com/market?agent=my-batis-generator)<br/><sup>By **[MeYoung](https://github.com/MeYoung)** on **2024-07-17**</sup> | 给与一个表结构,生成表的实体和 MyBatis 的 Mapper<br/>`sql` `sql` `mybatis` |
260
+ | [外贸高情商回复](https://chat-preview.lobehub.com/market?agent=reply-agent)<br/><sup>By **[zhushen12580](https://github.com/zhushen12580)** on **2024-07-13**</sup> | 我的目标是提供具有高情商的专业回复,帮助解决各种外贸相关的问题。<br/>`润色` `高情商` `回复` |
261
+ | [小黄鸭编程助手](https://chat-preview.lobehub.com/market?agent=rubber-duck-programming)<br/><sup>By **[JiyuShao](https://github.com/JiyuShao)** on **2024-07-10**</sup> | 小黄鸭编程助手<br/>`programming` |
262
+ | [B1 级德语会话伙伴](https://chat-preview.lobehub.com/market?agent=deutsche-b-1)<br/><sup>By **[tayhe](https://github.com/tayhe)** on **2024-07-08**</sup> | B1 级学习者提供流利的德语会话伙伴<br/>`语言交流` `学习支持` `教育` `德语学习` |
263
+
264
+ > 📊 Total agents: [<kbd>**298**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
265
265
 
266
266
  <!-- AGENT LIST -->
267
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
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",
@@ -4,7 +4,7 @@ import Link from 'next/link';
4
4
  import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
- import { DOCUMENTS, GITHUB } from '@/const/url';
7
+ import { DOCUMENTS_REFER_URL, GITHUB } from '@/const/url';
8
8
 
9
9
  const BottomActions = memo(() => {
10
10
  const { t } = useTranslation('common');
@@ -14,7 +14,7 @@ const BottomActions = memo(() => {
14
14
  <Link aria-label={'GitHub'} href={GITHUB} target={'_blank'}>
15
15
  <ActionIcon icon={Github} placement={'right'} title={'GitHub'} />
16
16
  </Link>
17
- <Link aria-label={t('document')} href={DOCUMENTS} target={'_blank'}>
17
+ <Link aria-label={t('document')} href={DOCUMENTS_REFER_URL} target={'_blank'}>
18
18
  <ActionIcon icon={Book} placement={'right'} title={t('document')} />
19
19
  </Link>
20
20
  </>
@@ -6,6 +6,8 @@ import Link from 'next/link';
6
6
  import { memo } from 'react';
7
7
  import { Flexbox, FlexboxProps } from 'react-layout-kit';
8
8
 
9
+ import { UTM_SOURCE } from '@/const/url';
10
+
9
11
  const useStyles = createStyles(({ token, css }) => ({
10
12
  logoLink: css`
11
13
  height: 20px;
@@ -29,7 +31,11 @@ const BrandWatermark = memo<Omit<FlexboxProps, 'children'>>(({ style, ...rest })
29
31
  {...rest}
30
32
  >
31
33
  <span>Powered by</span>
32
- <Link className={styles.logoLink} href={'https://lobehub.com'} target={'_blank'}>
34
+ <Link
35
+ className={styles.logoLink}
36
+ href={`https://lobehub.com?utm_source=${UTM_SOURCE}&utm_content=brand_watermark`}
37
+ target={'_blank'}
38
+ >
33
39
  <LobeHub size={20} type={'text'} />
34
40
  </Link>
35
41
  </Flexbox>
package/src/const/url.ts CHANGED
@@ -6,6 +6,8 @@ import { withBasePath } from '@/utils/basePath';
6
6
  import pkg from '../../package.json';
7
7
  import { INBOX_SESSION_ID } from './session';
8
8
 
9
+ export const UTM_SOURCE = 'chat_preview';
10
+
9
11
  export const OFFICIAL_URL = 'https://lobechat.com/';
10
12
  export const OFFICIAL_PREVIEW_URL = 'https://chat-preview.lobehub.com/';
11
13
  export const OFFICIAL_SITE = 'https://lobehub.com/';
@@ -24,6 +26,9 @@ export const USAGE_DOCUMENTS = urlJoin(DOCUMENTS, '/usage');
24
26
  export const SELF_HOSTING_DOCUMENTS = urlJoin(DOCUMENTS, '/self-hosting');
25
27
  export const WEBRTC_SYNC_DOCUMENTS = urlJoin(SELF_HOSTING_DOCUMENTS, '/advanced/webrtc');
26
28
 
29
+ // use this for the link
30
+ export const DOCUMENTS_REFER_URL = `${DOCUMENTS}?utm_source=${UTM_SOURCE}`;
31
+
27
32
  export const WIKI = urlJoin(GITHUB, 'wiki');
28
33
  export const WIKI_PLUGIN_GUIDE = urlJoin(USAGE_DOCUMENTS, '/plugins/development');
29
34
  export const MANUAL_UPGRADE_URL = urlJoin(SELF_HOSTING_DOCUMENTS, '/advanced/upstream-sync');
@@ -11,7 +11,7 @@ import Marquee from 'react-fast-marquee';
11
11
  import { useTranslation } from 'react-i18next';
12
12
  import { Center, Flexbox } from 'react-layout-kit';
13
13
 
14
- import { OFFICIAL_URL } from '@/const/url';
14
+ import { OFFICIAL_URL, UTM_SOURCE } from '@/const/url';
15
15
  import { isOnServerSide } from '@/utils/env';
16
16
 
17
17
  export const BANNER_HEIGHT = 40;
@@ -60,7 +60,7 @@ const CloudBanner = memo<{ mobile?: boolean }>(({ mobile }) => {
60
60
  <b>{t('alert.cloud.title', { name: 'LobeChat Cloud' })}:</b>
61
61
  <span>
62
62
  {t(mobile ? 'alert.cloud.descOnMobile' : 'alert.cloud.desc', {
63
- credit: new Intl.NumberFormat('en-US').format(500_000),
63
+ credit: new Intl.NumberFormat('en-US').format(450_000),
64
64
  name: 'LobeChat Cloud',
65
65
  })}
66
66
  </span>
@@ -78,7 +78,7 @@ const CloudBanner = memo<{ mobile?: boolean }>(({ mobile }) => {
78
78
  <div className={styles.background} />
79
79
  <Center className={styles.wrapper} gap={16} horizontal width={'100%'}>
80
80
  {isTruncated ? <Marquee pauseOnHover>{content}</Marquee> : content}
81
- <Link href={OFFICIAL_URL} target={'_blank'}>
81
+ <Link href={`${OFFICIAL_URL}?utm_source=${UTM_SOURCE}&utm_medium=banner`} target={'_blank'}>
82
82
  <Button size={'small'} type="primary">
83
83
  {t('alert.cloud.action')} <Icon icon={ArrowRightIcon} />
84
84
  </Button>
@@ -24,10 +24,11 @@ import urlJoin from 'url-join';
24
24
  import type { MenuProps } from '@/components/Menu';
25
25
  import {
26
26
  DISCORD,
27
- DOCUMENTS,
27
+ DOCUMENTS_REFER_URL,
28
28
  EMAIL_SUPPORT,
29
29
  GITHUB_ISSUES,
30
30
  OFFICIAL_URL,
31
+ UTM_SOURCE,
31
32
  mailTo,
32
33
  } from '@/const/url';
33
34
  import { isServerMode } from '@/const/version';
@@ -177,7 +178,7 @@ export const useMenu = () => {
177
178
  icon: <Icon icon={Cloudy} />,
178
179
  key: 'cloud',
179
180
  label: (
180
- <Link href={OFFICIAL_URL} target={'_blank'}>
181
+ <Link href={`${OFFICIAL_URL}?utm_source=${UTM_SOURCE}`} target={'_blank'}>
181
182
  {t('userPanel.cloud', { name: 'LobeChat Cloud' })}
182
183
  </Link>
183
184
  ),
@@ -197,7 +198,7 @@ export const useMenu = () => {
197
198
  icon: <Icon icon={Book} />,
198
199
  key: 'docs',
199
200
  label: (
200
- <Link href={DOCUMENTS} target={'_blank'}>
201
+ <Link href={DOCUMENTS_REFER_URL} target={'_blank'}>
201
202
  {t('userPanel.docs')}
202
203
  </Link>
203
204
  ),
@@ -20,6 +20,7 @@ vi.mock('@/database/client/models/session', () => {
20
20
  update: vi.fn(),
21
21
  count: vi.fn(),
22
22
  batchCreate: vi.fn(),
23
+ findById: vi.fn(),
23
24
  isEmpty: vi.fn(),
24
25
  queryByKeyword: vi.fn(),
25
26
  updateConfig: vi.fn(),
@@ -15,6 +15,7 @@ import {
15
15
  SessionGroupItem,
16
16
  SessionGroups,
17
17
  } from '@/types/session';
18
+ import { merge } from '@/utils/merge';
18
19
 
19
20
  import { ISessionService } from './type';
20
21
 
@@ -94,7 +95,9 @@ export class ClientService implements ISessionService {
94
95
  data: Partial<Pick<LobeAgentSession, 'group' | 'meta' | 'pinned'>>,
95
96
  ) {
96
97
  const pinned = typeof data.pinned === 'boolean' ? (data.pinned ? 1 : 0) : undefined;
97
- return SessionModel.update(id, { ...data, pinned });
98
+ const prev = await SessionModel.findById(id);
99
+
100
+ return SessionModel.update(id, merge(prev, { ...data, pinned }));
98
101
  }
99
102
 
100
103
  async updateSessionConfig(
@@ -13,9 +13,9 @@ import {
13
13
  LobeAgentSession,
14
14
  LobeSessionType,
15
15
  LobeSessions,
16
- SessionGroupId,
17
16
  SessionGroupItem,
18
17
  SessionGroups,
18
+ UpdateSessionParams,
19
19
  } from '@/types/session';
20
20
 
21
21
  import { ISessionService } from './type';
@@ -54,14 +54,11 @@ export class ServerService implements ISessionService {
54
54
  return lambdaClient.session.countSessions.query();
55
55
  }
56
56
 
57
- updateSession(
58
- id: string,
59
- data: Partial<{ group?: SessionGroupId; meta?: any; pinned?: boolean }>,
60
- ): Promise<any> {
61
- const { group, pinned, meta } = data;
57
+ updateSession(id: string, data: Partial<UpdateSessionParams>): Promise<any> {
58
+ const { group, pinned, meta, updatedAt } = data;
62
59
  return lambdaClient.session.updateSession.mutate({
63
60
  id,
64
- value: { groupId: group === 'default' ? null : group, pinned, ...meta },
61
+ value: { groupId: group === 'default' ? null : group, pinned, ...meta, updatedAt },
65
62
  });
66
63
  }
67
64
 
@@ -19,6 +19,7 @@ import { agentSelectors } from '@/store/agent/selectors';
19
19
  import { chatHelpers } from '@/store/chat/helpers';
20
20
  import { messageMapKey } from '@/store/chat/slices/message/utils';
21
21
  import { ChatStore } from '@/store/chat/store';
22
+ import { useSessionStore } from '@/store/session';
22
23
  import { ChatMessage, ChatMessageError, MessageToolCall } from '@/types/message';
23
24
  import { TraceEventPayloads } from '@/types/trace';
24
25
  import { setNamespace } from '@/utils/storeDebug';
@@ -319,6 +320,8 @@ export const chatMessage: StateCreator<
319
320
  }
320
321
  }
321
322
  }
323
+ // update assistant update to make it rerank
324
+ useSessionStore.getState().triggerSessionUpdate(get().activeId);
322
325
 
323
326
  const id = await get().internal_createMessage(newMessage, {
324
327
  tempMessageId,
@@ -18,7 +18,7 @@ import {
18
18
  LobeSessionGroups,
19
19
  LobeSessionType,
20
20
  LobeSessions,
21
- SessionGroupId,
21
+ UpdateSessionParams,
22
22
  } from '@/types/session';
23
23
  import { merge } from '@/utils/merge';
24
24
  import { setNamespace } from '@/utils/storeDebug';
@@ -52,6 +52,7 @@ export interface SessionAction {
52
52
  isSwitchSession?: boolean,
53
53
  ) => Promise<string>;
54
54
  duplicateSession: (id: string) => Promise<void>;
55
+ triggerSessionUpdate: (id: string) => Promise<void>;
55
56
  updateSessionGroupId: (sessionId: string, groupId: string) => Promise<void>;
56
57
  updateSessionMeta: (meta: Partial<MetaData>) => void;
57
58
 
@@ -75,10 +76,7 @@ export interface SessionAction {
75
76
  useSearchSessions: (keyword?: string) => SWRResponse<any>;
76
77
 
77
78
  internal_dispatchSessions: (payload: SessionDispatch) => void;
78
- internal_updateSession: (
79
- id: string,
80
- data: Partial<{ group?: SessionGroupId; meta?: any; pinned?: boolean }>,
81
- ) => Promise<void>;
79
+ internal_updateSession: (id: string, data: Partial<UpdateSessionParams>) => Promise<void>;
82
80
  internal_processSessions: (
83
81
  sessions: LobeSessions,
84
82
  customGroups: LobeSessionGroups,
@@ -117,7 +115,6 @@ export const createSessionSlice: StateCreator<
117
115
 
118
116
  return id;
119
117
  },
120
-
121
118
  duplicateSession: async (id) => {
122
119
  const { switchSession, refreshSessions } = get();
123
120
  const session = sessionSelectors.getSessionById(id)(get());
@@ -153,7 +150,6 @@ export const createSessionSlice: StateCreator<
153
150
  pinSession: async (id, pinned) => {
154
151
  await get().internal_updateSession(id, { pinned });
155
152
  },
156
-
157
153
  removeSession: async (sessionId) => {
158
154
  await sessionService.removeSession(sessionId);
159
155
  await get().refreshSessions();
@@ -170,6 +166,10 @@ export const createSessionSlice: StateCreator<
170
166
  set({ activeId: sessionId }, false, n(`activeSession/${sessionId}`));
171
167
  },
172
168
 
169
+ triggerSessionUpdate: async (id) => {
170
+ await get().internal_updateSession(id, { updatedAt: new Date() });
171
+ },
172
+
173
173
  updateSearchKeywords: (keywords) => {
174
174
  set(
175
175
  { isSearching: !!keywords, sessionSearchKeywords: keywords },
@@ -1,5 +1,5 @@
1
1
  import { LobeSessions } from '@/types/session/agentSession';
2
- import { LobeSessionGroups } from '@/types/session/sessionGroup';
2
+ import { LobeSessionGroups, SessionGroupId } from '@/types/session/sessionGroup';
3
3
 
4
4
  export * from './agentSession';
5
5
  export * from './sessionGroup';
@@ -8,3 +8,10 @@ export interface ChatSessionList {
8
8
  sessionGroups: LobeSessionGroups;
9
9
  sessions: LobeSessions;
10
10
  }
11
+
12
+ export interface UpdateSessionParams {
13
+ group?: SessionGroupId;
14
+ meta?: any;
15
+ pinned?: boolean;
16
+ updatedAt: Date;
17
+ }