mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
34 lines
909 B
JavaScript
34 lines
909 B
JavaScript
import { AbstractTool } from './AbstractTool.js'
|
|
|
|
export class SerpImageTool extends AbstractTool {
|
|
name = 'searchImage'
|
|
|
|
parameters = {
|
|
properties: {
|
|
q: {
|
|
type: 'string',
|
|
description: 'search keyword'
|
|
},
|
|
limit: {
|
|
type: 'number',
|
|
description: 'image number'
|
|
}
|
|
},
|
|
required: ['q']
|
|
}
|
|
|
|
func = async function (opts) {
|
|
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'
|
|
}
|
|
})
|
|
serpRes = await serpRes.json()
|
|
|
|
let res = serpRes.data
|
|
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.'
|
|
}
|