mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
* 修复引用转发,默认bing模式并发 * 开启stream增加稳定性 * fix: remove queue element only in non-bing mode * 使用chatgpt-api自带的超时逻辑,文字过多时启动切换到图片输出防止被吞 * Update chat.js * 添加Bing专用的图片输出样式 * 添加chatgpt的新图片模式,临时处理切换api导致的对话异常 * 修改bing样式表 * 为图片添加外部页面缓存 * 为图片模式添加MathJax * feat: add switch for qrcode * 防止script攻击 * 修复网页模板错误 * 修复bing页面引用错误 * 缓存服务器异常时处理 * 添加默认配置加载 * 修复配置文件路径错误 * 删除重复的模板文件,修复二维码地址错误 * 修正图片渲染错误 * 修复引用渲染错误 * 二维码网址统一改为使用本地配置 * 添加关闭思考提示的配置项 * 修复在Windows上无法载入配置文件的问题 * 修复关闭qr的情况下渲染错误 * 改为使用base64传递返回数据 * 当异常过多时使用图片输出 * 添加锅巴面板配置支持 * 补充遗漏的默认配置 * 修复qr模式下引用未被传递的问题 * 修复未将引用数据传输给缓存服务器的问题 * 删除无用的bingTimeoutMs配置项 * 添加消息队列超时弹出 * 优化图片模式处理,解决对话队列卡住的问题 --------- Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
61 lines
No EOL
2.3 KiB
JavaScript
61 lines
No EOL
2.3 KiB
JavaScript
import fs from 'fs'
|
|
import lodash from 'lodash'
|
|
const defaultConfig = {
|
|
blockWords: ['屏蔽词1', '屏蔽词b'],
|
|
promptBlockWords: ['屏蔽词1', '屏蔽词b'],
|
|
defaultUsePicture: false,
|
|
autoUsePicture: true,
|
|
autoUsePictureThreshold: 1200,
|
|
conversationPreserveTime: 0,
|
|
toggleMode: 'at',
|
|
showQRCode: true,
|
|
cacheUrl: 'https://content.alcedogroup.com',
|
|
cacheEntry: false,
|
|
apiKey: '',
|
|
model: '',
|
|
api: 'https://chatgpt.duti.tech/api/conversation',
|
|
apiBaseUrl: 'https://chatgpt.duti.tech/api',
|
|
plus: false,
|
|
reverseProxy: 'https://chatgpt.pawan.krd/api/completions',
|
|
promptPrefixOverride: 'Your answer shouldn\'t be too verbose. If you are generating a list, do not have too many items. Keep the number of items short. Prefer to answer in Chinese.',
|
|
assistantLabel: 'ChatGPT',
|
|
thinkingTips: true,
|
|
username: '',
|
|
password: '',
|
|
UA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
|
|
headless: false,
|
|
chromePath: '',
|
|
'2captchaToken': '',
|
|
proxy: '',
|
|
debug: true,
|
|
defaultTimeoutMs: 120000,
|
|
chromeTimeoutMS: 120000
|
|
}
|
|
const _path = process.cwd()
|
|
let config = {}
|
|
if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/config.js`)) {
|
|
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/config.js`);
|
|
config = (await import(`file://${fullPath}`)).default;
|
|
} else if (fs.existsSync(`${_path}/plugins/chatgpt-plugin/config/index.js`)) {
|
|
// 兼容旧版本
|
|
const fullPath = fs.realpathSync(`${_path}/plugins/chatgpt-plugin/config/index.js`);
|
|
config = (await import(`file://${fullPath}`)).Config;
|
|
}
|
|
config = Object.assign({}, defaultConfig, config)
|
|
export const Config = new Proxy(config, {
|
|
set(target, property, value) {
|
|
target[property] = value;
|
|
const change = lodash.transform(target, function(result, value, key) {
|
|
if (!lodash.isEqual(value, defaultConfig[key])) {
|
|
result[key] = (lodash.isObject(value) && lodash.isObject(defaultConfig[key])) ? changes(value, defaultConfig[key]) : value;
|
|
}
|
|
});
|
|
try {
|
|
fs.writeFileSync(`${_path}/plugins/chatgpt-plugin/config/config.js`, `export default ${JSON.stringify(change, '', '\t')}`, { flag: 'w' })
|
|
} catch (err) {
|
|
console.error(err)
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
}); |