@fivetu53/soul-chat 1.0.8 → 1.1.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/bin/api.js +9 -0
- package/bin/index.js +16 -17
- package/package.json +1 -1
package/bin/api.js
CHANGED
|
@@ -228,6 +228,15 @@ export async function deleteMessage(messageId) {
|
|
|
228
228
|
return data;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
export async function deleteLastMessages(conversationId) {
|
|
232
|
+
const response = await request(`/api/chat/conversations/${conversationId}/last`, {
|
|
233
|
+
method: 'DELETE'
|
|
234
|
+
});
|
|
235
|
+
const data = await response.json();
|
|
236
|
+
if (!response.ok) throw new Error(data.error);
|
|
237
|
+
return data;
|
|
238
|
+
}
|
|
239
|
+
|
|
231
240
|
// Memory APIs
|
|
232
241
|
export async function getMemories(characterId) {
|
|
233
242
|
const response = await request(`/api/memories/${characterId}`);
|
package/bin/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { loadConfig, saveConfig, getConfigPath } from './config.js';
|
|
|
10
10
|
import { checkAuth, showAuthScreen } from './auth.js';
|
|
11
11
|
import {
|
|
12
12
|
isLoggedIn, getCurrentUser, logout, updateProfile,
|
|
13
|
-
sendMessage, getCharacters, createCharacter, getConversations, getMessages, clearConversation,
|
|
13
|
+
sendMessage, getCharacters, createCharacter, getConversations, getMessages, clearConversation, deleteLastMessages, getMemories, pinMemory, deleteMemory
|
|
14
14
|
} from './api.js';
|
|
15
15
|
|
|
16
16
|
// Setup marked with terminal renderer
|
|
@@ -508,23 +508,13 @@ async function showChat() {
|
|
|
508
508
|
|
|
509
509
|
if (input === '/delete') {
|
|
510
510
|
// 删除最后一轮对话(用户消息+AI回复)
|
|
511
|
-
if (messages.length >= 2) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
// 从本地移除最后一轮对话
|
|
517
|
-
const userIdx = messages.lastIndexOf(lastUserMsg);
|
|
518
|
-
if (userIdx !== -1) {
|
|
519
|
-
messages.splice(userIdx, 2); // 删除用户消息和AI回复
|
|
520
|
-
}
|
|
521
|
-
} catch (err) {
|
|
522
|
-
// 忽略
|
|
523
|
-
}
|
|
524
|
-
} else {
|
|
525
|
-
// 没有ID,只删除本地
|
|
526
|
-
messages.splice(-2, 2);
|
|
511
|
+
if (messages.length >= 2 && currentConversationId) {
|
|
512
|
+
try {
|
|
513
|
+
await deleteLastMessages(currentConversationId);
|
|
514
|
+
} catch (err) {
|
|
515
|
+
// 忽略服务端错误
|
|
527
516
|
}
|
|
517
|
+
messages.splice(-2);
|
|
528
518
|
}
|
|
529
519
|
continue;
|
|
530
520
|
}
|
|
@@ -571,6 +561,15 @@ async function showChat() {
|
|
|
571
561
|
|
|
572
562
|
if (json.type === 'info') {
|
|
573
563
|
currentConversationId = json.conversationId;
|
|
564
|
+
} else if (json.type === 'tool_call') {
|
|
565
|
+
// 显示搜索状态
|
|
566
|
+
process.stdout.write('\r\x1b[K');
|
|
567
|
+
process.stdout.write(c('cyan', ` 🔍 正在搜索: ${json.query}...`));
|
|
568
|
+
} else if (json.type === 'tool_result') {
|
|
569
|
+
// 显示搜索结果数量
|
|
570
|
+
process.stdout.write('\r\x1b[K');
|
|
571
|
+
process.stdout.write(c('green', ` 📋 找到 ${json.count} 条结果\n`));
|
|
572
|
+
process.stdout.write(c('bot', ` ${currentCharacter.name}: `));
|
|
574
573
|
} else if (json.type === 'content') {
|
|
575
574
|
fullResponse += json.content;
|
|
576
575
|
// 打字机效果:直接输出内容
|