mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 增加#chatgpt修补Gemini 以暂时解决google库不支持反代的问题
This commit is contained in:
parent
3aefa40920
commit
6769e9d3f0
1 changed files with 57 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { exec } from 'child_process'
|
||||
import { Config } from '../utils/config.js'
|
||||
import {
|
||||
formatDuration,
|
||||
|
|
@ -324,6 +325,11 @@ export class ChatgptManagement extends plugin {
|
|||
reg: '^#chatgpt设置星火模型$',
|
||||
fnc: 'setXinghuoModel',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt修补Gemini$',
|
||||
fnc: 'patchGemini',
|
||||
permission: 'master'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
@ -952,6 +958,57 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
}
|
||||
}
|
||||
|
||||
async patchGemini () {
|
||||
const _path = process.cwd()
|
||||
let packageJson = fs.readFileSync(`${_path}/package.json`)
|
||||
packageJson = JSON.parse(String(packageJson))
|
||||
const packageName = '@google/generative-ai@0.1.1'
|
||||
const patchLoc = 'plugins/chatgpt-plugin/patches/@google__generative-ai@0.1.1.patch'
|
||||
if (!packageJson.pnpm) {
|
||||
packageJson.pnpm = {
|
||||
patchedDependencies: {
|
||||
[packageName]: patchLoc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (packageJson.pnpm.patchedDependencies) {
|
||||
packageJson.pnpm.patchedDependencies[packageName] = patchLoc
|
||||
} else {
|
||||
packageJson.pnpm.patchedDependencies = {
|
||||
[packageName]: patchLoc
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(`${_path}/package.json`, JSON.stringify(packageJson, null, 2))
|
||||
|
||||
function execSync (cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
resolve({ error, stdout, stderr })
|
||||
})
|
||||
})
|
||||
}
|
||||
async function checkPnpm () {
|
||||
let npm = 'npm'
|
||||
let ret = await execSync('pnpm -v')
|
||||
if (ret.stdout) npm = 'pnpm'
|
||||
return npm
|
||||
}
|
||||
let npmv = await checkPnpm()
|
||||
if (npmv === 'pnpm') {
|
||||
exec('pnpm i', {}, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
logger.error(error)
|
||||
logger.error(stderr)
|
||||
logger.info(stdout)
|
||||
this.e.reply('失败,请查看日志手动操作')
|
||||
} else {
|
||||
this.e.reply('修补完成,请手动重启')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async useQwenSolution () {
|
||||
let use = await redis.get('CHATGPT:USE')
|
||||
if (use !== 'qwen') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue