修复一些图片模式页面错误,添加图片页面服务器自定义配置,修改配置文件加载方法 (#172)

This commit is contained in:
HalcyonAlcedo 2023-02-20 11:32:44 +08:00 committed by GitHub
parent 6b9afe588a
commit 049e71b7bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
203 changed files with 2071 additions and 1385 deletions

View file

@ -1,5 +1,5 @@
import lodash from 'lodash'
import { Config } from '../config/index.js'
import { Config } from '../utils/config.js'
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
import { getOpenAIAuth } from './openai-auth.js'
import delay from 'delay'

40
utils/config.js Normal file
View file

@ -0,0 +1,40 @@
import fs from 'fs'
const defaultConfig = {
blockWords: ['屏蔽词1', '屏蔽词b'],
defaultUsePicture: false,
autoUsePicture: true,
autoUsePictureThreshold: 1200,
conversationPreserveTime: 0,
toggleMode: 'at',
showQRCode: true,
cacheUrl: 'https://content.alcedogroup.com',
apiKey: '',
model: '',
api: 'https://chatgpt.duti.tech/api/conversation',
apiBaseUrl: 'https://chatgpt.duti.tech',
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',
username: '',
password: '',
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(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(fullPath)).Config;
}
export const Config = Object.assign({}, defaultConfig, config);

View file

@ -1,5 +1,5 @@
import fetch from 'node-fetch'
import { Config } from '../config/index.js'
import { Config } from '../utils/config.js'
export async function getConversations (qq = '') {
let accessToken = await redis.get('CHATGPT:TOKEN')

View file

@ -1,5 +1,5 @@
import { v4 as uuidv4 } from 'uuid'
import { Config } from '../config/index.js'
import { Config } from '../utils/config.js'
import HttpsProxyAgent from 'https-proxy-agent'
import _ from 'lodash'
import fetch from 'node-fetch'

View file

@ -1,4 +1,4 @@
import { Config } from '../config/index.js'
import { Config } from '../utils/config.js'
import delay from 'delay'
import random from 'random'