fix: remove unuseful fields to reduce token usage

This commit is contained in:
ikechan8370 2023-07-10 11:18:15 +08:00
parent db24de9ae3
commit b5669de782
2 changed files with 13 additions and 6 deletions

View file

@ -8,14 +8,18 @@ export class SerpImageTool extends AbstractTool {
q: {
type: 'string',
description: 'search keyword'
},
limit: {
type: 'number',
description: 'image number'
}
},
required: ['q']
}
func = async function (opts) {
let { q } = opts
let serpRes = await fetch(`https://serp.ikechan8370.com/image/bing?q=${encodeURIComponent(q)}`, {
let { q, limit = 2 } = opts
let serpRes = await fetch(`https://serp.ikechan8370.com/image/bing?q=${encodeURIComponent(q)}&limit=${limit}`, {
headers: {
'X-From-Library': 'ikechan8370'
}
@ -23,8 +27,8 @@ export class SerpImageTool extends AbstractTool {
serpRes = await serpRes.json()
let res = serpRes.data
return `the images search results are here in json format:\n${JSON.stringify(res)}. the murl field is real picture url. You should use sendPicture to send them`
return `images search results in json format:\n${JSON.stringify(res)}. the murl field is actual picture url. You should use sendPicture to send them`
}
description = 'Useful when you want to search images from the internet.'
description = 'Useful when you want to search images from the Internet.'
}

View file

@ -22,7 +22,7 @@ export class SerpIkechan8370Tool extends AbstractTool {
if (!source) {
source = 'baidu'
}
let serpRes = await fetch(`https://serp.ikechan8370.com/${source}?q=${encodeURIComponent(q)}&lang=zh-CN&limit=10`, {
let serpRes = await fetch(`https://serp.ikechan8370.com/${source}?q=${encodeURIComponent(q)}&lang=zh-CN&limit=5`, {
headers: {
'X-From-Library': 'ikechan8370'
}
@ -30,8 +30,11 @@ export class SerpIkechan8370Tool extends AbstractTool {
serpRes = await serpRes.json()
let res = serpRes.data
res?.forEach(r => {
delete r?.rank
})
return `the search results are here in json format:\n${JSON.stringify(res)}`
}
description = 'Useful when you want to search something from the internet. If you don\'t know much about the user\'s question, just search about it! If you want to know details of a result, you can use website tool'
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'
}