@lobehub/chat 0.107.5 → 0.107.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.107.6](https://github.com/lobehub/lobe-chat/compare/v0.107.5...v0.107.6)
6
+
7
+ <sup>Released on **2023-11-30**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: 修正调用插件查询的显示问题.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: 修正调用插件查询的显示问题 ([671ccef](https://github.com/lobehub/lobe-chat/commit/671ccef))
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
+
5
30
  ### [Version 0.107.5](https://github.com/lobehub/lobe-chat/compare/v0.107.4...v0.107.5)
6
31
 
7
32
  <sup>Released on **2023-11-30**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.107.5",
3
+ "version": "0.107.6",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -260,6 +260,19 @@ describe('MessageModel', () => {
260
260
 
261
261
  expect(updatedMessage).toHaveProperty('content', 'Updated content');
262
262
  });
263
+
264
+ it('should update a role and plugins', async () => {
265
+ const createdMessage = await MessageModel.create(messageData);
266
+ const updateData = {
267
+ role: 'function' as const,
268
+ plugin: { apiName: 'a', identifier: 'b', arguments: 'abc' },
269
+ };
270
+
271
+ await MessageModel.update(createdMessage.id, updateData);
272
+ const updatedMessage = await MessageModel.findById(createdMessage.id);
273
+
274
+ expect(updatedMessage).toHaveProperty('role', 'function');
275
+ });
263
276
  });
264
277
 
265
278
  describe('batchUpdate', () => {
@@ -249,7 +249,6 @@ export const chatMessage: StateCreator<
249
249
  // 2. fetch the AI response
250
250
  const { isFunctionCall, content, functionCallAtEnd, functionCallContent } =
251
251
  await fetchAIChatMessage(messages, mid);
252
- await messageService.updateMessageContent(mid, content);
253
252
 
254
253
  // 3. if it's the function call message, trigger the function method
255
254
  if (isFunctionCall) {
@@ -361,6 +360,7 @@ export const chatMessage: StateCreator<
361
360
  onFinish: async (content) => {
362
361
  // update the content after fetch result
363
362
  await messageService.updateMessageContent(assistantId, content);
363
+ await refreshMessages();
364
364
  },
365
365
  onMessageHandle: async (text) => {
366
366
  output += text;
@@ -97,7 +97,7 @@ export const chatTopic: StateCreator<
97
97
  onError: () => {
98
98
  updateTopicTitleInSummary(topicId, topic.title);
99
99
  },
100
- onFinish: (text) => {
100
+ onFinish: async (text) => {
101
101
  topicService.updateTitle(topicId, text);
102
102
  },
103
103
  onLoadingChange: (loading) => {
@@ -27,7 +27,7 @@ export const getMessageError = async (response: Response) => {
27
27
 
28
28
  export interface FetchSSEOptions {
29
29
  onErrorHandle?: (error: ChatMessageError) => void;
30
- onFinish?: (text: string) => void;
30
+ onFinish?: (text: string) => Promise<void>;
31
31
  onMessageHandle?: (text: string) => void;
32
32
  }
33
33
 
@@ -67,7 +67,7 @@ export const fetchSSE = async (fetchFn: () => Promise<Response>, options: FetchS
67
67
  options.onMessageHandle?.(chunkValue);
68
68
  }
69
69
 
70
- options?.onFinish?.(output);
70
+ await options?.onFinish?.(output);
71
71
 
72
72
  return returnRes;
73
73
  };
@@ -78,7 +78,7 @@ interface FetchAITaskResultParams<T> {
78
78
  * 错误处理函数
79
79
  */
80
80
  onError?: (e: Error, rawError?: any) => void;
81
- onFinish?: (text: string) => void;
81
+ onFinish?: (text: string) => Promise<void>;
82
82
  /**
83
83
  * 加载状态变化处理函数
84
84
  * @param loading - 是否处于加载状态