@wu529778790/open-im 0.3.2 → 0.3.4
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.
|
@@ -99,9 +99,9 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
|
|
|
99
99
|
const taskKey = `${userId}:${msgId}`;
|
|
100
100
|
// 创建动态节流器
|
|
101
101
|
const throttle = new DynamicThrottle();
|
|
102
|
-
//
|
|
102
|
+
// 不保存思考内容,只显示最终结果
|
|
103
103
|
let savedThinkingText = '';
|
|
104
|
-
let hasThinkingContent = false; //
|
|
104
|
+
let hasThinkingContent = false; // 始终为 false,不显示思考内容
|
|
105
105
|
// 创建包装的流式更新函数(带串行化、智能跳过和防抖)
|
|
106
106
|
const createStreamUpdateWrapper = () => {
|
|
107
107
|
let lastUpdateTime = 0;
|
|
@@ -181,11 +181,10 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
|
|
|
181
181
|
const DEBOUNCE_MS = 150;
|
|
182
182
|
let debounceTimer = null;
|
|
183
183
|
return (content, toolNote) => {
|
|
184
|
-
//
|
|
184
|
+
// 检测是否是思考内容,如果则跳过不显示
|
|
185
185
|
if (content.startsWith('💭 **思考中...**')) {
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
hasThinkingContent = true;
|
|
186
|
+
// 不保存思考内容,直接返回,不触发更新
|
|
187
|
+
return;
|
|
189
188
|
}
|
|
190
189
|
const now = Date.now();
|
|
191
190
|
const elapsed = now - lastUpdateTime;
|
|
@@ -223,15 +222,8 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
|
|
|
223
222
|
},
|
|
224
223
|
sendComplete: async (content, note) => {
|
|
225
224
|
throttle.reset();
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
const thinkingFormatted = `💭 思考过程:\n${savedThinkingText}\n\n─────────\n\n`;
|
|
229
|
-
const combined = thinkingFormatted + content;
|
|
230
|
-
await sendFinalMessages(chatId, msgId, combined, note, toolId);
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
await sendFinalMessages(chatId, msgId, content, note, toolId);
|
|
234
|
-
}
|
|
225
|
+
// 完成时,只发送最终结果,不包含思考内容
|
|
226
|
+
await sendFinalMessages(chatId, msgId, content, note, toolId);
|
|
235
227
|
},
|
|
236
228
|
sendError: async (error) => {
|
|
237
229
|
throttle.reset();
|
|
@@ -71,15 +71,12 @@ export async function sendThinkingMessage(chatId, replyToMessageId, toolId = 'cl
|
|
|
71
71
|
await bot.telegram.editMessageText(Number(chatId), msg.message_id, undefined, formatMessage('正在思考...', 'thinking', '请稍候', toolId), { reply_markup: buildStopKeyboard(msg.message_id) });
|
|
72
72
|
return String(msg.message_id);
|
|
73
73
|
}
|
|
74
|
-
//
|
|
74
|
+
// 检查错误是否可忽略(只忽略真正无害的错误)
|
|
75
75
|
function isIgnorableError(err) {
|
|
76
76
|
if (err && typeof err === 'object' && 'message' in err) {
|
|
77
77
|
const msg = String(err.message);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
msg.includes('can\'t parse entities') ||
|
|
81
|
-
msg.includes('message to edit not found') ||
|
|
82
|
-
msg.includes('message is not modified'));
|
|
78
|
+
// 只忽略 "not modified" 类错误(内容没有变化)
|
|
79
|
+
return msg.includes('not modified') || msg.includes('message is not modified');
|
|
83
80
|
}
|
|
84
81
|
return false;
|
|
85
82
|
}
|