【优化】处理不同模型 maxTokens 不一样问题,如果超出会报错
parent
5a3ae2ab7a
commit
5344602346
|
@ -16,7 +16,7 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="模型" prop="modelId">
|
<el-form-item label="模型" prop="modelId">
|
||||||
<el-select v-model="formData.modelId" placeholder="请选择模型">
|
<el-select v-model="formData.modelId" placeholder="请选择模型" @change="handlerChange">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="chatModel in chatModelList"
|
v-for="chatModel in chatModelList"
|
||||||
:key="chatModel.id"
|
:key="chatModel.id"
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
v-model="formData.maxTokens"
|
v-model="formData.maxTokens"
|
||||||
placeholder="请输入回复数 Token 数"
|
placeholder="请输入回复数 Token 数"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="4096"
|
:max="maxTokens"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="上下文数量" prop="maxContexts">
|
<el-form-item label="上下文数量" prop="maxContexts">
|
||||||
|
@ -58,17 +58,18 @@
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import {CommonStatusEnum} from '@/utils/constants'
|
||||||
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
import {ChatModelApi, ChatModelVO} from '@/api/ai/model/chatModel'
|
||||||
import { ChatConversationApi, ChatConversationVO } from '@/api/ai/chat/conversation'
|
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
|
||||||
|
|
||||||
/** AI 聊天对话的更新表单 */
|
/** AI 聊天对话的更新表单 */
|
||||||
defineOptions({ name: 'ChatConversationUpdateForm' })
|
defineOptions({name: 'ChatConversationUpdateForm'})
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const maxTokens = ref(2000) // maxTokens默认2000
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
systemMessage: undefined,
|
systemMessage: undefined,
|
||||||
|
@ -78,11 +79,11 @@ const formData = ref({
|
||||||
maxContexts: undefined
|
maxContexts: undefined
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
modelId: [{ required: true, message: '模型不能为空', trigger: 'blur' }],
|
modelId: [{required: true, message: '模型不能为空', trigger: 'blur'}],
|
||||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
|
status: [{required: true, message: '状态不能为空', trigger: 'blur'}],
|
||||||
temperature: [{ required: true, message: '温度参数不能为空', trigger: 'blur' }],
|
temperature: [{required: true, message: '温度参数不能为空', trigger: 'blur'}],
|
||||||
maxTokens: [{ required: true, message: '回复数 Token 数不能为空', trigger: 'blur' }],
|
maxTokens: [{required: true, message: '回复数 Token 数不能为空', trigger: 'blur'}],
|
||||||
maxContexts: [{ required: true, message: '上下文数量不能为空', trigger: 'blur' }]
|
maxContexts: [{required: true, message: '上下文数量不能为空', trigger: 'blur'}]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
const chatModelList = ref([] as ChatModelVO[]) // 聊天模型列表
|
const chatModelList = ref([] as ChatModelVO[]) // 聊天模型列表
|
||||||
|
@ -109,7 +110,7 @@ const open = async (id: number) => {
|
||||||
// 获得下拉数据
|
// 获得下拉数据
|
||||||
chatModelList.value = await ChatModelApi.getChatModelSimpleList(CommonStatusEnum.ENABLE)
|
chatModelList.value = await ChatModelApi.getChatModelSimpleList(CommonStatusEnum.ENABLE)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({open}) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
@ -142,4 +143,21 @@ const resetForm = () => {
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** model change */
|
||||||
|
const handlerChange = (val) => {
|
||||||
|
const filterModel = chatModelList.value.filter(item => {
|
||||||
|
return item.id === val
|
||||||
|
})[0]
|
||||||
|
|
||||||
|
console.log(filterModel)
|
||||||
|
console.log(filterModel.maxTokens)
|
||||||
|
if (filterModel.maxTokens != null) {
|
||||||
|
maxTokens.value = filterModel.maxTokens
|
||||||
|
formData.value.maxTokens = filterModel.maxTokens
|
||||||
|
} else {
|
||||||
|
maxTokens.value = 2000
|
||||||
|
formData.value.maxTokens = 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue