【新增】AI:API 模型管理(完善)
This commit is contained in:
parent
b19d56ad02
commit
dd2c4b6b3c
@ -17,6 +17,11 @@ export const ApiKeyApi = {
|
|||||||
return await request.get({ url: `/ai/api-key/page`, params })
|
return await request.get({ url: `/ai/api-key/page`, params })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 获得 API 密钥列表
|
||||||
|
getApiKeyList: async () => {
|
||||||
|
return await request.get({ url: `/ai/api-key/simple-list` })
|
||||||
|
},
|
||||||
|
|
||||||
// 查询 API 密钥详情
|
// 查询 API 密钥详情
|
||||||
getApiKey: async (id: number) => {
|
getApiKey: async (id: number) => {
|
||||||
return await request.get({ url: `/ai/api-key/get?id=` + id })
|
return await request.get({ url: `/ai/api-key/get?id=` + id })
|
||||||
|
@ -7,13 +7,7 @@
|
|||||||
label-width="120px"
|
label-width="120px"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
>
|
>
|
||||||
<el-form-item label="名称" prop="name">
|
<el-form-item label="所属平台" prop="platform">
|
||||||
<el-input v-model="formData.name" placeholder="请输入名称" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="密钥" prop="apiKey">
|
|
||||||
<el-input v-model="formData.apiKey" placeholder="请输入密钥" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="平台" prop="platform">
|
|
||||||
<el-select v-model="formData.platform" placeholder="请输入平台" clearable>
|
<el-select v-model="formData.platform" placeholder="请输入平台" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getStrDictOptions(DICT_TYPE.AI_PLATFORM)"
|
v-for="dict in getStrDictOptions(DICT_TYPE.AI_PLATFORM)"
|
||||||
@ -23,8 +17,14 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="自定义 API 地址" prop="url">
|
<el-form-item label="名称" prop="name">
|
||||||
<el-input v-model="formData.url" placeholder="请输入自定义 API 地址" />
|
<el-input v-model="formData.name" placeholder="请输入名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="密钥" prop="apiKey">
|
||||||
|
<el-input v-model="formData.apiKey" placeholder="请输入密钥" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义 API URL" prop="url">
|
||||||
|
<el-input v-model="formData.url" placeholder="请输入自定义 API URL" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="formData.status">
|
<el-radio-group v-model="formData.status">
|
||||||
|
@ -60,15 +60,14 @@
|
|||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
<el-table-column label="编号" align="center" prop="id" />
|
<el-table-column label="所属平台" align="center" prop="platform">
|
||||||
<el-table-column label="名称" align="center" prop="name" />
|
|
||||||
<el-table-column label="密钥" align="center" prop="apiKey" />
|
|
||||||
<el-table-column label="平台" align="center" prop="platform">
|
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.AI_PLATFORM" :value="scope.row.platform" />
|
<dict-tag :type="DICT_TYPE.AI_PLATFORM" :value="scope.row.platform" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="自定义 API 地址" align="center" prop="url" />
|
<el-table-column label="名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="密钥" align="center" prop="apiKey" />
|
||||||
|
<el-table-column label="自定义 API URL" align="center" prop="url" />
|
||||||
<el-table-column label="状态" align="center" prop="status">
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
|
@ -7,8 +7,25 @@
|
|||||||
label-width="120px"
|
label-width="120px"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
>
|
>
|
||||||
<el-form-item label="API 秘钥编号" prop="keyId">
|
<el-form-item label="所属平台" prop="platform">
|
||||||
<el-input v-model="formData.keyId" placeholder="请输入API 秘钥编号" />
|
<el-select v-model="formData.platform" placeholder="请输入平台" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.AI_PLATFORM)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="API 秘钥" prop="keyId">
|
||||||
|
<el-select v-model="formData.keyId" placeholder="请选择 API 秘钥" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="apiKey in apiKeyList"
|
||||||
|
:key="apiKey.id"
|
||||||
|
:label="apiKey.name"
|
||||||
|
:value="apiKey.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="模型名字" prop="name">
|
<el-form-item label="模型名字" prop="name">
|
||||||
<el-input v-model="formData.name" placeholder="请输入模型名字" />
|
<el-input v-model="formData.name" placeholder="请输入模型名字" />
|
||||||
@ -16,15 +33,18 @@
|
|||||||
<el-form-item label="模型标识" prop="model">
|
<el-form-item label="模型标识" prop="model">
|
||||||
<el-input v-model="formData.model" placeholder="请输入模型标识" />
|
<el-input v-model="formData.model" placeholder="请输入模型标识" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="模型平台" prop="platform">
|
|
||||||
<el-input v-model="formData.platform" placeholder="请输入模型平台" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input v-model="formData.sort" placeholder="请输入排序" />
|
<el-input v-model="formData.sort" placeholder="请输入排序" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="formData.status">
|
<el-radio-group v-model="formData.status">
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
<el-radio
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="温度参数" prop="temperature">
|
<el-form-item label="温度参数" prop="temperature">
|
||||||
@ -45,7 +65,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
||||||
|
import { ApiKeyApi, ApiKeyVO } from '@/api/ai/model/apiKey'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
|
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||||
|
|
||||||
/** API 聊天模型 表单 */
|
/** API 聊天模型 表单 */
|
||||||
defineOptions({ name: 'ChatModelForm' })
|
defineOptions({ name: 'ChatModelForm' })
|
||||||
@ -70,14 +92,15 @@ const formData = ref({
|
|||||||
maxContexts: undefined
|
maxContexts: undefined
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
keyId: [{ required: true, message: 'API 秘钥编号不能为空', trigger: 'blur' }],
|
keyId: [{ required: true, message: 'API 秘钥不能为空', trigger: 'blur' }],
|
||||||
name: [{ required: true, message: '模型名字不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '模型名字不能为空', trigger: 'blur' }],
|
||||||
model: [{ required: true, message: '模型标识不能为空', trigger: 'blur' }],
|
model: [{ required: true, message: '模型标识不能为空', trigger: 'blur' }],
|
||||||
platform: [{ required: true, message: '模型平台不能为空', trigger: 'blur' }],
|
platform: [{ required: true, message: '所属平台不能为空', trigger: 'blur' }],
|
||||||
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
|
||||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const apiKeyList = ref([] as ApiKeyVO[]) // API 密钥列表
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
@ -94,6 +117,8 @@ const open = async (type: string, id?: number) => {
|
|||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 获得下拉数据
|
||||||
|
apiKeyList.value = await ApiKeyApi.getApiKeyList(CommonStatusEnum.ENABLE)
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
@ -53,23 +53,27 @@
|
|||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
<el-table-column label="编号" align="center" prop="id" />
|
<el-table-column label="所属平台" align="center" prop="platform">
|
||||||
<el-table-column label="API 秘钥编号" align="center" prop="keyId" />
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.AI_PLATFORM" :value="scope.row.platform" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="模型名字" align="center" prop="name" />
|
<el-table-column label="模型名字" align="center" prop="name" />
|
||||||
<el-table-column label="模型标识" align="center" prop="model" />
|
<el-table-column label="模型标识" align="center" prop="model" />
|
||||||
<el-table-column label="模型平台" align="center" prop="platform" />
|
<el-table-column label="API 秘钥" align="center" prop="keyId" min-width="140">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ apiKeyList.find((item) => item.id === scope.row.keyId)?.name }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="排序" align="center" prop="sort" />
|
<el-table-column label="排序" align="center" prop="sort" />
|
||||||
<el-table-column label="状态" align="center" prop="status" />
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="温度参数" align="center" prop="temperature" />
|
<el-table-column label="温度参数" align="center" prop="temperature" />
|
||||||
<el-table-column label="回复数 Token 数" align="center" prop="maxTokens" />
|
<el-table-column label="回复数 Token 数" align="center" prop="maxTokens" min-width="140" />
|
||||||
<el-table-column label="上下文数量" align="center" prop="maxContexts" />
|
<el-table-column label="上下文数量" align="center" prop="maxContexts" />
|
||||||
<el-table-column
|
|
||||||
label="创建时间"
|
|
||||||
align="center"
|
|
||||||
prop="createTime"
|
|
||||||
:formatter="dateFormatter"
|
|
||||||
width="180px"
|
|
||||||
/>
|
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
@ -106,9 +110,10 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import download from '@/utils/download'
|
|
||||||
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
import { ChatModelApi, ChatModelVO } from '@/api/ai/model/chatModel'
|
||||||
import ChatModelForm from './ChatModelForm.vue'
|
import ChatModelForm from './ChatModelForm.vue'
|
||||||
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { ApiKeyApi, ApiKeyVO } from '@/api/ai/model/apiKey'
|
||||||
|
|
||||||
/** API 聊天模型 列表 */
|
/** API 聊天模型 列表 */
|
||||||
defineOptions({ name: 'AiChatModel' })
|
defineOptions({ name: 'AiChatModel' })
|
||||||
@ -127,7 +132,7 @@ const queryParams = reactive({
|
|||||||
platform: undefined
|
platform: undefined
|
||||||
})
|
})
|
||||||
const queryFormRef = ref() // 搜索的表单
|
const queryFormRef = ref() // 搜索的表单
|
||||||
const exportLoading = ref(false) // 导出的加载中
|
const apiKeyList = ref([] as ApiKeyVO[]) // API 密钥列表
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
@ -173,7 +178,9 @@ const handleDelete = async (id: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
getList()
|
getList()
|
||||||
|
// 获得下拉数据
|
||||||
|
apiKeyList.value = await ApiKeyApi.getApiKeyList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user