add stable diffusion default negtive prompt system config

This commit is contained in:
RockYang 2024-05-07 16:21:31 +08:00
parent b0c9ffc5a6
commit 9a797bb4a5
8 changed files with 271 additions and 237 deletions

View File

@ -175,4 +175,6 @@ type SystemConfig struct {
EnableContext bool `json:"enable_context,omitempty"`
ContextDeep int `json:"context_deep,omitempty"`
SdNegPrompt string `json:"sd_neg_prompt"` // SD 默认反向提示词
}

View File

@ -83,7 +83,7 @@ func (h *ChatHandler) sendXunFeiMessage(
res = h.DB.Where("id", session.Model.KeyId).Where("enabled", true).Find(&apiKey)
}
// use the last unused key
if res.Error != nil {
if apiKey.Id == 0 {
res = h.DB.Where("platform", session.Model.Platform).Where("type", "chat").Where("enabled", true).Order("last_used_at ASC").First(&apiKey)
}
if res.Error != nil {

View File

@ -47,9 +47,9 @@ func NewLicenseService(server *core.AppServer, levelDB *store.LevelDB) *LicenseS
type License struct {
Name string `json:"name"`
License string `json:"license"`
Mid string `json:"mid"`
ActiveAt int64 `json:"active_at"`
License string `json:"license"`
MachineId string `json:"mid"`
ActiveAt int64 `json:"active_at"`
ExpiredAt int64 `json:"expired_at"`
UserNum int `json:"user_num"`
}
@ -139,7 +139,7 @@ func (s *LicenseService) fetchLicense() (*types.License, error) {
return &types.License{
Key: res.Data.License,
MachineId: res.Data.Mid,
MachineId: res.Data.MachineId,
UserNum: res.Data.UserNum,
ExpiredAt: res.Data.ExpiredAt,
IsActive: true,

View File

@ -58,6 +58,7 @@ func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderMa
services = append(services, plusService)
}
// for mid-journey proxy
for k, config := range appConfig.MjProxyConfigs {
if config.Enabled == false {
continue

View File

@ -608,7 +608,8 @@ onMounted(() => {
})
httpGet("/api/config/get?key=system").then(res => {
sdPower.value = res.data["sd_power"]
sdPower.value = res.data.sd_power
params.value.neg_prompt = res.data.sd_neg_prompt
}).catch(e => {
ElMessage.error("获取系统配置失败:" + e.message)
})

View File

@ -296,7 +296,7 @@ onUnmounted(() => {
const add = function () {
title.value = "新增模型"
showDialog.value = true
item.value = {enabled: true, weight: 1}
item.value = {enabled: true, weight: 1, open: true}
}
const edit = function (row) {

View File

@ -1,56 +1,40 @@
<template>
<div class="system-config" v-loading="loading">
<el-tabs v-model="activeName" class="demo-tabs">
<el-tab-pane label="基本设置" name="basic">
<el-tabs v-model="activeName" class="sys-tabs">
<el-tab-pane label="系统配置" name="basic">
<div class="container">
<el-form :model="system" label-width="150px" label-position="right" ref="systemFormRef" :rules="rules">
<el-form-item label="网站标题" prop="title">
<el-input v-model="system['title']"/>
</el-form-item>
<el-form-item label="控制台标题" prop="admin_title">
<el-input v-model="system['admin_title']"/>
</el-form-item>
<el-form-item label="网站 LOGO" prop="logo">
<el-input v-model="system['logo']" placeholder="网站LOGO图片">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('logo')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
</template>
</el-input>
</el-form-item>
<el-form-item label="注册赠送算力" prop="init_power">
<el-input v-model.number="system['init_power']" placeholder="新用户注册赠送算力"/>
</el-form-item>
<el-form-item label="邀请赠送算力" prop="invite_power">
<el-input v-model.number="system['invite_power']" placeholder="邀请新用户注册赠送算力"/>
</el-form-item>
<el-form-item label="VIP每月赠送算力" prop="vip_month_power">
<el-input v-model.number="system['vip_month_power']" placeholder="VIP用户每月赠送算力"/>
</el-form-item>
<el-form-item label="每日赠送算力" prop="daily_power">
<div class="tip-input-line">
<el-input v-model.number="system['daily_power']" placeholder="默认值0"/>
<div class="tip">
如果设置0表示不赠送用户享受完免费算力额度之后就不能再发起对话了如果设置为N则系统每天将算力值小于N的用户自动补充到N注意此功能要配合XXL-JOB启用
</div>
</div>
</el-form-item>
<el-form-item label="MJ绘图算力" prop="mj_power">
<div class="tip-input">
<el-input v-model.number="system['mj_power']" placeholder=""/>
<div class="info">
<el-tabs type="border-card">
<el-tab-pane label="基础配置">
<el-form-item label="网站标题" prop="title">
<el-input v-model="system['title']"/>
</el-form-item>
<el-form-item label="控制台标题" prop="admin_title">
<el-input v-model="system['admin_title']"/>
</el-form-item>
<el-form-item label="网站 LOGO" prop="logo">
<el-input v-model="system['logo']" placeholder="网站LOGO图片">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('logo')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
</template>
</el-input>
</el-form-item>
<el-form-item label="开放注册" prop="enabled_register">
<el-switch v-model="system['enabled_register']"/>
<el-tooltip
effect="dark"
content="使用MidJourney画一张图消耗算力"
content="关闭注册之后只能通过管理后台添加用户"
raw-content
placement="right"
>
@ -58,192 +42,237 @@
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="MJ操作算力" prop="mj_action_power">
<div class="tip-input">
<el-input v-model.number="system['mj_action_power']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="放大,变换,重绘操作一次消耗的算力"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="Stable-Diffusion算力" prop="sd_power">
<el-input v-model.number="system['sd_power']" placeholder="使用Stable-Diffusion画一张图消耗算力"/>
</el-form-item>
<el-form-item label="DALL-E-3算力" prop="dall_power">
<el-input v-model.number="system['dall_power']" placeholder="使用DALL-E-3画一张图消耗算力"/>
</el-form-item>
<el-form-item label="开放注册" prop="enabled_register">
<el-switch v-model="system['enabled_register']"/>
<el-tooltip
effect="dark"
content="关闭注册之后只能通过管理后台添加用户"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</el-form-item>
</el-form-item>
<el-form-item label="注册方式" prop="register_ways">
<el-checkbox-group v-model="system['register_ways']">
<el-checkbox label="mobile">手机注册</el-checkbox>
<el-checkbox label="email">邮箱注册</el-checkbox>
<el-checkbox label="username">用户名注册</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="注册方式" prop="register_ways">
<el-checkbox-group v-model="system['register_ways']">
<el-checkbox value="mobile">手机注册</el-checkbox>
<el-checkbox value="email">邮箱注册</el-checkbox>
<el-checkbox value="username">用户名注册</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="启用众筹功能" prop="enabled_reward">
<el-switch v-model="system['enabled_reward']"/>
<el-tooltip
effect="dark"
content="如果关闭次功能将不在用户菜单显示众筹二维码"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</el-form-item>
<div v-if="system['enabled_reward']">
<el-form-item label="算力单价" prop="power_price">
<el-input v-model="system['power_price']"
placeholder="单位算力的价格,比如设置 0.1 表示捐赠1元钱可以得到10个单位算力"/>
</el-form-item>
<el-form-item label="收款二维码" prop="reward_img">
<el-input v-model="system['reward_img']" placeholder="众筹收款二维码地址">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('reward_img')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
<el-form-item label="微信客服二维码" prop="wechat_card_url">
<el-input v-model="system['wechat_card_url']" placeholder="微信客服二维码">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('wechat_card_url')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
</template>
</el-input>
</el-form-item>
<el-form-item label="默认AI模型" prop="default_models">
<template #default>
<div class="tip-input">
<el-select
v-model="system['default_models']"
multiple
:filterable="true"
placeholder="选择AI模型多选"
style="width: 100%"
>
<el-option
v-for="item in models"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
<div class="info">
<el-tooltip
class="box-item"
effect="dark"
content="新用户注册默认开通的 AI 模型"
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</template>
</el-input>
</el-form-item>
<el-form-item label="开启聊天上下文">
<el-switch v-model="system['enable_context']"/>
</el-form-item>
<el-form-item label="会话上下文深度">
<div class="tip-input-line">
<el-input-number v-model="system['context_deep']" :min="0" :max="10"/>
<div class="tip">会话上下文深度在老会话中继续会话默认加载多少条聊天记录作为上下文如果设置为
0
则不加载聊天记录仅仅使用当前角色的上下文该配置参数最好设置需要为偶数否则将无法兼容百度的 API
</div>
</div>
</el-form-item>
<el-form-item label="SD反向提示词" prop="sd_neg_prompt">
<div class="tip-input">
<el-input v-model="system['sd_neg_prompt']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="Stable-Diffusion 绘画默认反向提示词"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
</el-tab-pane>
<el-tab-pane label="算力配置">
<el-form-item label="注册赠送算力" prop="init_power">
<el-input v-model.number="system['init_power']" placeholder="新用户注册赠送算力"/>
</el-form-item>
<el-form-item label="邀请赠送算力" prop="invite_power">
<el-input v-model.number="system['invite_power']" placeholder="邀请新用户注册赠送算力"/>
</el-form-item>
<el-form-item label="VIP每月赠送算力" prop="vip_month_power">
<el-input v-model.number="system['vip_month_power']" placeholder="VIP用户每月赠送算力"/>
</el-form-item>
<el-form-item label="每日赠送算力" prop="daily_power">
<div class="tip-input-line">
<el-input v-model.number="system['daily_power']" placeholder="默认值0"/>
<div class="tip">
如果设置0表示不赠送用户享受完免费算力额度之后就不能再发起对话了如果设置为N则系统每天将算力值小于N的用户自动补充到N注意此功能要配合XXL-JOB启用
</div>
</div>
</el-form-item>
<el-form-item label="MJ绘图算力" prop="mj_power">
<div class="tip-input">
<el-input v-model.number="system['mj_power']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="使用MidJourney画一张图消耗算力"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="MJ操作算力" prop="mj_action_power">
<div class="tip-input">
<el-input v-model.number="system['mj_action_power']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="放大,变换,重绘操作一次消耗的算力"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="Stable-Diffusion算力" prop="sd_power">
<el-input v-model.number="system['sd_power']" placeholder="使用Stable-Diffusion画一张图消耗算力"/>
</el-form-item>
<el-form-item label="DALL-E-3算力" prop="dall_power">
<el-input v-model.number="system['dall_power']" placeholder="使用DALL-E-3画一张图消耗算力"/>
</el-form-item>
</el-tab-pane>
<el-tab-pane label="众筹支付">
<el-form-item label="启用众筹功能" prop="enabled_reward">
<el-switch v-model="system['enabled_reward']"/>
<el-tooltip
effect="dark"
content="如果关闭次功能将不在用户菜单显示众筹二维码"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</el-form-item>
<div v-if="system['enabled_reward']">
<el-form-item label="算力单价" prop="power_price">
<el-input v-model="system['power_price']"
placeholder="单位算力的价格,比如设置 0.1 表示捐赠1元钱可以得到10个单位算力"/>
</el-form-item>
<el-form-item label="收款二维码" prop="reward_img">
<el-input v-model="system['reward_img']" placeholder="众筹收款二维码地址">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('reward_img')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
</template>
</el-input>
</el-form-item>
</div>
<el-form-item label="订单超时时间" prop="order_pay_timeout">
<div class="tip-input">
<el-input v-model.number="system['order_pay_timeout']" placeholder="单位:秒"/>
<div class="info">
<el-tooltip
effect="dark"
content="系统会定期清理超时未支付的订单<br/>默认值900秒"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="会员充值说明" prop="order_pay_timeout">
<div class="tip-input">
<el-input v-model="system['vip_info_text']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="会员充值页面的充值说明文字"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
</el-tab-pane>
</el-tabs>
<div style="padding: 10px;">
<el-form-item>
<el-button type="primary" @click="save('system')">保存</el-button>
</el-form-item>
</div>
<el-form-item label="微信客服二维码" prop="wechat_card_url">
<el-input v-model="system['wechat_card_url']" placeholder="微信客服二维码">
<template #append>
<el-upload
:auto-upload="true"
:show-file-list="false"
@click="beforeUpload('wechat_card_url')"
:http-request="uploadImg"
>
<el-icon class="uploader-icon">
<UploadFilled/>
</el-icon>
</el-upload>
</template>
</el-input>
</el-form-item>
<el-form-item label="订单超时时间" prop="order_pay_timeout">
<div class="tip-input">
<el-input v-model.number="system['order_pay_timeout']" placeholder="单位:秒"/>
<div class="info">
<el-tooltip
effect="dark"
content="系统会定期清理超时未支付的订单<br/>默认值900秒"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="会员充值说明" prop="order_pay_timeout">
<div class="tip-input">
<el-input v-model="system['vip_info_text']" placeholder=""/>
<div class="info">
<el-tooltip
effect="dark"
content="会员充值页面的充值说明文字"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="默认AI模型" prop="default_models">
<template #default>
<div class="tip-input">
<el-select
v-model="system['default_models']"
multiple
:filterable="true"
placeholder="选择AI模型多选"
style="width: 100%"
>
<el-option
v-for="item in models"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
<div class="info">
<el-tooltip
class="box-item"
effect="dark"
content="新用户注册默认开通的 AI 模型"
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</template>
</el-form-item>
<el-form-item label="开启聊天上下文">
<el-switch v-model="system['enable_context']"/>
</el-form-item>
<el-form-item label="会话上下文深度">
<div class="tip-input-line">
<el-input-number v-model="system['context_deep']" :min="0" :max="10"/>
<div class="tip">会话上下文深度在老会话中继续会话默认加载多少条聊天记录作为上下文如果设置为
0
则不加载聊天记录仅仅使用当前角色的上下文该配置参数最好设置需要为偶数否则将无法兼容百度的 API
</div>
</div>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="save('system')">保存</el-button>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
@ -457,11 +486,11 @@ const onUploadImg = (files, callback) => {
display flex
justify-content center
.el-tabs {
.sys-tabs {
width 100%
background-color var(--el-bg-color)
padding 10px 20px 40px 20px
border: 1px solid var(--el-border-color);
//border: 1px solid var(--el-border-color);
.container {
.el-form {

View File

@ -350,7 +350,8 @@ onMounted(() => {
})
httpGet("/api/config/get?key=system").then(res => {
sdPower.value = res.data["sd_power"]
sdPower.value = res.data.sd_power
params.value.neg_prompt = res.data.sd_neg_prompt
}).catch(e => {
showNotify({type: "danger", message: "获取系统配置失败:" + e.message})
})