From fcca28de37c66b517e3c04b1076c66fe49a8a44f Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sun, 16 Feb 2025 20:59:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=89=8D=E5=87=A0?= =?UTF-8?q?=E5=A4=A9=E6=94=AF=E6=8C=81multiple=20tools=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84gemini=E6=90=9C=E4=BA=86=E4=B8=8D=E5=8F=91=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/CustomGoogleGeminiClient.js | 4 ++-- utils/tools/SerpIkechan8370Tool.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/CustomGoogleGeminiClient.js b/client/CustomGoogleGeminiClient.js index 87ef625..2e5451f 100644 --- a/client/CustomGoogleGeminiClient.js +++ b/client/CustomGoogleGeminiClient.js @@ -222,11 +222,11 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient { // ANY要笑死人的效果 let mode = opt.toolMode || 'AUTO' - let lastFuncName = opt.functionResponse?.name + let lastFuncName = (/** @type {FunctionResponse[] | undefined}**/ opt.functionResponse)?.map(rsp => rsp.name) const mustSendNextTurn = [ 'searchImage', 'searchMusic', 'searchVideo' ] - if (lastFuncName && mustSendNextTurn.includes(lastFuncName)) { + if (lastFuncName && lastFuncName?.find(name => mustSendNextTurn.includes(name))) { mode = 'ANY' } body.tool_config = { diff --git a/utils/tools/SerpIkechan8370Tool.js b/utils/tools/SerpIkechan8370Tool.js index 075b059..d5d52d3 100644 --- a/utils/tools/SerpIkechan8370Tool.js +++ b/utils/tools/SerpIkechan8370Tool.js @@ -11,7 +11,8 @@ export class SerpIkechan8370Tool extends AbstractTool { }, source: { type: 'string', - enum: ['google', 'bing', 'baidu'] + enum: ['google', 'bing', 'baidu', 'duckduckgo'], + description: 'search source, default value is bing' } }, required: ['q'] @@ -19,8 +20,8 @@ export class SerpIkechan8370Tool extends AbstractTool { func = async function (opts) { let { q, source } = opts - if (!source || !['google', 'bing', 'baidu'].includes(source)) { - source = 'baidu' + if (!source || !['google', 'bing', 'baidu', 'duckduckgo'].includes(source)) { + source = 'bing' } let serpRes = await fetch(`https://serp.ikechan8370.com/${source}?q=${encodeURIComponent(q)}&lang=zh-CN&limit=5`, { headers: {