@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.
- package/.github/workflows/auto-merge.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/sync.yml +1 -1
- package/.github/workflows/test.yml +1 -1
- package/CHANGELOG.md +210 -185
- package/README.md +96 -75
- package/README.zh-CN.md +96 -75
- package/bun.lockb +0 -0
- package/package.json +1 -1
- package/src/store/session/slices/chat/actions/message.ts +10 -7
- package/src/store/session/slices/chat/actions/topic.ts +3 -1
- package/.gitpod.yml +0 -3
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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: () =>
|
|
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