From 8c7e6489e7d4e5ea66e98da087377c2591b96dd6 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sun, 25 Jun 2023 16:17:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 3 ++- utils/tools/ProcessPictureTool.js | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index 4c41612..222bf14 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -1989,7 +1989,7 @@ export class chatgpt extends plugin { new WeatherTool(), new SendPictureTool(), new TTSTool(), - new ProcessPictureTool(), + serpTool ] let img = [] @@ -2015,6 +2015,7 @@ export class chatgpt extends plugin { } if (img.length > 0 && Config.extraUrl) { tools.push(new ImageCaptionTool()) + tools.push(new ProcessPictureTool()) prompt += `\nthe url of the picture(s) above: ${img.join(', ')}` } else { tools.push(new SerpImageTool()) diff --git a/utils/tools/ProcessPictureTool.js b/utils/tools/ProcessPictureTool.js index 2540519..bf5a283 100644 --- a/utils/tools/ProcessPictureTool.js +++ b/utils/tools/ProcessPictureTool.js @@ -26,14 +26,14 @@ export class ProcessPictureTool extends AbstractTool { description = 'useful when you want to know what is inside a photo, such as user\'s avatar or other pictures' func = async function (opts) { - let { imgUrl, qq, type } = opts + let { url, qq, type } = opts if (qq) { - imgUrl = `https://q1.qlogo.cn/g?b=qq&s=160&nk=${qq}` + url = `https://q1.qlogo.cn/g?b=qq&s=160&nk=${qq}` } - if (!imgUrl) { + if (!url) { return 'you must give at least one parameter of imgUrl and qq' } - const imageResponse = await fetch(imgUrl) + const imageResponse = await fetch(url) const blob = await imageResponse.blob() const arrayBuffer = await blob.arrayBuffer() const buffer = Buffer.from(arrayBuffer)