feat: 应用设置
This commit is contained in:
parent
ab7c789e1b
commit
1420f6278b
@ -79,6 +79,31 @@ const postApplication: (
|
|||||||
return post(`${prefix}`, data, undefined, loading)
|
return post(`${prefix}`, data, undefined, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改应用
|
||||||
|
* @param 参数
|
||||||
|
* {
|
||||||
|
"name": "string",
|
||||||
|
"desc": "string",
|
||||||
|
"model_id": "string",
|
||||||
|
"multiple_rounds_dialogue": true,
|
||||||
|
"prologue": "string",
|
||||||
|
"example": [
|
||||||
|
"string"
|
||||||
|
],
|
||||||
|
"dataset_id_list": [
|
||||||
|
"string"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const putApplication: (
|
||||||
|
applicaiton_id: String,
|
||||||
|
data: ApplicationFormType,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (applicaiton_id, data, loading) => {
|
||||||
|
return put(`${prefix}/${applicaiton_id}`, data, undefined, loading)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除应用
|
* 删除应用
|
||||||
* @param 参数 applicaiton_id
|
* @param 参数 applicaiton_id
|
||||||
@ -91,15 +116,31 @@ const delApplication: (applicaiton_id: String) => Promise<Result<boolean>> = (ap
|
|||||||
* 应用详情
|
* 应用详情
|
||||||
* @param 参数 applicaiton_id
|
* @param 参数 applicaiton_id
|
||||||
*/
|
*/
|
||||||
const getApplicationDetail: (applicaiton_id: string) => Promise<Result<any>> = (applicaiton_id) => {
|
const getApplicationDetail: (
|
||||||
return get(`${prefix}/${applicaiton_id}`)
|
applicaiton_id: string,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (applicaiton_id, loading) => {
|
||||||
|
return get(`${prefix}/${applicaiton_id}`, undefined, loading)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得当前应用可使用的数据集
|
||||||
|
* @param 参数 applicaiton_id
|
||||||
|
*/
|
||||||
|
const getApplicationDataset: (
|
||||||
|
applicaiton_id: string,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (applicaiton_id, loading) => {
|
||||||
|
return get(`${prefix}/${applicaiton_id}/list_dataset`, undefined, loading)
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
getAllAppilcation,
|
getAllAppilcation,
|
||||||
getApplication,
|
getApplication,
|
||||||
postApplication,
|
postApplication,
|
||||||
|
putApplication,
|
||||||
postChatOpen,
|
postChatOpen,
|
||||||
postChatMessage,
|
postChatMessage,
|
||||||
delApplication,
|
delApplication,
|
||||||
getApplicationDetail
|
getApplicationDetail,
|
||||||
|
getApplicationDataset
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,8 +55,8 @@
|
|||||||
</AppAvatar>
|
</AppAvatar>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="flex" v-if="!item.answer_text || item.problem_text.length === 0">
|
<div class="flex" v-if="!item.answer_text">
|
||||||
<el-card shadow="always" class="dialog-card"> {{ '回答中...' }} </el-card>
|
<el-card shadow="always" class="dialog-card"> 回答中... </el-card>
|
||||||
</div>
|
</div>
|
||||||
<el-card v-else shadow="always" class="dialog-card">
|
<el-card v-else shadow="always" class="dialog-card">
|
||||||
<MarkdownRenderer :source="item.answer_text"></MarkdownRenderer>
|
<MarkdownRenderer :source="item.answer_text"></MarkdownRenderer>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
|
import { type Ref } from 'vue'
|
||||||
|
|
||||||
const useApplicationStore = defineStore({
|
const useApplicationStore = defineStore({
|
||||||
id: 'application',
|
id: 'application',
|
||||||
@ -18,10 +19,10 @@ const useApplicationStore = defineStore({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async asyncGetApplicationDetail(id: string) {
|
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
applicationApi
|
applicationApi
|
||||||
.getApplicationDetail(id)
|
.getApplicationDetail(id, loading)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
resolve(data)
|
resolve(data)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -171,7 +171,7 @@ import type { Provider } from '@/api/type/model'
|
|||||||
import { realatedObject } from '@/utils/utils'
|
import { realatedObject } from '@/utils/utils'
|
||||||
import { MsgSuccess } from '@/utils/message'
|
import { MsgSuccess } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { model, dataset, application } = useStore()
|
const { model, dataset, application, user } = useStore()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -184,7 +184,7 @@ const AddDatasetDialogRef = ref()
|
|||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const exampleList = ref(['', ''])
|
const exampleList = ref(['', ''])
|
||||||
const applicationForm = reactive<ApplicationFormType>({
|
const applicationForm = ref<ApplicationFormType>({
|
||||||
name: '',
|
name: '',
|
||||||
desc: '',
|
desc: '',
|
||||||
model_id: '',
|
model_id: '',
|
||||||
@ -209,62 +209,63 @@ const providerOptions = ref<Array<Provider>>([])
|
|||||||
const datasetList = ref([])
|
const datasetList = ref([])
|
||||||
|
|
||||||
watch(exampleList.value, () => {
|
watch(exampleList.value, () => {
|
||||||
applicationForm.example = exampleList.value.filter((v) => v)
|
applicationForm.value.example = exampleList.value.filter((v) => v)
|
||||||
})
|
})
|
||||||
|
|
||||||
const submit = async (formEl: FormInstance | undefined) => {
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid, fields) => {
|
await formEl.validate((valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
applicationApi
|
if (id) {
|
||||||
.postApplication(applicationForm, loading)
|
applicationApi.putApplication(id, applicationForm.value, loading).then((res) => {
|
||||||
.then((res) => {
|
MsgSuccess('保存成功')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
|
||||||
MsgSuccess('创建成功')
|
MsgSuccess('创建成功')
|
||||||
router.push({ path: `/application` })
|
router.push({ path: `/application` })
|
||||||
})
|
})
|
||||||
.catch(() => {
|
}
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
console.log('error submit!')
|
console.log('error submit!')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeDataset(id: String) {
|
function removeDataset(id: string) {
|
||||||
applicationForm.dataset_id_list.splice(applicationForm.dataset_id_list.indexOf(id), 1)
|
applicationForm.value.dataset_id_list.splice(applicationForm.value.dataset_id_list.indexOf(id), 1)
|
||||||
}
|
}
|
||||||
function addDataset(val: Array<string>) {
|
function addDataset(val: Array<string>) {
|
||||||
applicationForm.dataset_id_list = val
|
applicationForm.value.dataset_id_list = val
|
||||||
}
|
}
|
||||||
function openDatasetDialog() {
|
function openDatasetDialog() {
|
||||||
AddDatasetDialogRef.value.open(applicationForm.dataset_id_list)
|
AddDatasetDialogRef.value.open(applicationForm.value.dataset_id_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDetail() {
|
function getDetail() {
|
||||||
loading.value = true
|
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
||||||
application
|
applicationForm.value = res.data
|
||||||
.asyncGetApplicationDetail(id)
|
applicationForm.value.model_id = res.data.model
|
||||||
.then((res) => {
|
|
||||||
// detail.value = res.data
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataset() {
|
function getDataset() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
if (id) {
|
||||||
|
applicationApi.getApplicationDataset(id, loading).then((res) => {
|
||||||
|
datasetList.value = res.data
|
||||||
|
})
|
||||||
|
} else {
|
||||||
dataset
|
dataset
|
||||||
.asyncGetAllDateset()
|
.asyncGetAllDateset()
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
datasetList.value = res.data
|
datasetList.value = res.data?.filter((v) => v.user_id === user.userInfo?.id)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModel() {
|
function getModel() {
|
||||||
@ -294,12 +295,12 @@ function getProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (id) {
|
|
||||||
getDetail()
|
|
||||||
}
|
|
||||||
getProvider()
|
getProvider()
|
||||||
getModel()
|
getModel()
|
||||||
getDataset()
|
getDataset()
|
||||||
|
if (id) {
|
||||||
|
getDetail()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user