@wu529778790/open-im 0.3.8 → 0.3.9
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/dist/shared/ai-task.js
CHANGED
|
@@ -12,10 +12,11 @@ function buildCompletionNote(result, sessionManager, ctx) {
|
|
|
12
12
|
parts.push(toolInfo);
|
|
13
13
|
if (result.model)
|
|
14
14
|
parts.push(result.model);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// 获取当前的总轮数(不再累加,因为已经在请求开始时累加了)
|
|
16
|
+
const currentTurns = ctx.threadId
|
|
17
|
+
? sessionManager.addTurnsForThread(ctx.userId, ctx.threadId, 0)
|
|
18
|
+
: sessionManager.addTurns(ctx.userId, 0);
|
|
19
|
+
const ctxWarning = getContextWarning(currentTurns);
|
|
19
20
|
if (ctxWarning)
|
|
20
21
|
parts.push(ctxWarning);
|
|
21
22
|
return parts.join(' | ');
|
|
@@ -79,6 +79,9 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
|
|
|
79
79
|
});
|
|
80
80
|
registerPermissionSender('telegram', {});
|
|
81
81
|
async function handleAIRequest(userId, chatId, prompt, workDir, convId, _threadCtx, replyToMessageId) {
|
|
82
|
+
// 在用户每次发送消息时就累加计数,确保提示能轮换显示
|
|
83
|
+
const currentTurns = sessionManager.addTurns(userId, 1);
|
|
84
|
+
log.info(`User request: total turns = ${currentTurns} for user ${userId}`);
|
|
82
85
|
const toolAdapter = getAdapter(config.aiCommand);
|
|
83
86
|
if (!toolAdapter) {
|
|
84
87
|
await sendTextReply(chatId, `未配置 AI 工具: ${config.aiCommand}`);
|