feat: 应用管理
This commit is contained in:
parent
fcf04ee234
commit
68165707bd
@ -29,6 +29,32 @@ const getApplication: (param: pageRequest) => Promise<Result<any>> = (param) =>
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得临时回话Id
|
||||||
|
* @param 参数
|
||||||
|
* {
|
||||||
|
"model_id": "string",
|
||||||
|
"multiple_rounds_dialogue": true,
|
||||||
|
"dataset_id_list": [
|
||||||
|
"string"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
||||||
|
return post(`${prefix}/chat/open`, data)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 对话
|
||||||
|
* @param 参数
|
||||||
|
* chat_id: string
|
||||||
|
* {
|
||||||
|
"message": "string",
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const postChatMessage: (chat_id: string, message: string) => Promise<any> = (chat_id, message) => {
|
||||||
|
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建应用
|
* 创建应用
|
||||||
* @param 参数
|
* @param 参数
|
||||||
@ -46,36 +72,10 @@ const getApplication: (param: pageRequest) => Promise<Result<any>> = (param) =>
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const postApplication: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
const postApplication: ( data: ApplicationFormType, loading?: Ref<boolean> ) => Promise<Result<any>> = (data, loading) => {
|
||||||
return post(`${prefix}`, data)
|
return post(`${prefix}`, data, undefined, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得临时回话Id
|
|
||||||
* @param 参数
|
|
||||||
* {
|
|
||||||
"model_id": "string",
|
|
||||||
"multiple_rounds_dialogue": true,
|
|
||||||
"dataset_id_list": [
|
|
||||||
"string"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const postChatOpen: (data: ApplicationFormType) => Promise<Result<any>> = (data) => {
|
|
||||||
return post(`${prefix}/chat/open`, data)
|
|
||||||
}
|
|
||||||
// 对话
|
|
||||||
/**
|
|
||||||
* 创建数据集
|
|
||||||
* @param 参数
|
|
||||||
* chat_id: string
|
|
||||||
* {
|
|
||||||
"message": "string",
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const postChatMessage: (chat_id: string, message: string) => Promise<any> = (chat_id, message) => {
|
|
||||||
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
|
|
||||||
}
|
|
||||||
export default {
|
export default {
|
||||||
getAllAppilcation,
|
getAllAppilcation,
|
||||||
getApplication,
|
getApplication,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<LayoutContainer :header="id ? '设置' : '创建应用'" back-to="-1" class="create-application">
|
<LayoutContainer :header="id ? '设置' : '创建应用'" back-to="-1" class="create-application">
|
||||||
<el-row>
|
<el-row v-loading="loading">
|
||||||
<el-col :span="10">
|
<el-col :span="10">
|
||||||
<div class="p-24 mb-16" style="padding-bottom: 0">
|
<div class="p-24 mb-16" style="padding-bottom: 0">
|
||||||
<h4 class="title-decoration-1">应用信息</h4>
|
<h4 class="title-decoration-1">应用信息</h4>
|
||||||
@ -140,7 +140,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-right border-t p-16">
|
<div class="text-right border-t p-16">
|
||||||
<el-button @click="router.push({ path: `/application` })"> 取消 </el-button>
|
<el-button @click="router.push({ path: `/application` })"> 取消 </el-button>
|
||||||
<el-button type="primary" @click="submit" :disabled="loading"> 创建 </el-button>
|
<el-button type="primary" @click="submit(applicationFormRef)" :disabled="loading">
|
||||||
|
创建
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="14" class="p-24 border-l">
|
<el-col :span="14" class="p-24 border-l">
|
||||||
@ -162,10 +164,12 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
import { groupBy } from 'lodash'
|
import { groupBy } from 'lodash'
|
||||||
import AiDialog from '@/components/ai-dialog/index.vue'
|
import AiDialog from '@/components/ai-dialog/index.vue'
|
||||||
import AddDatasetDialog from './components/AddDatasetDialog.vue'
|
import AddDatasetDialog from './components/AddDatasetDialog.vue'
|
||||||
|
import applicationApi from '@/api/application'
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import type { ApplicationFormType } from '@/api/type/application'
|
import type { ApplicationFormType } from '@/api/type/application'
|
||||||
import type { Provider } from '@/api/type/model'
|
import type { Provider } from '@/api/type/model'
|
||||||
import { realatedObject } from '@/utils/utils'
|
import { realatedObject } from '@/utils/utils'
|
||||||
|
import { MsgSuccess } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { model, dataset } = useStore()
|
const { model, dataset } = useStore()
|
||||||
|
|
||||||
@ -208,41 +212,23 @@ watch(exampleList.value, () => {
|
|||||||
applicationForm.example = exampleList.value.filter((v) => v)
|
applicationForm.example = exampleList.value.filter((v) => v)
|
||||||
})
|
})
|
||||||
|
|
||||||
function submit() {
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
loading.value = true
|
if (!formEl) return
|
||||||
|
await formEl.validate((valid, fields) => {
|
||||||
// const documents = [] as any[]
|
if (valid) {
|
||||||
// StepSecondRef.value.paragraphList.map((item: any) => {
|
applicationApi
|
||||||
// documents.push({
|
.postApplication(applicationForm, loading)
|
||||||
// name: item.name,
|
.then((res) => {
|
||||||
// paragraphs: item.content
|
MsgSuccess('创建成功')
|
||||||
// })
|
router.push({ path: `/application` })
|
||||||
// })
|
})
|
||||||
// const obj = { ...baseInfo.value, documents } as datasetData
|
.catch(() => {
|
||||||
// if (id) {
|
loading.value = false
|
||||||
// documentApi
|
})
|
||||||
// .postDocument(id, documents)
|
} else {
|
||||||
// .then((res) => {
|
console.log('error submit!')
|
||||||
// MsgSuccess('提交成功')
|
}
|
||||||
// clearStore()
|
})
|
||||||
// router.push({ path: `/dataset/${id}/document` })
|
|
||||||
// })
|
|
||||||
// .catch(() => {
|
|
||||||
// loading.value = false
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// datasetApi
|
|
||||||
// .postDateset(obj)
|
|
||||||
// .then((res) => {
|
|
||||||
// successInfo.value = res.data
|
|
||||||
// active.value = 2
|
|
||||||
// clearStore()
|
|
||||||
// loading.value = false
|
|
||||||
// })
|
|
||||||
// .catch(() => {
|
|
||||||
// loading.value = false
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeDataset(id: String) {
|
function removeDataset(id: String) {
|
||||||
|
|||||||
@ -20,16 +20,25 @@
|
|||||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mt-8">
|
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mt-8">
|
||||||
<CardAdd title="创建应用" @click="router.push({ path: '/application/create' })" />
|
<CardAdd title="创建应用" @click="router.push({ path: '/application/create' })" />
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mt-8">
|
<el-col
|
||||||
|
:xs="24"
|
||||||
|
:sm="12"
|
||||||
|
:md="8"
|
||||||
|
:lg="6"
|
||||||
|
:xl="4"
|
||||||
|
v-for="(item, index) in applicationList"
|
||||||
|
:key="index"
|
||||||
|
class="mt-8"
|
||||||
|
>
|
||||||
<CardBox
|
<CardBox
|
||||||
title="应用"
|
:title="item.name"
|
||||||
description="XXXXXX"
|
:description="item.desc"
|
||||||
class="application-card cursor"
|
class="application-card cursor"
|
||||||
@click="router.push({ path: '/application/1/overview' })"
|
@click="router.push({ path: `/application/${item.id}/overview` })"
|
||||||
>
|
>
|
||||||
<div class="status-tag">
|
<div class="status-tag">
|
||||||
<el-tag class="warning-tag">已停用</el-tag>
|
<el-tag v-if="item.status" class="success-tag">运行中</el-tag>
|
||||||
<el-tag class="success-tag">运行中</el-tag>
|
<el-tag v-else class="warning-tag">已停用</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -41,7 +50,10 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
<el-tooltip effect="dark" content="设置" placement="top">
|
<el-tooltip effect="dark" content="设置" placement="top">
|
||||||
<el-button text @click.stop>
|
<el-button
|
||||||
|
text
|
||||||
|
@click.stop="router.push({ path: `/application/${item.id}/setting` })"
|
||||||
|
>
|
||||||
<AppIcon iconName="Setting"></AppIcon>
|
<AppIcon iconName="Setting"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@ -56,7 +68,8 @@
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<div class="dropdown-custom-switch">
|
<div class="dropdown-custom-switch">
|
||||||
<span>运行中</span><el-switch v-model="state" />
|
<span>运行中</span>
|
||||||
|
<!-- <el-switch v-model="item.status" @change="changeState($event, item)" /> -->
|
||||||
</div>
|
</div>
|
||||||
<el-dropdown-item divided>删除</el-dropdown-item>
|
<el-dropdown-item divided>删除</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
@ -122,19 +135,27 @@ function search() {
|
|||||||
// .catch(() => {})
|
// .catch(() => {})
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// function changeState(bool: Boolean, row: any) {
|
||||||
|
// const obj = {
|
||||||
|
// is_active: bool
|
||||||
|
// }
|
||||||
|
// loading.value = true
|
||||||
|
// applicationApi
|
||||||
|
// .asyncPutParagraph(id, documentId, row.id, obj)
|
||||||
|
// .then((res) => {
|
||||||
|
// loading.value = false
|
||||||
|
// })
|
||||||
|
// .catch(() => {
|
||||||
|
// loading.value = false
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
applicationApi
|
applicationApi
|
||||||
.getApplication(pageConfig)
|
.getApplication(pageConfig)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const list = res.data?.records
|
applicationList.value = res.data?.records
|
||||||
list.map((item: any) => {
|
|
||||||
applicationList.value.push({
|
|
||||||
value: item.provider,
|
|
||||||
label: item.name
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user