mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +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: {
|
||||
type: 'string',
|
||||
enum: ['google', 'bing', 'baidu', 'duckduckgo'],
|
||||
enum: ['bing', 'google', 'baidu', 'duckduckgo'],
|
||||
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) {
|
||||
let { q, source } = opts
|
||||
let { q, source, num = 5 } = opts
|
||||
if (!source || !['google', 'bing', 'baidu', 'duckduckgo'].includes(source)) {
|
||||
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: {
|
||||
'X-From-Library': 'ikechan8370'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue