更新模型类型字段名称,统一为 modelType,以提高代码一致性和可读性。涉及多个组件和接口的相应调整,确保功能正常。
This commit is contained in:
@@ -4,7 +4,7 @@ export interface ModelModuleListParams {
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
modelName?: string;
|
||||
modelsType?: number | string;
|
||||
modelType?: number | string;
|
||||
}
|
||||
|
||||
export interface ModelFormItem {
|
||||
@@ -23,7 +23,7 @@ export interface ModelFormEntry {
|
||||
export interface ModelTypeListItem {
|
||||
id?: number | string;
|
||||
typeId?: number | string;
|
||||
modelsType?: number | string;
|
||||
modelType?: number | string;
|
||||
name?: string;
|
||||
typeName?: string;
|
||||
label?: string;
|
||||
@@ -55,7 +55,7 @@ export function normalizeModelTypeOptions(res: { data?: unknown }): Array<{ id:
|
||||
const arr: ModelTypeListItem[] = Array.isArray(raw) ? raw : ((raw as { list?: ModelTypeListItem[] })?.list ?? []);
|
||||
return arr
|
||||
.map((item) => {
|
||||
const id = item.id ?? item.typeId ?? item.modelsType;
|
||||
const id = item.id ?? item.typeId ?? item.modelType;
|
||||
const label = item.name ?? item.typeName ?? item.label ?? (id != null && id !== '' ? String(id) : '');
|
||||
return { id: id as number | string, label: label || String(id) };
|
||||
})
|
||||
@@ -73,7 +73,7 @@ export interface ModelModuleItem {
|
||||
isDeleted?: boolean;
|
||||
modelName: string;
|
||||
/** 模型类型 ID,与 listType 返回项对应 */
|
||||
modelsType?: number | string;
|
||||
modelType?: number | string;
|
||||
baseUrl: string;
|
||||
route?: string;
|
||||
httpMethod: string;
|
||||
@@ -110,7 +110,7 @@ export interface ModelModuleListResponse {
|
||||
export interface CreateModelParams {
|
||||
modelName: string;
|
||||
/** 与 listType 返回的类型 id 一致,可能为数字或字符串 */
|
||||
modelsType: number | string;
|
||||
modelType: number | string;
|
||||
baseUrl: string;
|
||||
httpMethod?: string;
|
||||
headMsg?: string;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
@click="handleSelectModel(model)"
|
||||
>
|
||||
<div class="model-card-header">
|
||||
<div class="model-type">{{ getModelTypeName(model.modelsType) }}</div>
|
||||
<div class="model-type">{{ getModelTypeName(model.modelType) }}</div>
|
||||
<div class="model-badges">
|
||||
<el-tag v-if="!model.apiKey" type="warning" size="small">内置模型</el-tag>
|
||||
<el-icon v-if="selectedModel?.id === model.id" class="check-icon" color="#67c23a"><CircleCheck /></el-icon>
|
||||
@@ -101,7 +101,7 @@ interface ModelItem {
|
||||
id: string;
|
||||
tenantId?: number;
|
||||
modelName: string;
|
||||
modelsType: number;
|
||||
modelType: number;
|
||||
baseUrl: string;
|
||||
route: string;
|
||||
httpMethod: string;
|
||||
@@ -264,7 +264,7 @@ const handleCreatePrivateModel = async () => {
|
||||
const systemModel = systemModelToClone.value;
|
||||
const createParams = {
|
||||
modelName: apiKeyForm.modelName,
|
||||
modelsType: systemModel.modelsType,
|
||||
modelType: systemModel.modelType,
|
||||
baseUrl: systemModel.baseUrl,
|
||||
httpMethod: systemModel.httpMethod || 'POST',
|
||||
headMsg: systemModel.headMsg || '',
|
||||
|
||||
@@ -445,7 +445,12 @@
|
||||
<div class="workflow-list-vertical" v-loading="workflowListLoading">
|
||||
<el-empty v-if="!workflowListLoading && templateWorkflowList.length === 0" description="暂无模板" :image-size="60" />
|
||||
<div v-else class="workflow-list-scroll">
|
||||
<div v-for="workflow in templateWorkflowList" :key="workflow.id" class="workflow-item" @click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)">
|
||||
<div
|
||||
v-for="workflow in templateWorkflowList"
|
||||
:key="workflow.id"
|
||||
class="workflow-item"
|
||||
@click="isSuperAdmin ? editWorkflow(workflow) : useWorkflow(workflow)"
|
||||
>
|
||||
<div class="workflow-item-content">
|
||||
<div class="workflow-item-name">{{ workflow.flowName || workflow.flowTemplateName }}</div>
|
||||
<div class="workflow-item-desc">{{ workflow.description || '暂无描述' }}</div>
|
||||
@@ -520,12 +525,14 @@
|
||||
v-for="model in filteredChatModels"
|
||||
:key="model.id"
|
||||
class="chat-model-card"
|
||||
:class="{ selected: selectedChatModel?.id === model.id }"
|
||||
:class="{ selected: selectedChatModel?.id === model.id, 'is-chat-model': model.isChatModel === 1 }"
|
||||
@click="selectedChatModel = model"
|
||||
>
|
||||
<div class="chat-model-name">{{ model.modelName }}</div>
|
||||
<div class="chat-model-url">{{ model.baseUrl }}</div>
|
||||
<el-icon v-if="selectedChatModel?.id === model.id" class="check-icon" color="#67c23a"><CircleCheck /></el-icon>
|
||||
<el-icon v-if="selectedChatModel?.id === model.id || model.isChatModel === 1" class="check-icon" color="#67c23a"
|
||||
><CircleCheck
|
||||
/></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1010,7 +1017,7 @@ const fetchChatModelList = async () => {
|
||||
const res: any = await getModelModuleList({
|
||||
pageNum: chatModelPagination.pageNum,
|
||||
pageSize: chatModelPagination.pageSize,
|
||||
modelsType: 1, // 传递 modelsType=1 给后端,获取推理模型
|
||||
modelType: 1, // 传递 modelType=1 给后端,获取推理模型
|
||||
modelName: chatModelSearchKeyword.value || undefined,
|
||||
});
|
||||
chatModelList.value = res.data?.list || [];
|
||||
@@ -2385,7 +2392,7 @@ onMounted(async () => {
|
||||
initLogicFlow();
|
||||
await getNodeLibrary();
|
||||
await fetchWorkflowList();
|
||||
|
||||
|
||||
// 获取当前用户角色
|
||||
try {
|
||||
const res: any = await checkIsSuperAdmin();
|
||||
@@ -3562,7 +3569,8 @@ onBeforeUnmount(() => {
|
||||
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.chat-model-card.selected {
|
||||
.chat-model-card.selected,
|
||||
.chat-model-card.is-chat-model {
|
||||
border-color: #67c23a;
|
||||
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
|
||||
box-shadow: 0 4px 12px rgba(103, 194, 58, 0.2);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="模型类型" prop="modelsType">
|
||||
<el-select v-model="state.ruleForm.modelsType" placeholder="请选择模型类型" clearable style="width: 100%">
|
||||
<el-form-item label="模型类型" prop="modelType">
|
||||
<el-select v-model="state.ruleForm.modelType" placeholder="请选择模型类型" clearable style="width: 100%">
|
||||
<el-option v-for="t in modelTypeOptions" :key="String(t.id)" :label="t.label" :value="typeOptionValue(t.id)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -279,7 +279,7 @@ const state = reactive({
|
||||
ruleForm: {
|
||||
id: '',
|
||||
modelName: '',
|
||||
modelsType: null as number | string | null,
|
||||
modelType: null as number | string | null,
|
||||
baseUrl: '',
|
||||
httpMethod: 'POST',
|
||||
headMsg: '',
|
||||
@@ -299,7 +299,7 @@ const state = reactive({
|
||||
},
|
||||
rules: {
|
||||
modelName: [{ required: true, message: '请输入模型名称', trigger: 'blur' }],
|
||||
modelsType: [
|
||||
modelType: [
|
||||
{
|
||||
validator: (_rule: unknown, value: unknown, callback: (e?: Error) => void) => {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
@@ -528,7 +528,7 @@ const fillFormFromDetailRow = (row: Record<string, unknown>) => {
|
||||
state.ruleForm = {
|
||||
id: row.id as string,
|
||||
modelName: String(row.modelName ?? ''),
|
||||
modelsType: row.modelsType !== undefined && row.modelsType !== null ? typeOptionValue(row.modelsType as number | string) : null,
|
||||
modelType: row.modelType !== undefined && row.modelType !== null ? typeOptionValue(row.modelType as number | string) : null,
|
||||
baseUrl: String(row.baseUrl ?? ''),
|
||||
httpMethod: String(row.httpMethod || 'POST'),
|
||||
headMsg: String(row.headMsg || ''),
|
||||
@@ -605,7 +605,7 @@ const openDialog = async (type: string, row?: Record<string, unknown>) => {
|
||||
state.ruleForm = {
|
||||
id: '',
|
||||
modelName: '',
|
||||
modelsType: null,
|
||||
modelType: null,
|
||||
baseUrl: '',
|
||||
httpMethod: 'POST',
|
||||
headMsg: '',
|
||||
@@ -659,7 +659,7 @@ const onSubmit = () => {
|
||||
const responseBody = responseBodyField ? { [responseBodyField.key.trim()]: responseBodyField.value } : {};
|
||||
const submitData = {
|
||||
modelName: state.ruleForm.modelName,
|
||||
modelsType: state.ruleForm.modelsType as number | string,
|
||||
modelType: state.ruleForm.modelType as number | string,
|
||||
baseUrl: state.ruleForm.baseUrl,
|
||||
httpMethod: state.ruleForm.httpMethod || 'POST',
|
||||
headMsg: state.ruleForm.headMsg,
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<el-table-column prop="modelName" label="模型名称" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="模型类型" width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ resolveModelTypeLabel(row.modelsType) }}
|
||||
{{ resolveModelTypeLabel(row.modelType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="baseUrl" label="模型服务地址" show-overflow-tooltip width="200"></el-table-column> -->
|
||||
@@ -59,7 +59,7 @@
|
||||
<!-- 非管理员才显示会话模型按钮 -->
|
||||
<template v-if="!isSuperAdmin">
|
||||
<el-button
|
||||
v-if="isInferenceModel(scope.row.modelsType) && Number(scope.row.isChatModel) !== 1"
|
||||
v-if="isInferenceModel(scope.row.modelType) && Number(scope.row.isChatModel) !== 1"
|
||||
size="small"
|
||||
text
|
||||
type="warning"
|
||||
@@ -68,7 +68,7 @@
|
||||
设为会话模型
|
||||
</el-button>
|
||||
<el-tag
|
||||
v-if="isInferenceModel(scope.row.modelsType) && Number(scope.row.isChatModel) === 1"
|
||||
v-if="isInferenceModel(scope.row.modelType) && Number(scope.row.isChatModel) === 1"
|
||||
type="success"
|
||||
effect="dark"
|
||||
size="default"
|
||||
@@ -181,13 +181,13 @@ const checkAdminStatus = async () => {
|
||||
};
|
||||
|
||||
// 判断是否为推理模型(只有推理模型才能设置为会话模型)
|
||||
const isInferenceModel = (modelsType: number | string | undefined | null) => {
|
||||
if (modelsType === undefined || modelsType === null || modelsType === '') {
|
||||
const isInferenceModel = (modelType: number | string | undefined | null) => {
|
||||
if (modelType === undefined || modelType === null || modelType === '') {
|
||||
return false;
|
||||
}
|
||||
// 查找模型类型标签,判断是否为"推理模型"
|
||||
const typeInfo = state.modelTypes.find((t) => String(t.id) === String(modelsType));
|
||||
return typeInfo?.label === '推理模型' || String(modelsType) === '1';
|
||||
const typeInfo = state.modelTypes.find((t) => String(t.id) === String(modelType));
|
||||
return typeInfo?.label === '推理模型' || String(modelType) === '1';
|
||||
};
|
||||
|
||||
// 设置为会话模型
|
||||
@@ -227,7 +227,7 @@ const handleCreatePrivateModelAndSetChat = async () => {
|
||||
const systemModel = systemModelToClone.value;
|
||||
const createParams = {
|
||||
modelName: apiKeyForm.modelName,
|
||||
modelsType: systemModel.modelsType,
|
||||
modelType: systemModel.modelType,
|
||||
baseUrl: systemModel.baseUrl,
|
||||
httpMethod: systemModel.httpMethod || 'POST',
|
||||
headMsg: systemModel.headMsg || '',
|
||||
@@ -266,12 +266,12 @@ const handleCreatePrivateModelAndSetChat = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const resolveModelTypeLabel = (modelsType: number | string | undefined | null) => {
|
||||
if (modelsType === undefined || modelsType === null || modelsType === '') {
|
||||
const resolveModelTypeLabel = (modelType: number | string | undefined | null) => {
|
||||
if (modelType === undefined || modelType === null || modelType === '') {
|
||||
return '—';
|
||||
}
|
||||
const hit = state.modelTypes.find((t) => String(t.id) === String(modelsType));
|
||||
return hit?.label ?? String(modelsType);
|
||||
const hit = state.modelTypes.find((t) => String(t.id) === String(modelType));
|
||||
return hit?.label ?? String(modelType);
|
||||
};
|
||||
|
||||
const loadModelTypes = async () => {
|
||||
|
||||
Reference in New Issue
Block a user