mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-09 18:53:43 +08:00
feat: 支持文心4.0模型,不同的用户可以订阅不同的AI模型
This commit is contained in:
10
web/src/assets/css/admin-form.css
Normal file
10
web/src/assets/css/admin-form.css
Normal file
@@ -0,0 +1,10 @@
|
||||
.el-form-item__content .tip-input {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
.el-form-item__content .tip-input .input {
|
||||
width: 100%;
|
||||
}
|
||||
.el-form-item__content .tip-input .info {
|
||||
margin-left: 6px;
|
||||
}
|
||||
15
web/src/assets/css/admin-form.styl
Normal file
15
web/src/assets/css/admin-form.styl
Normal file
@@ -0,0 +1,15 @@
|
||||
.el-form-item__content {
|
||||
.tip-input {
|
||||
display flex
|
||||
width 100%
|
||||
|
||||
.input {
|
||||
width 100%
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-left 6px
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.page-mj .inner .task-list-box .finish-job-list .job-item:hover {
|
||||
.page-mj .inner .task-list-box .finish-job-list .animate:hover {
|
||||
box-shadow: 0 0 10px rgba(71,255,241,0.6); /* 添加阴影效果 */
|
||||
transform: translateY(-10px); /* 向上移动10像素 */
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.page-sd .inner .task-list-box .finish-job-list .job-item:hover {
|
||||
.page-sd .inner .task-list-box .finish-job-list .animate:hover {
|
||||
box-shadow: 0 0 10px rgba(71,255,241,0.6); /* 添加阴影效果 */
|
||||
transform: translateY(-10px); /* 向上移动10像素 */
|
||||
}
|
||||
|
||||
@@ -80,8 +80,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.animate {
|
||||
&:hover {
|
||||
box-shadow: 0 0 10px rgba(71, 255, 241, 0.6); /* 添加阴影效果 */
|
||||
transform: translateY(-10px); /* 向上移动10像素 */
|
||||
|
||||
@@ -332,7 +332,7 @@
|
||||
<div class="finish-job-list">
|
||||
<ItemList :items="finishedJobs" v-if="finishedJobs.length > 0" width="240" :gap="16">
|
||||
<template #default="scope">
|
||||
<div class="job-item" @click="showTask(scope.item)">
|
||||
<div class="job-item animate" @click="showTask(scope.item)">
|
||||
<el-image
|
||||
:src="scope.item['img_url']+'?imageView2/1/w/240/h/240/q/75'"
|
||||
fit="cover"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="模型名称"/>
|
||||
<el-table-column prop="value" label="模型值"/>
|
||||
<el-table-column prop="weight" label="对话权重"/>
|
||||
<el-table-column prop="enabled" label="启用状态">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row['enabled']" @change="enable(scope.row)"/>
|
||||
@@ -59,6 +60,27 @@
|
||||
<el-input v-model="item.value" autocomplete="off"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="对话权重:" prop="weight">
|
||||
|
||||
<template #default>
|
||||
<div class="tip-input">
|
||||
<el-input-number :min="1" v-model="item.weight" autocomplete="off"/>
|
||||
<div class="info">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="对话权重,每次对话扣减多少次对话额度"
|
||||
placement="right"
|
||||
>
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="启用状态:" prop="enable">
|
||||
<el-switch v-model="item.enabled"/>
|
||||
</el-form-item>
|
||||
@@ -79,7 +101,7 @@ import {onMounted, reactive, ref} from "vue";
|
||||
import {httpGet, httpPost} from "@/utils/http";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {dateFormat, removeArrayItem} from "@/utils/libs";
|
||||
import {Plus} from "@element-plus/icons-vue";
|
||||
import {InfoFilled, Plus} from "@element-plus/icons-vue";
|
||||
import {Sortable} from "sortablejs";
|
||||
|
||||
// 变量定义
|
||||
@@ -136,9 +158,11 @@ onMounted(() => {
|
||||
sortedData.forEach((id, index) => {
|
||||
ids.push(parseInt(id))
|
||||
sorts.push(index)
|
||||
items.value[index].sort_num = index
|
||||
})
|
||||
|
||||
httpPost("/api/admin/model/sort", {ids: ids, sorts: sorts}).catch(e => {
|
||||
httpPost("/api/admin/model/sort", {ids: ids, sorts: sorts}).then(() => {
|
||||
}).catch(e => {
|
||||
ElMessage.error("排序失败:" + e.message)
|
||||
})
|
||||
}
|
||||
@@ -148,7 +172,7 @@ onMounted(() => {
|
||||
const add = function () {
|
||||
title.value = "新增模型"
|
||||
showDialog.value = true
|
||||
item.value = {}
|
||||
item.value = {enabled: true, weight: 1}
|
||||
}
|
||||
|
||||
const edit = function (row) {
|
||||
@@ -197,6 +221,7 @@ const remove = function (row) {
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import "@/assets/css/admin-form.styl"
|
||||
.list {
|
||||
|
||||
.opt-box {
|
||||
|
||||
@@ -87,6 +87,38 @@
|
||||
</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.value"
|
||||
/>
|
||||
</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>
|
||||
<el-button type="primary" @click="save('system')">保存</el-button>
|
||||
</el-form-item>
|
||||
@@ -198,6 +230,7 @@ const chat = ref({
|
||||
const loading = ref(true)
|
||||
const systemFormRef = ref(null)
|
||||
const chatFormRef = ref(null)
|
||||
const models = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
// 加载系统配置
|
||||
@@ -233,6 +266,12 @@ onMounted(() => {
|
||||
ElMessage.error("加载聊天配置失败: " + e.message)
|
||||
})
|
||||
|
||||
httpGet('/api/admin/model/list').then(res => {
|
||||
models.value = res.data
|
||||
}).catch(e => {
|
||||
ElMessage.error("获取模型失败:" + e.message)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
const rules = reactive({
|
||||
@@ -293,6 +332,7 @@ const uploadRewardImg = (file) => {
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import "@/assets/css/admin-form.styl"
|
||||
.system-config {
|
||||
display flex
|
||||
justify-content center
|
||||
|
||||
@@ -104,6 +104,23 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="模型权限" prop="chat_models">
|
||||
<el-select
|
||||
v-model="user.chat_models"
|
||||
multiple
|
||||
:filterable="true"
|
||||
placeholder="选择AI模型,多选"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in models"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="启用状态">
|
||||
<el-switch v-model="user.status"/>
|
||||
</el-form-item>
|
||||
@@ -155,9 +172,10 @@ const query = ref({username: '', mobile: '', page: 1, page_size: 15})
|
||||
|
||||
const title = ref('添加用户')
|
||||
const add = ref(true)
|
||||
const user = ref({chat_roles: []})
|
||||
const user = ref({chat_roles: [], chat_models: []})
|
||||
const pass = ref({username: '', password: '', id: 0})
|
||||
const roles = ref([])
|
||||
const models = ref([])
|
||||
const showUserEditDialog = ref(false)
|
||||
const showResetPassDialog = ref(false)
|
||||
const rules = reactive({
|
||||
@@ -170,6 +188,7 @@ const rules = reactive({
|
||||
{type: 'number', message: '请输入有效数字'},
|
||||
],
|
||||
chat_roles: [{required: true, message: '请选择聊天角色', trigger: 'change'}],
|
||||
chat_models: [{required: true, message: '请选择AI模型', trigger: 'change'}],
|
||||
})
|
||||
const loading = ref(true)
|
||||
|
||||
@@ -183,6 +202,12 @@ onMounted(() => {
|
||||
}).catch(() => {
|
||||
ElMessage.error("获取聊天角色失败");
|
||||
})
|
||||
|
||||
httpGet('/api/admin/model/list').then(res => {
|
||||
models.value = res.data
|
||||
}).catch(e => {
|
||||
ElMessage.error("获取模型失败:" + e.message)
|
||||
})
|
||||
})
|
||||
|
||||
const fetchUserList = function (page, pageSize) {
|
||||
|
||||
Reference in New Issue
Block a user