|
@@ -1,14 +1,17 @@
|
|
|
<script lang="ts" setup>
|
|
|
- import { h, reactive, ref, toRaw } from 'vue';
|
|
|
+ import { h, reactive, ref } from 'vue';
|
|
|
import { BasicTable, TableAction } from '@/components/Table';
|
|
|
import { DeleteOutlined, EditOutlined, PlusOutlined } from '@vicons/antd';
|
|
|
import { columns, LLMProviders } from './data';
|
|
|
import Edit from './edit.vue';
|
|
|
- import { list } from '@/api/aigc/model';
|
|
|
+ import { del, list } from '@/api/aigc/model';
|
|
|
+ import { useDialog, useMessage } from 'naive-ui';
|
|
|
|
|
|
+ const message = useMessage();
|
|
|
+ const dialog = useDialog();
|
|
|
const actionRef = ref();
|
|
|
const editRef = ref();
|
|
|
- const expands = ref([]);
|
|
|
+ const provider = ref('');
|
|
|
const actionColumn = reactive({
|
|
|
width: 100,
|
|
|
title: '操作',
|
|
@@ -16,19 +19,6 @@
|
|
|
fixed: 'right',
|
|
|
align: 'center',
|
|
|
render(record: any) {
|
|
|
- const providers = LLMProviders.map((i) => i.model);
|
|
|
- if (providers.includes(toRaw(record).model)) {
|
|
|
- return h(TableAction as any, {
|
|
|
- style: 'text',
|
|
|
- actions: [
|
|
|
- {
|
|
|
- type: 'success',
|
|
|
- icon: PlusOutlined,
|
|
|
- onClick: handleAdd.bind(null, { provider: record.model }),
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
- }
|
|
|
return h(TableAction as any, {
|
|
|
style: 'text',
|
|
|
actions: [
|
|
@@ -48,23 +38,14 @@
|
|
|
});
|
|
|
|
|
|
const loadDataTable = async (params: any) => {
|
|
|
- const models = await list({ ...params });
|
|
|
- const data: any[] = [];
|
|
|
- LLMProviders.forEach((i) => {
|
|
|
- const children = models.filter((m) => m.provider == i.model);
|
|
|
- console.log(children);
|
|
|
- data.push({
|
|
|
- model: i.model,
|
|
|
- name: i.name,
|
|
|
- type: 'expand',
|
|
|
- expandable: true,
|
|
|
- children: children,
|
|
|
- });
|
|
|
- });
|
|
|
- return data;
|
|
|
+ if (provider.value === '') {
|
|
|
+ provider.value = LLMProviders[0].model;
|
|
|
+ }
|
|
|
+
|
|
|
+ return await list({ ...params, provider: provider.value });
|
|
|
};
|
|
|
- function handleAdd(record: any) {
|
|
|
- editRef.value.show(record);
|
|
|
+ function handleAdd() {
|
|
|
+ editRef.value.show({ provider: provider.value });
|
|
|
}
|
|
|
|
|
|
function handleEdit(record: any) {
|
|
@@ -75,37 +56,66 @@
|
|
|
actionRef.value.reload();
|
|
|
}
|
|
|
|
|
|
- function handleDel(record: any) {}
|
|
|
+ function handleDel(record: any) {
|
|
|
+ dialog.warning({
|
|
|
+ title: '警告',
|
|
|
+ content: `你确定删除 [${record.name}] 模型吗?删除之后不可再用该模型对话`,
|
|
|
+ positiveText: '确定',
|
|
|
+ negativeText: '不确定',
|
|
|
+ onPositiveClick: async () => {
|
|
|
+ await del(record.id);
|
|
|
+ message.success('模型删除成功');
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="n-layout-page-header">
|
|
|
- <n-card :bordered="false" title="模型配置"> 支持对常见的模型配置。 </n-card>
|
|
|
+ <n-card :bordered="false" title="模型配置">
|
|
|
+ 支持动态配置LLM大模型参数,支持不同的模型使用不同的ApiKey。
|
|
|
+ </n-card>
|
|
|
</div>
|
|
|
|
|
|
<n-card :bordered="false" class="mt-4">
|
|
|
- <BasicTable
|
|
|
- ref="actionRef"
|
|
|
- :actionColumn="actionColumn"
|
|
|
- :columns="columns"
|
|
|
- :pagination="false"
|
|
|
- :request="loadDataTable"
|
|
|
- :row-key="(row:any) => row.model"
|
|
|
- :single-line="false"
|
|
|
- default-expand-all
|
|
|
- >
|
|
|
- <template #tableTitle>
|
|
|
- <n-button type="primary" @click="handleAdd">
|
|
|
- <template #icon>
|
|
|
- <n-icon>
|
|
|
- <PlusOutlined />
|
|
|
- </n-icon>
|
|
|
+ <div class="flex gap-5">
|
|
|
+ <div class="w-52 flex flex-col gap-4 py-1">
|
|
|
+ <div class="font-bold text-base">LLM Provider</div>
|
|
|
+ <n-menu
|
|
|
+ v-model:value="provider"
|
|
|
+ :key-field="'model'"
|
|
|
+ :label-field="'name'"
|
|
|
+ :options="LLMProviders"
|
|
|
+ class="model-menu"
|
|
|
+ @update:value="reloadTable"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="w-full">
|
|
|
+ <BasicTable
|
|
|
+ ref="actionRef"
|
|
|
+ :actionColumn="actionColumn"
|
|
|
+ :columns="columns"
|
|
|
+ :pagination="false"
|
|
|
+ :request="loadDataTable"
|
|
|
+ :row-key="(row:any) => row.model"
|
|
|
+ :single-line="false"
|
|
|
+ default-expand-all
|
|
|
+ >
|
|
|
+ <template #tableTitle>
|
|
|
+ <n-button type="primary" @click="handleAdd">
|
|
|
+ <template #icon>
|
|
|
+ <n-icon>
|
|
|
+ <PlusOutlined />
|
|
|
+ </n-icon>
|
|
|
+ </template>
|
|
|
+ 新增模型
|
|
|
+ </n-button>
|
|
|
</template>
|
|
|
- 新增模型
|
|
|
- </n-button>
|
|
|
- </template>
|
|
|
- </BasicTable>
|
|
|
+ </BasicTable>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</n-card>
|
|
|
|
|
|
<Edit ref="editRef" @reload="reloadTable" />
|