2.5版本 增加dall-e 优化mj 对接mj-plus

This commit is contained in:
小易
2024-02-04 18:51:37 +08:00
parent 822ff0a51d
commit 2ca3c164a0
57 changed files with 12239 additions and 7693 deletions

View File

@@ -1,5 +1,5 @@
{
"version": "2.4.0",
"version": "2.5.0",
"scripts": {
"dev": "vite",
"build:test": "vue-tsc --noEmit && vite build --mode test",

View File

@@ -174,6 +174,7 @@ export const MODEL_LIST = [
"gpt-4-vision-preview",
"gpt-4-all",
"gpt-4-0125-preview",
'dall-e-3',
// claude
"claude-2.0",
"claude-2.1",
@@ -293,6 +294,7 @@ export const MODELSMAPLIST = {
"gpt-4-vision-preview",
"gpt-4-all",
"gpt-4-0125-preview",
'dall-e-3',
// claude
"claude-2.0",
"claude-2.1",

View File

@@ -23,21 +23,21 @@ const routes: RouteRecordRaw = {
icon: 'menu-history',
},
},
{
path: 'config',
name: 'mjManage',
component: () => import('@/views/mjDraw/index.vue'),
meta: {
title: '参数配置',
icon: 'menu-params',
},
},
// {
// path: 'config',
// name: 'mjManage',
// component: () => import('@/views/mjDraw/index.vue'),
// meta: {
// title: '参数配置',
// icon: 'menu-params',
// },
// },
{
path: 'proxy',
name: 'mjProxyManage',
component: () => import('@/views/mjDraw/proxy.vue'),
meta: {
title: '更多设置',
title: '参数配置',
icon: 'menu-proxy',
},
},

View File

@@ -1,20 +1,23 @@
<route lang="yaml">
meta:
title: MJ绘画管理
</route>
</route>
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import type { FormInstance } from 'element-plus'
import { ElMessage } from 'element-plus'
import ApiChat from '@/api/modules/chat'
import ApiUsre from '@/api/modules/user'
import { DRAW_MJ_STATUS_LIST, RECOMMEND_STATUS_OPTIONS } from '@/constants/index'
import { onMounted, reactive, ref } from 'vue';
import type { FormInstance } from 'element-plus';
import { ElMessage } from 'element-plus';
import ApiChat from '@/api/modules/chat';
import ApiUsre from '@/api/modules/user';
import {
DRAW_MJ_STATUS_LIST,
RECOMMEND_STATUS_OPTIONS,
} from '@/constants/index';
const loading = ref(false)
const formRef = ref<FormInstance>()
const total = ref(0)
const userList = ref([])
const loading = ref(false);
const formRef = ref<FormInstance>();
const total = ref(0);
const userList = ref([]);
const formInline = reactive({
userId: '',
@@ -22,60 +25,60 @@ const formInline = reactive({
status: 3,
page: 1,
size: 10,
})
});
interface Logitem {
id: number
userId: number
answer: string
thumbImg: string
rec: number
model: number
createdAt: string
updatedAt: string
id: number;
userId: number;
answer: string;
thumbImg: string;
rec: number;
model: number;
createdAt: string;
updatedAt: string;
drawUrl: string;
fileInfo: {
width: number
height: number
thumbImg: string
cosUrl: string
}
width: number;
height: number;
thumbImg: string;
cosUrl: string;
};
}
const tableData = ref<Logitem[]>([])
const tableData = ref<Logitem[]>([]);
async function queryAllDrawLog() {
loading.value = true
loading.value = true;
try {
const res = await ApiChat.queryMjDrawAll(formInline)
const { rows, count } = res.data
loading.value = false
const res = await ApiChat.queryMjDrawAll(formInline);
const { rows, count } = res.data;
loading.value = false;
total.value = count
tableData.value = rows
}
catch (error) {
loading.value = false
total.value = count;
tableData.value = rows;
} catch (error) {
loading.value = false;
}
}
async function recommendDrawImg(id: number) {
const res = await ApiChat.recMjDrawImg({ id })
ElMessage.success(res.data)
queryAllDrawLog()
const res = await ApiChat.recMjDrawImg({ id });
ElMessage.success(res.data);
queryAllDrawLog();
}
async function handlerSearchUser(val: string) {
const res = await ApiUsre.queryAllUser({ size: 30, username: val })
userList.value = res.data.rows
const res = await ApiUsre.queryAllUser({ size: 30, username: val });
userList.value = res.data.rows;
}
function handlerReset(formEl: FormInstance | undefined) {
formEl?.resetFields()
queryAllDrawLog()
formEl?.resetFields();
queryAllDrawLog();
}
onMounted(() => {
queryAllDrawLog()
})
queryAllDrawLog();
});
</script>
<template>
@@ -102,37 +105,68 @@ onMounted(() => {
</el-select>
</el-form-item>
<el-form-item label="推荐状态" prop="rec">
<el-select v-model="formInline.rec" placeholder="请选择推荐状态" clearable>
<el-option v-for="item in RECOMMEND_STATUS_OPTIONS" :key="item.value" :label="item.label" :value="item.value" />
<el-select
v-model="formInline.rec"
placeholder="请选择推荐状态"
clearable
>
<el-option
v-for="item in RECOMMEND_STATUS_OPTIONS"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="绘制状态" prop="status">
<el-select v-model="formInline.status" placeholder="请选择图片绘制状态" clearable>
<el-option v-for="item in DRAW_MJ_STATUS_LIST" :key="item.value" :label="item.label" :value="item.value" />
<el-select
v-model="formInline.status"
placeholder="请选择图片绘制状态"
clearable
>
<el-option
v-for="item in DRAW_MJ_STATUS_LIST"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryAllDrawLog">
查询
</el-button>
<el-button @click="handlerReset(formRef)">
重置
</el-button>
<el-button type="primary" @click="queryAllDrawLog"> 查询 </el-button>
<el-button @click="handlerReset(formRef)"> 重置 </el-button>
</el-form-item>
</el-form>
</page-main>
<page-main v-loading="loading" style="width: 100%;">
<page-main v-loading="loading" style="width: 100%">
<div class="flex draw_container">
<div v-for="item in tableData" :key="item.id" style="height: 280px;" class="draw_img_container flex border">
<div
v-for="item in tableData"
:key="item.id"
style="height: 280px"
class="draw_img_container flex border"
>
<div class="draw_head">
<el-image fit="contain" :preview-src-list="[item.fileInfo.cosUrl]" :src="item.fileInfo.thumbImg" lazy class="draw_img" hide-on-click-modal />
<el-image
fit="contain"
:preview-src-list="[item.drawUrl]"
:src="item.drawUrl"
lazy
class="draw_img"
hide-on-click-modal
/>
</div>
<div class="draw_footer flex mt-3 justify-between items-center">
<el-tag class="ml-2" :type="item.rec ? 'success' : 'info'">
{{ item.rec ? '已推荐' : '未推荐' }}
</el-tag>
<el-button type="warning" plain size="small" @click="recommendDrawImg(item.id)">
<el-button
type="warning"
plain
size="small"
@click="recommendDrawImg(item.id)"
>
{{ item.rec ? '取消推荐' : '加入推荐' }}
<el-icon v-if="!item.rec">
<Plus />
@@ -161,32 +195,32 @@ onMounted(() => {
</div>
</template>
<style lang="less">
.draw_container {
flex-wrap: wrap;
min-height: 400px;
<style lang="less">
.draw_container {
flex-wrap: wrap;
min-height: 400px;
}
.draw_img_container {
max-width: 18%;
flex-direction: column;
margin: 8px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
.draw_head {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.draw_img {
width: 100%;
}
.draw_img_container {
max-width: 18%;
flex-direction: column;
margin: 8px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
.draw_head{
flex: 1;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.draw_img {
width: 100%;
}
.draw_footer {
height: 25px;
}
.draw_footer {
height: 25px;
}
</style>
}
</style>

View File

@@ -1,82 +1,85 @@
<route lang="yaml">
meta:
title: key列表
</route>
</route>
<script lang="ts" setup>
import { onMounted, reactive } from 'vue'
import { ElMessage, type FormInstance } from 'element-plus'
import ApiMj from '@/api/modules/mj'
import ApiChat from '@/api/modules/chat'
import { utcToShanghaiTime } from '@/utils/utcformatTime'
import { onMounted, reactive } from 'vue';
import { ElMessage, type FormInstance } from 'element-plus';
import ApiMj from '@/api/modules/mj';
import ApiChat from '@/api/modules/chat';
import { utcToShanghaiTime } from '@/utils/utcformatTime';
import { DRAW_STATUS_MAP, RECOMMEND_STATUS, WITHDRAW_STATUS_OPTIONS } from '@/constants/index'
import {
DRAW_STATUS_MAP,
RECOMMEND_STATUS,
WITHDRAW_STATUS_OPTIONS,
} from '@/constants/index';
const formRef = ref<FormInstance>()
const total = ref(0)
const loading = ref(false)
const formRef = ref<FormInstance>();
const total = ref(0);
const loading = ref(false);
const formInline = reactive({
rec: null,
status: null,
page: 1,
size: 10,
})
});
interface OrderInfo {
id: number
status: number
withdrawalAmount: number
userId: number
remark: string
contactInformation: string
auditStatus: number
auditUserId: number
createdAt: Date
updatedAt: Date
id: number;
status: number;
withdrawalAmount: number;
userId: number;
remark: string;
contactInformation: string;
auditStatus: number;
auditUserId: number;
createdAt: Date;
updatedAt: Date;
userInfo: {
avatar: string
username: string
email: string
}
avatar: string;
username: string;
email: string;
};
}
const tableData = ref<OrderInfo[]>([])
const tableData = ref<OrderInfo[]>([]);
async function queryDrawList() {
try {
loading.value = true
const res = await ApiMj.queryAdminDrawList(formInline)
loading.value = false
const { rows, count } = res.data
total.value = count
tableData.value = rows
}
catch (error) {
loading.value = false
loading.value = true;
const res = await ApiMj.queryAdminDrawList(formInline);
loading.value = false;
const { rows, count } = res.data;
total.value = count;
tableData.value = rows;
} catch (error) {
loading.value = false;
}
}
function handlerReset(formEl: FormInstance | undefined) {
formEl?.resetFields()
queryDrawList()
formEl?.resetFields();
queryDrawList();
}
async function recommendDrawImg(id: number) {
const res = await ApiChat.recMjDrawImg({ id })
ElMessage.success(res.data)
queryDrawList()
const res = await ApiChat.recMjDrawImg({ id });
ElMessage.success(res.data);
queryDrawList();
}
async function handleDelChatLog(id) {
const res = await ApiChat.delChatLog({ id })
ElMessage.success(res.data)
queryDrawList()
const res = await ApiChat.delChatLog({ id });
ElMessage.success(res.data);
queryDrawList();
}
onMounted(() => {
queryDrawList()
})
queryDrawList();
});
</script>
<template>
@@ -84,24 +87,38 @@ onMounted(() => {
<page-main>
<el-form ref="formRef" :inline="true" :model="formInline">
<el-form-item label="推荐状态" prop="rec">
<el-select v-model="formInline.rec" placeholder="请选择推荐状态" clearable>
<el-option v-for="item in RECOMMEND_STATUS" :key="item.value" :label="item.label" :value="item.value" />
<el-select
v-model="formInline.rec"
placeholder="请选择推荐状态"
clearable
>
<el-option
v-for="item in RECOMMEND_STATUS"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="绘制状态" prop="status">
<el-select v-model="formInline.status" placeholder="请选择绘制状态" clearable>
<el-option v-for="item in WITHDRAW_STATUS_OPTIONS" :key="item.value" :label="item.label" :value="item.value" />
<el-select
v-model="formInline.status"
placeholder="请选择绘制状态"
clearable
>
<el-option
v-for="item in WITHDRAW_STATUS_OPTIONS"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryDrawList">
查询
</el-button>
<el-button @click="handlerReset(formRef)">
重置
</el-button>
<el-button type="primary" @click="queryDrawList"> 查询 </el-button>
<el-button @click="handlerReset(formRef)"> 重置 </el-button>
</el-form-item>
<span style="float: right;">
<span style="float: right">
<el-button type="success" @click="queryDrawList">
刷新列表
</el-button>
@@ -109,33 +126,77 @@ onMounted(() => {
</el-form>
</page-main>
<page-main>
<el-alert show-icon title="MJ绘图历史说明" description="点击推荐的图片将会出现在画廊当中!" type="success" />
<el-alert
show-icon
title="MJ绘图历史说明"
description="点击推荐的图片将会出现在画廊当中!"
type="success"
/>
</page-main>
<page-main style="width: 100%;">
<el-table v-loading="loading" border :data="tableData" style="width: 100%;" size="large">
<page-main style="width: 100%">
<el-table
v-loading="loading"
border
:data="tableData"
style="width: 100%"
size="large"
>
<el-table-column prop="id" align="center" label="ID" width="70" />
<el-table-column prop="fileInfo.thumbImg" align="center" label="绘图结果">
<el-table-column prop="drawUrl" align="center" label="绘图结果">
<template #default="scope">
<el-image style="height: 120px;" preview-teleported fit="contain" :preview-src-list="[scope.row?.fileInfo?.cosUrl]" :src="scope.row?.fileInfo?.thumbImg" lazy hide-on-click-modal />
<el-image
style="height: 120px"
preview-teleported
fit="contain"
:preview-src-list="[scope.row?.drawUrl]"
:src="scope.row?.drawUrl"
lazy
hide-on-click-modal
/>
</template>
</el-table-column>
<el-table-column prop="userInfo.username" align="center" label="用户名" width="120" />
<el-table-column prop="fileInfo.thumbImg" align="center" label="推荐状态" width="90">
<el-table-column
prop="userInfo.username"
align="center"
label="用户名"
width="120"
/>
<el-table-column
prop="fileInfo.thumbImg"
align="center"
label="推荐状态"
width="90"
>
<template #default="scope">
<el-tag :type="scope.row.rec === 1 ? 'success' : ''">
{{ scope.row.rec === 1 ? '已推荐' : '未推荐' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="userInfo.email" label="邮箱" width="180" align="center" />
<el-table-column prop="status" align="center" label="绘图状态" width="105">
<el-table-column
prop="userInfo.email"
label="邮箱"
width="180"
align="center"
/>
<el-table-column
prop="status"
align="center"
label="绘图状态"
width="105"
>
<template #default="scope">
<el-tag :type="scope.row.status === 100 ? 'success' : ''">
{{ DRAW_STATUS_MAP[scope.row.status] }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="fullPrompt" label="绘图指令" align="center" width="200">
<el-table-column
prop="fullPrompt"
label="绘图指令"
align="center"
width="200"
>
<template #default="scope">
<el-popover placement="top" :width="400" trigger="click">
<template #reference>
@@ -149,19 +210,38 @@ onMounted(() => {
</el-popover>
</template>
</el-table-column>
<el-table-column prop="progress" align="center" label="绘图进度" width="90" />
<el-table-column
prop="progress"
align="center"
label="绘图进度"
width="90"
/>
<el-table-column prop="fileInfo.thumbImg" align="center" label="绘图尺寸" width="120">
<el-table-column
prop="fileInfo.thumbImg"
align="center"
label="绘图尺寸"
width="120"
>
<template #default="scope">
{{ scope.row?.fileInfo ? `${scope.row?.fileInfo?.width}*${scope.row?.fileInfo?.height}` : '---' }}
{{
scope.row?.fileInfo
? `${scope.row?.fileInfo?.width}*${scope.row?.fileInfo?.height}`
: '---'
}}
</template>
</el-table-column>
<el-table-column prop="userInfo.avatar" label="用户头像" width="90">
<template #default="scope">
<img :src="scope.row?.userInfo?.avatar" style="height: 50px;">
<img :src="scope.row?.userInfo?.avatar" style="height: 50px" />
</template>
</el-table-column>
<el-table-column prop="createdAt" label="提问时间" align="center" width="200">
<el-table-column
prop="createdAt"
label="提问时间"
align="center"
width="200"
>
<template #default="scope">
{{ utcToShanghaiTime(scope.row.createdAt, 'YYYY-MM-DD hh:mm:ss') }}
</template>
@@ -169,18 +249,32 @@ onMounted(() => {
<el-table-column fixed="right" label="操作" width="200" align="center">
<template #default="scope">
<el-popconfirm :title="`确认${scope.row.rec === 1 ? '取消推荐' : '推荐'}图片吗!`" width="260" icon-color="red" @confirm="recommendDrawImg(scope.row.id)">
<el-popconfirm
:title="`确认${
scope.row.rec === 1 ? '取消推荐' : '推荐'
}图片吗!`"
width="260"
icon-color="red"
@confirm="recommendDrawImg(scope.row.id)"
>
<template #reference>
<el-button link :type="scope.row.rec === 1 ? 'success' : '' " size="small">
<el-button
link
:type="scope.row.rec === 1 ? 'success' : ''"
size="small"
>
推荐图片
</el-button>
</template>
</el-popconfirm>
<el-popconfirm title="`确认删除此条记录么!" width="260" icon-color="red" @confirm="handleDelChatLog(scope.row.id)">
<el-popconfirm
title="`确认删除此条记录么!"
width="260"
icon-color="red"
@confirm="handleDelChatLog(scope.row.id)"
>
<template #reference>
<el-button type="warning" size="small">
删除记录
</el-button>
<el-button type="warning" size="small"> 删除记录 </el-button>
</template>
</el-popconfirm>
</template>

View File

@@ -1,49 +1,59 @@
<route lang="yaml">
meta:
title: MJ设置
</route>
</route>
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import apiConfig from '@/api/modules/config'
import { onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import type { FormInstance, FormRules } from 'element-plus';
import apiConfig from '@/api/modules/config';
const formInline = reactive({
mjTimeoutMs: '', // 接口超时时间
mjProxy: '0',
mjTimeoutMs: '500000',
mjProxyUrl: '',
mjLimitCount: null,
mjProxyImgUrl: '',
mjKey: '',
mjLimitCount: '2',
// mjProxyImgUrl: '',
mjNotSaveImg: '0',
mjUseBaiduFy: '0',
// mjUseBaiduFy: '0',
mjHideNotBlock: '0',
mjHideWorkIn: '0'
})
mjHideWorkIn: '0',
});
const rules = ref<FormRules>({})
const rules = ref<FormRules>({});
const formRef = ref<FormInstance>()
const formRef = ref<FormInstance>();
async function queryAllconfig() {
const res = await apiConfig.queryConfig({ keys: ['mjTimeoutMs', 'mjProxy', 'mjProxyUrl','mjLimitCount','mjNotSaveImg','mjProxyImgUrl','mjUseBaiduFy','mjHideNotBlock','mjHideWorkIn'] })
Object.assign(formInline, res.data)
const res = await apiConfig.queryConfig({
keys: [
'mjTimeoutMs',
'mjKey',
'mjProxyUrl',
'mjLimitCount',
'mjNotSaveImg',
// 'mjProxyImgUrl',
// 'mjUseBaiduFy',
'mjHideNotBlock',
'mjHideWorkIn',
],
});
Object.assign(formInline, res.data);
}
function handlerUpdateConfig() {
formRef.value?.validate(async (valid) => {
if (valid) {
try {
await apiConfig.setConfig({ settings: fotmatSetting(formInline) })
ElMessage.success('变更配置信息成功')
}
catch (error) {}
queryAllconfig()
await apiConfig.setConfig({ settings: fotmatSetting(formInline) });
ElMessage.success('变更配置信息成功');
} catch (error) {}
queryAllconfig();
} else {
ElMessage.error('请填写完整信息');
}
else {
ElMessage.error('请填写完整信息')
}
})
});
}
function fotmatSetting(settings: any) {
@@ -51,21 +61,27 @@ function fotmatSetting(settings: any) {
return {
configKey: key,
configVal: settings[key],
}
})
};
});
}
onMounted(() => {
queryAllconfig()
})
queryAllconfig();
});
</script>
<template>
<div>
<page-main>
<el-alert :closable="false" show-icon title="MJ参数说明" description="如果您是海外服务器则不强制开启代理、反之则需要开启代理、代理为系统配套项目、非常规代理、如果您想自己搭建代理请查看教程、如果您想使用系统提供的默认代理、那么选择开启代理并且不填写代理地址即可使用默认地址、如果想获取默认地址请在售后群获取地址!" type="success" />
<el-alert
:closable="false"
show-icon
title="MJ参数说明"
description="如果您是海外服务器则不强制开启代理、反之则需要开启代理、代理为系统配套项目、非常规代理、如果您想自己搭建代理请查看教程、如果您想使用系统提供的默认代理、那么选择开启代理并且不填写代理地址即可使用默认地址、如果想获取默认地址请在售后群获取地址!"
type="success"
/>
</page-main>
<el-card style="margin: 20px;">
<el-card style="margin: 20px">
<template #header>
<div class="flex justify-between">
<b>MJ参数设置</b>
@@ -74,9 +90,14 @@ onMounted(() => {
</el-button>
</div>
</template>
<el-form ref="formRef" :rules="rules" :model="formInline" label-width="150px">
<el-form
ref="formRef"
:rules="rules"
:model="formInline"
label-width="150px"
>
<h4>绘图代理设置</h4>
<el-row>
<!-- <el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="是否开启代理" prop="mjProxy">
<el-switch
@@ -86,107 +107,143 @@ onMounted(() => {
/>
</el-form-item>
</el-col>
</el-row>
</el-row> -->
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="请填写代理地址" prop="mjProxyUrl" label-width="150">
<el-input v-model="formInline.mjProxyUrl" placeholder="请填写代理地址、详细使用请访问教程!" clearable />
<el-form-item
label="请填写代理地址"
prop="mjProxyUrl"
label-width="150"
>
<el-input
v-model="formInline.mjProxyUrl"
placeholder="请填写代理地址、详细使用请访问教程!"
clearable
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="绘画超时时间设置ms" prop="mjTimeoutMs" label-width="150">
<el-input v-model="formInline.mjTimeoutMs" placeholder="请设置绘画超时时间、单位为ms、根据慢速快速定义后续优化逻辑" clearable />
<el-form-item label="MJ 绘图 Key" prop="mjKey" label-width="150">
<el-input
v-model="formInline.mjKey"
placeholder="请填 MJ 绘图使用的 Key"
clearable
/>
</el-form-item>
</el-col>
</el-row>
<el-divider />
<h4>绘图并发设置</h4>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="单人绘图并发限制" prop="mjLimitCount" label-width="150">
<el-input v-model="formInline.mjLimitCount" placeholder="单人同时绘制限制数量、同一时间最多可以绘制几张!" clearable />
<el-form-item
label="绘画超时时间设置ms"
prop="mjTimeoutMs"
label-width="150"
>
<el-input
v-model="formInline.mjTimeoutMs"
placeholder="请设置绘画超时时间、单位为ms、根据慢速快速定义后续优化逻辑"
clearable
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item
label="单人绘图并发限制"
prop="mjLimitCount"
label-width="150"
>
<el-input
v-model="formInline.mjLimitCount"
placeholder="单人同时绘制限制数量、同一时间最多可以绘制几张!"
clearable
/>
</el-form-item>
</el-col>
</el-row>
<el-divider />
<h4>绘图可选设置</h4>
<el-row>
<!-- <el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="描述词使用百度翻译" prop="mjUseBaiduFy" label-width="150" >
<el-switch
<el-form-item
label="描述词使用百度翻译"
prop="mjUseBaiduFy"
label-width="150"
>
<el-switch
v-model="formInline.mjUseBaiduFy"
active-value="1"
inactive-value="0"
/>
<el-tooltip
class="box-item"
effect="dark"
placement="right"
>
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px;">
<div style="width: 250px">
mj描述词的翻译默认设置为AI翻译如果您想使用百度翻译请打开此选项并且在下面的百度翻译中配置上所需参数
</div>
</template>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
<el-icon class="ml-3 cursor-pointer"
><QuestionFilled
/></el-icon>
</el-tooltip>
</el-form-item>
</el-col>
</el-row> -->
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item
label="隐藏不需要元素模块"
prop="mjHideNotBlock"
label-width="150"
>
<el-switch
v-model="formInline.mjHideNotBlock"
active-value="1"
inactive-value="0"
/>
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px">
隐藏客户端绘图页面的不需要的元素模块隐藏后用户不可选择无法选中模块
</div>
</template>
<el-icon class="ml-3 cursor-pointer"
><QuestionFilled
/></el-icon>
</el-tooltip>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="隐藏不需要元素模块" prop="mjHideNotBlock" label-width="150" >
<el-switch
v-model="formInline.mjHideNotBlock"
active-value="1"
inactive-value="0"
/>
<el-tooltip
class="box-item"
effect="dark"
placement="right"
>
<template #content>
<div style="width: 250px;">
隐藏客户端绘图页面的不需要的元素模块隐藏后用户不可选择无法选中模块
</div>
</template>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="隐藏工作中内容模块" prop="mjHideWorkIn" label-width="150" >
<el-switch
<el-form-item
label="隐藏工作中内容模块"
prop="mjHideWorkIn"
label-width="150"
>
<el-switch
v-model="formInline.mjHideWorkIn"
active-value="1"
inactive-value="0"
/>
<el-tooltip
class="box-item"
effect="dark"
placement="right"
>
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px;">
<div style="width: 250px">
客户端绘图页面隐藏掉工作中模块将不再展示给用户此模块
</div>
</template>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
<el-icon class="ml-3 cursor-pointer"
><QuestionFilled
/></el-icon>
</el-tooltip>
</el-form-item>
</el-col>
</el-row>
<el-divider />
<h4>图片存储设置</h4>
<el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="不存储图片" prop="mjNotSaveImg">
@@ -195,28 +252,35 @@ onMounted(() => {
active-value="1"
inactive-value="0"
/>
<el-tooltip
class="box-item"
effect="dark"
placement="right"
>
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px;">
<div style="width: 250px">
默认会存储图片到配置的存储中如果开启此选择则表示不保存原图到我们配置的存储上那么则必须配置一个图片反代地址直接反代访问原始图片这样可以进一步节省空间需要您部署mj-proxy项目并填写基础地址即可
</div>
</template>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
<el-icon class="ml-3 cursor-pointer"
><QuestionFilled
/></el-icon>
</el-tooltip>
</el-form-item>
</el-col>
</el-row>
<el-row>
<!-- <el-row>
<el-col :xs="24" :md="20" :lg="15" :xl="12">
<el-form-item label="图片反代地址" prop="mjProxyImgUrl" label-width="150">
<el-input v-model="formInline.mjProxyImgUrl" placeholder="图片反代地址、用于代理访问图片、此项目请自行部署mj-proxy项目配置其中的地址即可" clearable style="width: 100%;" />
<el-form-item
label="图片反代地址"
prop="mjProxyImgUrl"
label-width="150"
>
<el-input
v-model="formInline.mjProxyImgUrl"
placeholder="图片反代地址、用于代理访问图片、此项目请自行部署mj-proxy项目配置其中的地址即可"
clearable
style="width: 100%"
/>
</el-form-item>
</el-col>
</el-row>
</el-row> -->
</el-form>
</el-card>
</div>

View File

@@ -10,13 +10,13 @@ import ApiModels from '@/api/modules/models'
import { utcToShanghaiTime } from '@/utils/utcformatTime'
import {
DEDUCTTYPELIST,
MODELSMAP,
MODELSMAPLIST,
MODELTYPELIST,
MODEL_LIST,
ModelTypeLabelMap,
QUESTION_STATUS_OPTIONS,
MODELTYPELIST,
MODELSMAP,
DEDUCTTYPELIST,
MODELSMAPLIST,
} from '@/constants/index'
const formBlukRef = ref<FormInstance>()
@@ -45,16 +45,17 @@ const formPackage = reactive({
status: true,
model: '',
isDraw: false,
isTokenBased: false,
tokenFeeRatio: 1000,
keyWeight: 1,
maxModelTokens: 4096,
modelOrder: 1,
maxModelTokens: 4000,
maxResponseTokens: 2000,
proxyUrl: '',
timeout: 300,
deduct: 1,
deductType: 1,
maxRounds: 12,
isTokenBased: false,
tokenFeeRatio: 1000,
})
const rules = reactive<FormRules>({
@@ -164,8 +165,7 @@ async function queryModelsList() {
const { rows, count } = res.data
total.value = count
tableData.value = rows
}
catch (error) {
} catch (error) {
loading.value = false
}
}
@@ -187,6 +187,7 @@ function handleEditKey(row: any) {
status,
model,
keyWeight,
modelOrder,
maxModelTokens,
maxResponseTokens,
proxyUrl,
@@ -196,7 +197,7 @@ function handleEditKey(row: any) {
maxRounds,
isDraw,
isTokenBased,
tokenFeeRatio
tokenFeeRatio,
} = row
nextTick(() => {
Object.assign(formPackage, {
@@ -216,7 +217,8 @@ function handleEditKey(row: any) {
maxRounds,
isDraw,
isTokenBased,
tokenFeeRatio
tokenFeeRatio,
modelOrder,
})
})
visible.value = true
@@ -254,7 +256,7 @@ onMounted(() => {
<template>
<div>
<page-main>
<page-main style="padding-bottom:0">
<el-form ref="formRef" :inline="true" :model="formInline">
<el-form-item label="模型类型" prop="model">
<el-select
@@ -303,21 +305,9 @@ onMounted(() => {
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryModelsList">
查询
</el-button>
<el-button @click="handlerReset(formRef)">
重置
</el-button>
<el-button type="primary" @click="queryModelsList"> 查询 </el-button>
<el-button @click="handlerReset(formRef)"> 重置 </el-button>
</el-form-item>
<span style="float: right">
<el-button type="success" @click="visible = true">
添加模型Key
<el-icon class="ml-3">
<Plus />
</el-icon>
</el-button>
</span>
</el-form>
</page-main>
<page-main>
@@ -329,6 +319,12 @@ onMounted(() => {
/>
</page-main>
<page-main style="width: 100%">
<el-button type="success" @click="visible = true" style="margin-bottom:20px">
添加模型Key
<el-icon class="ml-3">
<Plus />
</el-icon>
</el-button>
<el-table
v-loading="loading"
border
@@ -336,13 +332,19 @@ onMounted(() => {
style="width: 100%"
size="large"
>
<el-table-column prop="keyType" label="模型类型" width="120">
<!-- <el-table-column prop="keyType" label="模型类型" width="120">
<template #default="scope">
<el-tag type="success">
{{ MODELSMAP[scope.row.keyType] }}
</el-tag>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column
prop="modelOrder"
label="模型排序"
width="90"
align="center"
/>
<el-table-column prop="modelName" label="模型名称" width="180" />
<el-table-column
prop="status"
@@ -386,11 +388,10 @@ onMounted(() => {
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="isDraw"
align="center"
label="是否绘画KEY"
label="绘画KEY"
width="120"
>
<template #default="scope">
@@ -402,7 +403,7 @@ onMounted(() => {
<el-table-column
prop="isTokenBased"
align="center"
label="设为Token计费"
label="Token计费"
width="120"
>
<template #default="scope">
@@ -419,7 +420,7 @@ onMounted(() => {
>
<template #default="scope">
<el-tag :type="scope.row.deductType === 1 ? 'success' : 'warning'">
{{ scope.row.deductType === 1 ? '普通余额' : '高级余额' }}
{{ scope.row.deductType === 1 ? '普通积分' : '高级积分' }}
</el-tag>
</template>
</el-table-column>
@@ -431,7 +432,7 @@ onMounted(() => {
>
<template #default="scope">
<el-tag :type="scope.row.deductType === 1 ? 'success' : 'warning'">
{{ `${scope.row.deduct} 余额` }}
{{ `${scope.row.deduct} 积分` }}
</el-tag>
</template>
</el-table-column>
@@ -459,8 +460,8 @@ onMounted(() => {
scope.row.keyStatus === 1
? '正常工作'
: scope.row.keyStatus === -1
? '已被封禁'
: '余额耗尽 '
? '已被封禁'
: '余额耗尽 '
}}
</el-tag>
</template>
@@ -575,7 +576,7 @@ onMounted(() => {
:model="formPackage"
:rules="rules"
>
<el-form-item label="模型类型选择" prop="keyType">
<!-- <el-form-item label="模型类型选择" prop="keyType">
<el-select
v-model="formPackage.keyType"
placeholder="请选择模型类型"
@@ -588,6 +589,27 @@ onMounted(() => {
:value="item.value"
/>
</el-select>
</el-form-item> -->
<el-form-item label="模型中文名称" prop="modelName">
<el-input
v-model="formPackage.modelName"
placeholder="请填写模型中文名称(用户选择的)"
/>
</el-form-item>
<el-form-item label="模型排序" prop="modelOrder">
<el-input
v-model.number="formPackage.modelOrder"
placeholder="模型排序,越大越靠前。"
/>
<!-- <el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px">
填写此配置可以限制用户在选择模型时候的高级配置中的最大上下文轮次可以通过限制此数量减少token的损耗减低上下文的损耗量
如果设置了模型的最大token和返回量那么两个限制会同时生效
</div>
</template>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip> -->
</el-form-item>
<el-form-item label="模型启用状态" prop="status">
<el-switch v-model="formPackage.status" />
@@ -597,23 +619,16 @@ onMounted(() => {
账号启用状态一旦锁定当前key将停止工作
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="模型中文名称" prop="modelName">
<el-input
v-model="formPackage.modelName"
placeholder="请填写模型中文名称(用户选择的)"
/>
</el-form-item>
<el-form-item :label="labelKeyName" prop="key">
<el-input
v-model="formPackage.key"
:type="Number(formPackage.keyType) === 1 ? 'textarea' : 'text'"
:rows="5"
placeholder="请填写模型Key|clientId|AppId"
placeholder="请填写模型Key"
style="width: 95%"
/>
<el-tooltip class="box-item" effect="dark" placement="right">
@@ -622,15 +637,13 @@ onMounted(() => {
不同模型的设置不同例如openai仅设置key即可如果是百度大模型则填写clientId以及同时需要填写secret对于OPENAI模型我们支持批量导入如果您需要批量导入key则一行一个key即可多个key使用换行隔离其余配置将共享多个key可以重复选用默认模型
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item
v-if="[2].includes(Number(formPackage.keyType))"
label="SecretKey"
prop="secret"
v-if="[2].includes(Number(formPackage.keyType))"
>
<el-input
v-model="formPackage.secret"
@@ -643,9 +656,7 @@ onMounted(() => {
不同账号填写的内容不同但是都代表的是Secret秘钥
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="账号关联模型" prop="model">
@@ -670,9 +681,7 @@ onMounted(() => {
给定了部分可选的模型列表你可以可以手动填写您需要调用的模型请确保填写的模型是当前key支持的类型否则可能会在调用中出现不可预知错误
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="模型扣费类型" prop="deductType">
@@ -694,12 +703,10 @@ onMounted(() => {
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px">
设置当前key的扣费类型扣除普通余额或是高级余额
设置当前key的扣费类型扣除普通积分或是高级积分
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="单次扣除金额" prop="deduct">
@@ -711,12 +718,10 @@ onMounted(() => {
<el-tooltip class="box-item" effect="dark" placement="right">
<template #content>
<div style="width: 250px">
设置当前key的单次调用扣除余额建议同模型或名称key设置相同的金额避免扣费发生异常
设置当前key的单次调用扣除积分建议同模型或名称key设置相同的金额避免扣费发生异常
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="上下文限制" prop="maxRounds">
@@ -732,9 +737,7 @@ onMounted(() => {
如果设置了模型的最大token和返回量那么两个限制会同时生效
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="调用轮询权重" prop="keyWeight">
@@ -750,9 +753,7 @@ onMounted(() => {
保证每个key的调用顺序以及限制每次调用的准确次数
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="模型最大Token" prop="maxModelTokens">
@@ -768,9 +769,9 @@ onMounted(() => {
/>
</el-form-item>
<el-form-item
v-if="[1].includes(Number(formPackage.keyType))"
label="调用超时时间"
prop="timeout"
v-if="[1].includes(Number(formPackage.keyType))"
>
<el-input
v-model.number="formPackage.timeout"
@@ -778,9 +779,9 @@ onMounted(() => {
/>
</el-form-item>
<el-form-item
v-if="[1].includes(Number(formPackage.keyType))"
label="设为特殊key"
prop="isDraw"
v-if="[1].includes(Number(formPackage.keyType))"
>
<el-switch v-model="formPackage.isDraw" />
<el-tooltip class="box-item" effect="dark" placement="right">
@@ -789,15 +790,13 @@ onMounted(() => {
基础绘画来自于OPENAI的DALL-E模型所以需要为官方的apiKey请确定至少设置一张key为基础绘画key即可使用绘画功能同时当前版本的mind思维导图和mj联想绘图等功能都会走当前设置的key会后后续版本解除此限制
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item
v-if="[1].includes(Number(formPackage.keyType))"
label="设为token计费"
prop="isTokenBased"
v-if="[1].includes(Number(formPackage.keyType))"
>
<el-switch v-model="formPackage.isTokenBased" />
<el-tooltip class="box-item" effect="dark" placement="right">
@@ -806,12 +805,10 @@ onMounted(() => {
基于 token 计费计费方式为基础消费 * token消耗
</div>
</template>
<el-icon class="ml-3 cursor-pointer">
<QuestionFilled />
</el-icon>
<el-icon class="ml-3 cursor-pointer"><QuestionFilled /></el-icon>
</el-tooltip>
</el-form-item>
<el-form-item label="token计费比例" prop="tokenFeeRatio">
<el-form-item label="token计费比例" prop="tokenFeeRatio">
<el-input
v-model.number="formPackage.tokenFeeRatio"
placeholder="请填写token计费比例"
@@ -827,9 +824,9 @@ onMounted(() => {
</el-tooltip>
</el-form-item>
<el-form-item
v-if="[1].includes(Number(formPackage.keyType))"
label="指定代理地址"
prop="proxyUrl"
v-if="[1].includes(Number(formPackage.keyType))"
>
<el-input
v-model.number="formPackage.proxyUrl"
@@ -848,9 +845,3 @@ onMounted(() => {
</el-dialog>
</div>
</template>
<style scoped>
.el-form--inline .el-form-item {
margin-right: 15px;
}
</style>