diff --git a/utils/tools/SerpIkechan8370Tool.js b/utils/tools/SerpIkechan8370Tool.js index d5d52d3..e360c06 100644 --- a/utils/tools/SerpIkechan8370Tool.js +++ b/utils/tools/SerpIkechan8370Tool.js @@ -34,7 +34,7 @@ export class SerpIkechan8370Tool extends AbstractTool { res?.forEach(r => { delete r?.rank }) - return `the search results are here in json format:\n${JSON.stringify(res)}` + return `the search results are here in json format:\n${JSON.stringify(res)} \n(Notice that these information are only available for you, the user cannot see them, you next answer should consider about the information)` } description = 'Useful when you want to search something from the Internet. If you don\'t know much about the user\'s question, prefer to search about it! If you want to know further details of a result, you can use website tool' diff --git a/utils/tools/WebsiteTool.js b/utils/tools/WebsiteTool.js index a67683c..88b383c 100644 --- a/utils/tools/WebsiteTool.js +++ b/utils/tools/WebsiteTool.js @@ -61,48 +61,49 @@ export class WebsiteTool extends AbstractTool { .replace(/\s{2}/g, '') // 多个空格只保留一个空格 .replace('', '') // 去除声明 - if (mode === 'gemini') { - let client = new CustomGoogleGeminiClient({ - e, - userId: e?.sender?.user_id, - key: Config.getGeminiKey(), - model: Config.geminiModel, - baseUrl: Config.geminiBaseUrl, - debug: Config.debug - }) - const htmlContentSummaryRes = await client.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`) - let htmlContentSummary = htmlContentSummaryRes.text - return `this is the main content of website:\n ${htmlContentSummary}` - } else { - let maxModelTokens = getMaxModelTokens(Config.model) - text = text.slice(0, Math.min(text.length, maxModelTokens - 1600)) - let completionParams = { - // model: Config.model - model: 'gpt-3.5-turbo-16k' - } - let api = new ChatGPTAPI({ - apiBaseUrl: Config.openAiBaseUrl, - apiKey: Config.apiKey, - debug: false, - completionParams, - fetch: (url, options = {}) => { - const defaultOptions = Config.proxy - ? { - agent: proxy(Config.proxy) - } - : {} - const mergedOptions = { - ...defaultOptions, - ...options - } - return fetch(url, mergedOptions) - }, - maxModelTokens - }) - const htmlContentSummaryRes = await api.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`, { completionParams }) - let htmlContentSummary = htmlContentSummaryRes.text - return `this is the main content of website:\n ${htmlContentSummary}` - } + // if (mode === 'gemini') { + // let client = new CustomGoogleGeminiClient({ + // e, + // userId: e?.sender?.user_id, + // key: Config.getGeminiKey(), + // model: Config.geminiModel, + // baseUrl: Config.geminiBaseUrl, + // debug: Config.debug + // }) + // const htmlContentSummaryRes = await client.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`) + // let htmlContentSummary = htmlContentSummaryRes.text + // return `this is the main content of website:\n ${htmlContentSummary}` + // } else { + // let maxModelTokens = getMaxModelTokens(Config.model) + // text = text.slice(0, Math.min(text.length, maxModelTokens - 1600)) + // let completionParams = { + // // model: Config.model + // model: 'gpt-3.5-turbo-16k' + // } + // let api = new ChatGPTAPI({ + // apiBaseUrl: Config.openAiBaseUrl, + // apiKey: Config.apiKey, + // debug: false, + // completionParams, + // fetch: (url, options = {}) => { + // const defaultOptions = Config.proxy + // ? { + // agent: proxy(Config.proxy) + // } + // : {} + // const mergedOptions = { + // ...defaultOptions, + // ...options + // } + // return fetch(url, mergedOptions) + // }, + // maxModelTokens + // }) + // const htmlContentSummaryRes = await api.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`, { completionParams }) + // let htmlContentSummary = htmlContentSummaryRes.text + // return `this is the main content of website:\n ${htmlContentSummary}` + // } + return `the content of the website is:\n${text}` } catch (err) { return `failed to visit the website, error: ${err.toString()}` } finally {