Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
cherishsince 2024-05-18 22:03:00 +08:00
commit 264cad5301
3 changed files with 49 additions and 48 deletions

View File

@ -71,9 +71,9 @@ export const useFormCreateDesigner = async (designer: Ref) => {
*/
const buildSystemMenu = () => {
// 移除自带的下拉选择器组件,使用 currencySelectRule 替代
designer.value?.removeMenuItem('select')
designer.value?.removeMenuItem('radio')
designer.value?.removeMenuItem('checkbox')
// designer.value?.removeMenuItem('select')
// designer.value?.removeMenuItem('radio')
// designer.value?.removeMenuItem('checkbox')
const components = [userSelectRule, deptSelectRule, dictSelectRule, apiSelectRule0]
const menu: Menu = {
name: 'system',

View File

@ -48,13 +48,29 @@
</el-radio-group>
</el-form-item>
<el-form-item label="温度参数" prop="temperature">
<el-input v-model="formData.temperature" placeholder="请输入温度参数" />
<el-input-number
v-model="formData.temperature"
placeholder="请输入温度参数"
:min="0"
:max="2"
:precision="2"
/>
</el-form-item>
<el-form-item label="回复数 Token 数" prop="maxTokens">
<el-input v-model="formData.maxTokens" placeholder="请输入回复数 Token 数" />
<el-input-number
v-model="formData.maxTokens"
placeholder="请输入回复数 Token 数"
:min="0"
:max="4096"
/>
</el-form-item>
<el-form-item label="上下文数量" prop="maxContexts">
<el-input v-model="formData.maxContexts" placeholder="请输入上下文数量" />
<el-input-number
v-model="formData.maxContexts"
placeholder="请输入上下文数量"
:min="0"
:max="20"
/>
</el-form-item>
</el-form>
<template #footer>

View File

@ -8,10 +8,10 @@
v-loading="formLoading"
>
<el-form-item label="角色名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入角色名称"/>
<el-input v-model="formData.name" placeholder="请输入角色名称" />
</el-form-item>
<el-form-item label="角色头像" prop="avatar">
<UploadImg v-model="formData.avatar" height="60px" width="60px"/>
<UploadImg v-model="formData.avatar" height="60px" width="60px" />
</el-form-item>
<el-form-item label="绑定模型" prop="modelId" v-if="!isUser(formType)">
<el-select v-model="formData.modelId" placeholder="请选择模型" clearable>
@ -24,17 +24,14 @@
</el-select>
</el-form-item>
<el-form-item label="角色类别" prop="category" v-if="!isUser(formType)">
<el-input v-model="formData.category" placeholder="请输入角色类别"/>
<el-input v-model="formData.category" placeholder="请输入角色类别" />
</el-form-item>
<el-form-item label="角色描述" prop="description">
<el-input type="textarea" v-model="formData.description" placeholder="请输入角色描述"/>
<el-input type="textarea" v-model="formData.description" placeholder="请输入角色描述" />
</el-form-item>
<el-form-item label="角色设定" prop="systemMessage">
<el-input type="textarea" v-model="formData.systemMessage" placeholder="请输入角色设定" />
</el-form-item>
<el-form-item label="欢迎语👏🏻" prop="welcomeMessage" v-if="isUser(formType)">
<el-input type="textarea" v-model="formData.welcomeMessage" placeholder="请输入欢迎语"/>
</el-form-item>
<el-form-item label="是否公开" prop="publicStatus" v-if="!isUser(formType)">
<el-radio-group v-model="formData.publicStatus">
<el-radio
@ -47,7 +44,7 @@
</el-radio-group>
</el-form-item>
<el-form-item label="角色排序" prop="sort" v-if="!isUser(formType)">
<el-input-number v-model="formData.sort" placeholder="请输入角色排序" class="!w-1/1"/>
<el-input-number v-model="formData.sort" placeholder="请输入角色排序" class="!w-1/1" />
</el-form-item>
<el-form-item label="开启状态" prop="status" v-if="!isUser(formType)">
<el-radio-group v-model="formData.status">
@ -68,15 +65,15 @@
</Dialog>
</template>
<script setup lang="ts">
import {getIntDictOptions, getBoolDictOptions, DICT_TYPE} from '@/utils/dict'
import {ChatRoleApi, ChatRoleVO} from '@/api/ai/model/chatRole'
import {CommonStatusEnum} from '@/utils/constants'
import {ChatModelApi, ChatModelVO} from '@/api/ai/model/chatModel'
import { getIntDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import { ChatRoleApi, ChatRoleVO } from '@/api/ai/model/chatRole'
import { CommonStatusEnum } from '@/utils/constants'
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
/** AI 聊天角色 表单 */
defineOptions({name: 'ChatRoleForm'})
defineOptions({ name: 'ChatRoleForm' })
const {t} = useI18n() //
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
@ -92,44 +89,36 @@ const formData = ref({
sort: undefined,
description: undefined,
systemMessage: undefined,
welcomeMessage: undefined,
publicStatus: true,
status: CommonStatusEnum.ENABLE
})
//
const isUser = (type: string) => {
return (type === 'my-create' || type === 'my-update')
}
const formRules = ref() // reactive(formRulesObj)
const formRef = ref() // Ref
const chatModelList = ref([] as ChatModelVO[]) //
/** 是否【我】自己创建,私有角色 */
// TODO @fan computed
const isUser = (type: string) => {
return type === 'my-create' || type === 'my-update'
}
// TODO @fan使 formRules
const getFormRules = async (type: string) => {
let formRulesObj = {
name: [{required: true, message: '角色名称不能为空', trigger: 'blur'}],
avatar: [{required: true, message: '角色头像不能为空', trigger: 'blur'}],
category: [{required: true, message: '角色类别不能为空', trigger: 'blur'}],
sort: [{required: true, message: '角色排序不能为空', trigger: 'blur'}],
description: [{required: true, message: '角色描述不能为空', trigger: 'blur'}],
systemMessage: [{required: true, message: '角色设定不能为空', trigger: 'blur'}],
// welcomeMessage: [{ required: true, message: '', trigger: 'blur' }],
publicStatus: [{required: true, message: '是否公开不能为空', trigger: 'blur'}]
}
if (isUser(type)) {
formRulesObj['welcomeMessage'] = [{
required: true,
message: '欢迎语不能为空',
trigger: 'blur'
}]
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
avatar: [{ required: true, message: '角色头像不能为空', trigger: 'blur' }],
category: [{ required: true, message: '角色类别不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '角色排序不能为空', trigger: 'blur' }],
description: [{ required: true, message: '角色描述不能为空', trigger: 'blur' }],
systemMessage: [{ required: true, message: '角色设定不能为空', trigger: 'blur' }],
publicStatus: [{ required: true, message: '是否公开不能为空', trigger: 'blur' }]
}
formRules.value = reactive(formRulesObj)
}
/** 打开弹窗 */
// TODO @fantitle type title
const open = async (type: string, id?: number, title?: string) => {
dialogVisible.value = true
dialogTitle.value = title || t('action.' + type)
@ -148,7 +137,7 @@ const open = async (type: string, id?: number, title?: string) => {
//
chatModelList.value = await ChatModelApi.getChatModelSimpleList(CommonStatusEnum.ENABLE)
}
defineExpose({open}) // open
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
@ -159,10 +148,8 @@ const submitForm = async () => {
formLoading.value = true
try {
const data = formData.value as unknown as ChatRoleVO
// tip: my-createmy-update chat
// tip: createelse
if (formType.value === 'my-create') {
await ChatRoleApi.createMy(data)
message.success(t('common.createSuccess'))
@ -184,7 +171,6 @@ const submitForm = async () => {
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
@ -196,7 +182,6 @@ const resetForm = () => {
sort: undefined,
description: undefined,
systemMessage: undefined,
welcomeMessage: undefined,
publicStatus: true,
status: CommonStatusEnum.ENABLE
}