mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
对后台更新 (#683)
* fix: 修复星火api上下文 * 将无星火ck的情况降低为warn * feat: 添加星火设定自定义代码功能 * 修复星火api模式的一些问题 * 修复导出配置问题 * feat:添加工具箱快捷登录接口 * 添加工具箱快捷登录指令 * 阻止群聊使用快捷登录 * 添加Azure配置支持,修复重复的配置项冲突 * 移除旧版本渲染和新版本帮助 * 添加工具箱 * 更新工具箱替换原有后台 * 更新工具箱适配代码 * 后台适配Trss * 修复trss不支持sendPrivateMsg的问题 * 优化路由 * 修复路由 * 适配其他uin * 添加bing第三方绘图 * 修复bing绘图第三方调用错误 * 添加bing第三方绘图采样配置 * 修复错误 * 添加bing第三方绘图图片大小配置 * 修复视图错误 * 使用ap替换第三方绘图 * 适配trss * server 适配trss * 修复错误的后台版本更新 * 添加锅巴用户数据 * 修复server初始化消息错误 * 添加锅巴插件适配 * 更新后台页面 * 添加锅巴代理接口 * 优化锅巴接口代理 * 修复锅巴代理参数 * 删除调试信息 * 修复headers * 更新后台锅巴插件支持 * 适配星火v3 * 适配星火v3 * 修复星火domain错误 * 修复更新后trss无法快捷登陆面板问题 * 奇怪的错误,忽略提示不影响使用 * 添加后台配置项 * 添加后台星火v3.5模式选项 * 添加后台缺少的部分配置项 * 增加后台对缺少的锅巴配置自动读取,将后台登陆信息添加到redis
This commit is contained in:
parent
7bbe1a9db1
commit
b431794497
5 changed files with 184 additions and 9 deletions
|
|
@ -18,6 +18,11 @@
|
|||
"label": "调试信息",
|
||||
"data": "debug"
|
||||
},
|
||||
{
|
||||
"type": "check",
|
||||
"label": "QQ开启markdown",
|
||||
"data": "enableMd"
|
||||
},
|
||||
{
|
||||
"type": "check",
|
||||
"label": "是否允许私聊机器人",
|
||||
|
|
@ -127,6 +132,17 @@
|
|||
"placeholder": "测试期间提供一个公益接口,一段时间后撤掉",
|
||||
"data": "extraUrl"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"label": "翻译来源",
|
||||
"data": "translateSource",
|
||||
"items": [
|
||||
{ "label": "OpenAI", "value": "openai" },
|
||||
{ "label": "Gemini", "value": "gemini" },
|
||||
{ "label": "星火", "value": "xh" },
|
||||
{ "label": "通义千问", "value": "qwen" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"label": "Trss主账号",
|
||||
|
|
@ -472,7 +488,7 @@
|
|||
"type": "select",
|
||||
"label": "Bing模式",
|
||||
"data": "toneStyle",
|
||||
"items": [ { "label": "创意", "value": "Creative" }, { "label": "精确", "value": "Precise" } ]
|
||||
"items": [ { "label": "创意", "value": "Creative" }, { "label": "均衡", "value": "Balanced" }, { "label": "精确", "value": "Precise" } ]
|
||||
},
|
||||
{
|
||||
"type": "check",
|
||||
|
|
@ -568,6 +584,18 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "智谱清言",
|
||||
"tab": "chatGLM",
|
||||
"view": [
|
||||
{
|
||||
"type": "password",
|
||||
"label": "refresh token",
|
||||
"placeholder": "chatglm_refresh_token 6个月有效期",
|
||||
"data": "chatglmRefreshToken"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Slack Claude",
|
||||
"tab": "claude",
|
||||
|
|
@ -634,6 +662,10 @@
|
|||
"label": "讯飞星火认知大模型V3.0",
|
||||
"value": "apiv3"
|
||||
},
|
||||
{
|
||||
"label": "讯飞星火认知大模型V3.5",
|
||||
"value": "apiv3.5"
|
||||
},
|
||||
{
|
||||
"label": "讯飞星火助手",
|
||||
"value": "assistants"
|
||||
|
|
@ -756,6 +788,61 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "通义千问",
|
||||
"tab": "qwen",
|
||||
"view": [
|
||||
{
|
||||
"type": "password",
|
||||
"label": "API Key",
|
||||
"data": "qwenApiKey"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"label": "模型",
|
||||
"data": "qwenModel",
|
||||
"items": [
|
||||
{
|
||||
"label": "turbo",
|
||||
"value": "qwen-turbo"
|
||||
},
|
||||
{
|
||||
"label": "plus",
|
||||
"value": "qwen-plus"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "topP",
|
||||
"placeholder": "生成时,核采样方法的概率阈值。例如,取值为0.8时,仅保留累计概率之和大于等于0.8的概率分布中的token,作为随机采样的候选集。取值范围为(0,1.0),取值越大,生成的随机性越高;取值越低,生成的随机性越低。默认值 0.5。注意,取值不要大于等于1",
|
||||
"data": "qwenTopP"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "topK",
|
||||
"placeholder": "生成时,采样候选集的大小。例如,取值为50时,仅将单次生成中得分最高的50个token组成随机采样的候选集。取值越大,生成的随机性越高;取值越小,生成的确定性越高。注意:如果top_k的值大于100,top_k将采用默认值0,表示不启用top_k策略,此时仅有top_p策略生效。",
|
||||
"data": "qwenTopK"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "Seed",
|
||||
"placeholder": "生成时,随机数的种子,用于控制模型生成的随机性。如果使用相同的种子,每次运行生成的结果都将相同;当需要复现模型的生成结果时,可以使用相同的种子。seed参数支持无符号64位整数类型。默认值 0, 表示每次随机生成",
|
||||
"data": "qwenSeed"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"label": "温度",
|
||||
"placeholder": "用于控制随机性和多样性的程度。具体来说,temperature值控制了生成文本时对每个候选词的概率分布进行平滑的程度。较高的temperature值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化;而较低的temperature值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。\n\n 取值范围: (0, 2),系统默认值1.0",
|
||||
"data": "qwenTemperature"
|
||||
},
|
||||
{
|
||||
"type": "check",
|
||||
"label": "允许搜索",
|
||||
"data": "qwenEnableSearch"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Azure",
|
||||
"tab": "azure",
|
||||
|
|
@ -889,6 +976,24 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "SunoSettings",
|
||||
"title": "Suno音乐合成设置",
|
||||
"view": [
|
||||
{
|
||||
"type": "textarea",
|
||||
"label": "sess token",
|
||||
"placeholder": "suno的__sess token,需要与sunoClientToken一一对应数量相同,多个用逗号隔开",
|
||||
"data": "sunoSessToken"
|
||||
},
|
||||
{
|
||||
"type": "textarea",
|
||||
"label": "client token",
|
||||
"placeholder": "suno的__client token,需要与sunoSessToken一一对应数量相同,多个用逗号隔开",
|
||||
"data": "sunoClientToken"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "GroupSettings",
|
||||
"title": "群聊设置",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import os from 'os'
|
|||
import websocketclient from 'ws'
|
||||
|
||||
import { Config } from '../utils/config.js'
|
||||
import { UserInfo, GetUser, AddUser } from './modules/user_data.js'
|
||||
import { UserInfo, GetUser, AddUser, ReplaceUsers } from './modules/user_data.js'
|
||||
import { getPublicIP, getUserData, getMasterQQ, randomString, getUin } from '../utils/common.js'
|
||||
|
||||
import webRoute from './modules/web_route.js'
|
||||
|
|
@ -78,12 +78,12 @@ async function mediaLink () {
|
|||
if (data.qq && data.passwd) {
|
||||
const token = randomString(32)
|
||||
if (data.qq == getUin() && await redis.get('CHATGPT:ADMIN_PASSWD') == data.passwd) {
|
||||
AddUser({ user: data.qq, token, autho: 'admin' })
|
||||
await AddUser({ user: data.qq, token, autho: 'admin' })
|
||||
ws.send(JSON.stringify({ command: data.command, state: true, autho: 'admin', token, region: getUin(), type: 'server' }))
|
||||
} else {
|
||||
const user = await getUserData(data.qq)
|
||||
if (user.passwd != '' && user.passwd === data.passwd) {
|
||||
AddUser({ user: data.qq, token, autho: 'user' })
|
||||
await AddUser({ user: data.qq, token, autho: 'user' })
|
||||
ws.send(JSON.stringify({ command: data.command, state: true, autho: 'user', token, region: getUin(), type: 'server' }))
|
||||
} else {
|
||||
ws.send(JSON.stringify({ command: data.command, state: false, error: `用户名密码错误,如果忘记密码请私聊机器人输入 ${data.qq == getUin() ? '#修改管理密码' : '#修改用户密码'} 进行修改`, region: getUin(), type: 'server' }))
|
||||
|
|
@ -593,6 +593,7 @@ export async function runServer () {
|
|||
server.log.info(`server listening on ${server.server.address().port}`)
|
||||
}
|
||||
})
|
||||
await ReplaceUsers()
|
||||
}
|
||||
|
||||
export async function stopServer () {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,23 @@
|
|||
import { UserInfo } from './user_data.js'
|
||||
import { supportGuoba } from '../../guoba.support.js'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
function getAttributeValues(obj, attributeName, results = []) {
|
||||
if (Array.isArray(obj)) {
|
||||
obj.forEach(item => getAttributeValues(item, attributeName, results));
|
||||
} else if (typeof obj === 'object' && obj !== null) {
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (key === attributeName) {
|
||||
results.push(obj[key]);
|
||||
} else if (typeof obj[key] === 'object') {
|
||||
getAttributeValues(obj[key], attributeName, results);
|
||||
}
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
async function SettingView(fastify, options) {
|
||||
// 获取配置视图
|
||||
fastify.post('/settingView', async (request, reply) => {
|
||||
|
|
@ -11,7 +27,56 @@ async function SettingView(fastify, options) {
|
|||
reply.send({ err: '未登录' })
|
||||
} else if (user.autho === 'admin') {
|
||||
const filepath = path.join('plugins/chatgpt-plugin/resources/view', 'setting_view.json')
|
||||
const configView = JSON.parse(fs.readFileSync(filepath, 'utf8'))
|
||||
let configView = JSON.parse(fs.readFileSync(filepath, 'utf8'))
|
||||
|
||||
// 从锅巴配置获取额外配置视图
|
||||
const guoba = supportGuoba()
|
||||
const guobaConfig = guoba.configInfo.schemas
|
||||
const viewDataList = getAttributeValues(configView, 'data')
|
||||
const guobaDataList = getAttributeValues(guobaConfig, 'field')
|
||||
const otherDataList = guobaDataList.filter(item => !viewDataList.includes(item))
|
||||
const otherData = guobaConfig.filter(item => otherDataList.includes(item.field))
|
||||
// 转换视图
|
||||
if (otherData.length > 0) {
|
||||
let otherView = []
|
||||
for (const data of otherData) {
|
||||
let view = {
|
||||
'label': data.label,
|
||||
'placeholder': data.bottomHelpMessage || undefined,
|
||||
'data': data.field,
|
||||
}
|
||||
switch (data.component) {
|
||||
case 'Input':
|
||||
view.type = 'text'
|
||||
break
|
||||
case 'Switch':
|
||||
view.type = 'check'
|
||||
break
|
||||
case 'InputNumber':
|
||||
view.type = 'number'
|
||||
break
|
||||
case 'InputPassword':
|
||||
view.type = 'password'
|
||||
break
|
||||
case 'InputTextArea':
|
||||
view.type = 'textarea'
|
||||
break
|
||||
case 'Select':
|
||||
view.type = 'textarea'
|
||||
view.items = data.componentProps.options
|
||||
break
|
||||
default:
|
||||
continue
|
||||
}
|
||||
otherView.push(view)
|
||||
}
|
||||
configView.push({
|
||||
"id": "OtherSettings",
|
||||
"title": "其他设置",
|
||||
"view": otherView
|
||||
})
|
||||
}
|
||||
|
||||
reply.send(configView)
|
||||
} else {
|
||||
reply.send({ err: '权限不足' })
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ async function User (fastify, options) {
|
|||
const token = randomString(32)
|
||||
if (body.qq == getUin() && await redis.get('CHATGPT:ADMIN_PASSWD') == body.passwd) {
|
||||
const guobaToken = await guobaLoginService.signToken(body.qq)
|
||||
AddUser({ user: body.qq, token, autho: 'admin' })
|
||||
await AddUser({ user: body.qq, token, autho: 'admin' })
|
||||
reply.setCookie('token', token, { path: '/' })
|
||||
reply.send({ login: true, autho: 'admin', token, guobaToken, guoba: guobaAPI })
|
||||
} else {
|
||||
const user = await getUserData(body.qq)
|
||||
if (user.passwd != '' && user.passwd === body.passwd) {
|
||||
AddUser({ user: body.qq, token, autho: 'user' })
|
||||
await AddUser({ user: body.qq, token, autho: 'user' })
|
||||
reply.setCookie('token', token, { path: '/' })
|
||||
reply.send({ login: true, autho: 'user', token })
|
||||
} else {
|
||||
|
|
@ -43,7 +43,7 @@ async function User (fastify, options) {
|
|||
const opt = await redis.get('CHATGPT:SERVER_QUICK')
|
||||
if (opt && body.otp == opt) {
|
||||
const guobaToken = await guobaLoginService.signToken(getUin())
|
||||
AddUser({ user: getUin(), token, autho: 'admin' })
|
||||
await AddUser({ user: getUin(), token, autho: 'admin' })
|
||||
reply.setCookie('token', token, { path: '/' })
|
||||
reply.send({ login: true, autho: 'admin', token, user: getUin(), guobaToken, guoba: guobaAPI })
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export function GetUser(user) {
|
|||
return users.user.find(user => user === user)
|
||||
}
|
||||
// 添加用户token
|
||||
export function AddUser(data) {
|
||||
export async function AddUser(data) {
|
||||
const userIndex = users.user.findIndex(user => user === data.user)
|
||||
if (userIndex >= 0) {
|
||||
users.user[userIndex].token.push(data.token)
|
||||
|
|
@ -38,4 +38,8 @@ export function AddUser(data) {
|
|||
tiem: new Date()
|
||||
})
|
||||
}
|
||||
await redis.set('CHATGPT:SERVER_USER', JSON.stringify(users))
|
||||
}
|
||||
export async function ReplaceUsers() {
|
||||
users = JSON.parse(await redis.get('CHATGPT:SERVER_USER') || '{"user": []}')
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue