mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 修复website tool的bug(啊)
This commit is contained in:
parent
6ba96eecc7
commit
285afad993
1 changed files with 5 additions and 4 deletions
|
|
@ -60,13 +60,14 @@ export class WebsiteTool extends AbstractTool {
|
||||||
.replace('<!DOCTYPE html>', '') // 去除<!DOCTYPE>声明
|
.replace('<!DOCTYPE html>', '') // 去除<!DOCTYPE>声明
|
||||||
let maxModelTokens = getMaxModelTokens(Config.model)
|
let maxModelTokens = getMaxModelTokens(Config.model)
|
||||||
text = text.slice(0, Math.min(text.length, maxModelTokens - 1600))
|
text = text.slice(0, Math.min(text.length, maxModelTokens - 1600))
|
||||||
|
let completionParams = {
|
||||||
|
model: Config.model
|
||||||
|
}
|
||||||
let api = new ChatGPTAPI({
|
let api = new ChatGPTAPI({
|
||||||
apiBaseUrl: Config.openAiBaseUrl,
|
apiBaseUrl: Config.openAiBaseUrl,
|
||||||
apiKey: Config.apiKey,
|
apiKey: Config.apiKey,
|
||||||
debug: false,
|
debug: false,
|
||||||
completionParams: {
|
completionParams,
|
||||||
model: Config.model
|
|
||||||
},
|
|
||||||
fetch: (url, options = {}) => {
|
fetch: (url, options = {}) => {
|
||||||
const defaultOptions = Config.proxy
|
const defaultOptions = Config.proxy
|
||||||
? {
|
? {
|
||||||
|
|
@ -81,7 +82,7 @@ export class WebsiteTool extends AbstractTool {
|
||||||
},
|
},
|
||||||
maxModelTokens
|
maxModelTokens
|
||||||
})
|
})
|
||||||
const htmlContentSummaryRes = await api.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`)
|
const htmlContentSummaryRes = await api.sendMessage(`去除与主体内容无关的部分,从中整理出主体内容并转换成md格式,不需要主观描述性的语言与冗余的空白行。${text}`, { completionParams })
|
||||||
let htmlContentSummary = htmlContentSummaryRes.text
|
let htmlContentSummary = htmlContentSummaryRes.text
|
||||||
return `this is the main content of website:\n ${htmlContentSummary}`
|
return `this is the main content of website:\n ${htmlContentSummary}`
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue