From f1558cf107a9a2d02b2fb598750e27cf0d1e50e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A3=9E?= <42599406+xfdown@users.noreply.github.com> Date: Wed, 9 Apr 2025 22:21:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E4=BA=86=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=81=8A=E5=A4=A9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=88?= =?UTF-8?q?=E4=BB=85=E5=9C=A8icqq=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=EF=BC=89=20(#767)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/chat.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/utils/chat.js b/utils/chat.js index 1d86038..5b0790b 100644 --- a/utils/chat.js +++ b/utils/chat.js @@ -10,19 +10,14 @@ export async function getChatHistoryGroup (e, num) { let latestChat = latestChats[0] if (latestChat) { let seq = latestChat.seq || latestChat.message_id - let chats = [] - while (chats.length < num) { - let chatHistory = await e.group.getChatHistory(seq, 20) - if (!chatHistory || chatHistory.length === 0) { - break - } - chats.push(...chatHistory.reverse()) - if (seq === chatHistory[chatHistory.length - 1].seq || seq === chatHistory[chatHistory.length - 1].message_id) { - break - } - seq = chatHistory[chatHistory.length - 1].seq || chatHistory[chatHistory.length - 1].message_id - } - chats = chats.slice(0, num).reverse() + let chats = [e] + while(chats.length < num){ + let chatHistory = await e.group.getChatHistory(seq, 20) + if(seq === (chatHistory[0].seq || chatHistory[0].message_id)) break + seq = chatHistory[0].seq || chatHistory[0].message_id + chats.unshift(...chatHistory.filter(chat => chat.sender?.user_id).slice(0, -1)) + } + chats = chats.slice(chats.length - num) try { let mm = await e.bot.gml for (const chat of chats) { @@ -45,7 +40,6 @@ export async function getChatHistoryGroup (e, num) { } catch (err) { logger.warn(err) } - // console.log(chats) return chats } } From 475838264423cc0af46b9c5249b1463f49344faa Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Wed, 23 Apr 2025 11:24:53 +0800 Subject: [PATCH 2/4] fix: max_completion_tokens --- utils/openai/chatgpt-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/openai/chatgpt-api.js b/utils/openai/chatgpt-api.js index 56b5939..fe7752d 100644 --- a/utils/openai/chatgpt-api.js +++ b/utils/openai/chatgpt-api.js @@ -189,7 +189,7 @@ var ChatGPTAPI = /** @class */ (function () { 'Content-Type': 'application/json', Authorization: "Bearer ".concat(this._apiKey) }; - body = __assign(__assign(__assign({ max_tokens: maxTokens }, this._completionParams), completionParams), { messages: messages, stream: stream }); + body = __assign(__assign(__assign({ max_completion_tokens: maxTokens }, this._completionParams), completionParams), { messages: messages, stream: stream }); if (this._debug) { console.log(JSON.stringify(body)); } From 7b2262acc6ce3416e6de8067c54bec112a0dd92e Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Wed, 23 Apr 2025 11:26:43 +0800 Subject: [PATCH 3/4] fix: temperature --- utils/openai/chatgpt-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/openai/chatgpt-api.js b/utils/openai/chatgpt-api.js index fe7752d..25924dd 100644 --- a/utils/openai/chatgpt-api.js +++ b/utils/openai/chatgpt-api.js @@ -88,7 +88,7 @@ var ChatGPTAPI = /** @class */ (function () { this._apiBaseUrl = apiBaseUrl; this._debug = !!debug; this._fetch = fetch; - this._completionParams = __assign({ model: CHATGPT_MODEL, temperature: 0.8, top_p: 1.0, presence_penalty: 1.0 }, completionParams); + this._completionParams = __assign({ model: CHATGPT_MODEL, temperature: 1, top_p: 1.0, presence_penalty: 1.0 }, completionParams); this._systemMessage = systemMessage; if (this._systemMessage === undefined) { var currentDate = new Date().toISOString().split('T')[0]; From aeeba0889384b38a4c6dd4111e63d3eff8f54d12 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Wed, 23 Apr 2025 11:30:49 +0800 Subject: [PATCH 4/4] Update chatgpt-api.js --- utils/openai/chatgpt-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/openai/chatgpt-api.js b/utils/openai/chatgpt-api.js index 25924dd..31dbfb1 100644 --- a/utils/openai/chatgpt-api.js +++ b/utils/openai/chatgpt-api.js @@ -88,7 +88,7 @@ var ChatGPTAPI = /** @class */ (function () { this._apiBaseUrl = apiBaseUrl; this._debug = !!debug; this._fetch = fetch; - this._completionParams = __assign({ model: CHATGPT_MODEL, temperature: 1, top_p: 1.0, presence_penalty: 1.0 }, completionParams); + this._completionParams = __assign({ model: CHATGPT_MODEL, temperature: 1, top_p: 1.0 }, completionParams); this._systemMessage = systemMessage; if (this._systemMessage === undefined) { var currentDate = new Date().toISOString().split('T')[0];