@lobehub/chat 0.77.2 → 0.78.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.
@@ -270,21 +270,24 @@ export const chatMessage: StateCreator<
270
270
  const userId = nanoid();
271
271
  dispatchMessage({ id: userId, message, role: 'user', type: 'addMessage' });
272
272
 
273
- // 如果有 activeTopicId,则添加 topicId
273
+ // if there is activeTopicId,then add topicId to message
274
274
  if (activeTopicId) {
275
275
  dispatchMessage({ id: userId, key: 'topicId', type: 'updateMessage', value: activeTopicId });
276
276
  }
277
277
 
278
- // 先拿到当前的 messages
278
+ // Get the current messages to generate AI response
279
279
  const messages = chatSelectors.currentChats(get());
280
280
 
281
281
  await realFetchAIResponse(messages, userId);
282
282
 
283
- // TODO: AgentSettings 提供一个外部调用的 hooks
284
- // const chats = chatSelectors.currentChats(get());
285
- // if (chats.length >= 4) {
286
- // autocompleteSessionAgentMeta(session.id);
287
- // }
283
+ // check activeTopic and then auto create topic
284
+ const chats = chatSelectors.currentChats(get());
285
+
286
+ if (!activeTopicId && chats.length >= 2) {
287
+ const { saveToTopic, toggleTopic } = get();
288
+ const id = saveToTopic();
289
+ if (id) toggleTopic(id);
290
+ }
288
291
  },
289
292
 
290
293
  stopGenerateMessage: () => {
@@ -26,7 +26,7 @@ export interface ChatTopicAction {
26
26
  /**
27
27
  * 将当前消息保存为主题
28
28
  */
29
- saveToTopic: () => void;
29
+ saveToTopic: () => string | undefined;
30
30
  /**
31
31
  * 切换主题
32
32
  * @param id - 要切换的主题的 ID
@@ -118,6 +118,8 @@ export const chatTopic: StateCreator<
118
118
  },
119
119
  params: promptSummaryTitle(messages),
120
120
  });
121
+
122
+ return topicId;
121
123
  },
122
124
  toggleTopic: (id) => {
123
125
  set({ activeTopicId: id }, false, t('toggleTopic'));
package/.gitpod.yml DELETED
@@ -1,3 +0,0 @@
1
- tasks:
2
- - init: pnpm install
3
- command: pnpm run start