mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: adjust serp tool
This commit is contained in:
parent
95e776b334
commit
84e7e6b859
1 changed files with 8 additions and 4 deletions
|
|
@ -11,19 +11,23 @@ export class SerpIkechan8370Tool extends AbstractTool {
|
||||||
},
|
},
|
||||||
source: {
|
source: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
enum: ['google', 'bing', 'baidu', 'duckduckgo'],
|
enum: ['bing', 'google', 'baidu', 'duckduckgo'],
|
||||||
description: 'search source, default value is bing'
|
description: 'search source, default value is bing'
|
||||||
|
},
|
||||||
|
num: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'search results limit number, default is 5'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
required: ['q']
|
required: ['q', 'source']
|
||||||
}
|
}
|
||||||
|
|
||||||
func = async function (opts) {
|
func = async function (opts) {
|
||||||
let { q, source } = opts
|
let { q, source, num = 5 } = opts
|
||||||
if (!source || !['google', 'bing', 'baidu', 'duckduckgo'].includes(source)) {
|
if (!source || !['google', 'bing', 'baidu', 'duckduckgo'].includes(source)) {
|
||||||
source = 'bing'
|
source = 'bing'
|
||||||
}
|
}
|
||||||
let serpRes = await fetch(`https://serp.ikechan8370.com/${source}?q=${encodeURIComponent(q)}&lang=zh-CN&limit=5`, {
|
let serpRes = await fetch(`https://serp.ikechan8370.com/${source}?q=${encodeURIComponent(q)}&lang=zh-CN&limit=${num}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-From-Library': 'ikechan8370'
|
'X-From-Library': 'ikechan8370'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue