mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
feat: 搜图和发图
This commit is contained in:
parent
8d13145d2f
commit
5ccefa6fa6
3 changed files with 60 additions and 18 deletions
30
utils/tools/SearchImageTool.js
Normal file
30
utils/tools/SearchImageTool.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
|
||||
export class SerpImageTool extends AbstractTool {
|
||||
name = 'searchImage'
|
||||
|
||||
parameters = {
|
||||
properties: {
|
||||
q: {
|
||||
type: 'string',
|
||||
description: 'search keyword'
|
||||
}
|
||||
},
|
||||
required: ['q']
|
||||
}
|
||||
|
||||
func = async function (opts) {
|
||||
let { q } = opts
|
||||
let serpRes = await fetch(`https://serp.ikechan8370.com/image/bing?q=${encodeURIComponent(q)}`, {
|
||||
headers: {
|
||||
'X-From-Library': 'ikechan8370'
|
||||
}
|
||||
})
|
||||
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`
|
||||
}
|
||||
|
||||
description = 'Useful when you want to search images from the internet. '
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue