mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: application publish (#3342)
This commit is contained in:
parent
b496a2b2c5
commit
06e910b630
|
|
@ -599,6 +599,7 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||
application.desc = node_data.get('desc')
|
||||
application.prologue = node_data.get('prologue')
|
||||
application.work_flow = work_flow
|
||||
application.is_publish = True
|
||||
application.save()
|
||||
work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application,
|
||||
name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||
|
|
@ -606,7 +607,7 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||
publish_user_name=user.username,
|
||||
workspace_id=workspace_id)
|
||||
work_flow_version.save()
|
||||
return True
|
||||
return self.one(with_valid=False)
|
||||
|
||||
@staticmethod
|
||||
def update_work_flow_model(instance):
|
||||
|
|
@ -673,7 +674,8 @@ class ApplicationOperateSerializer(serializers.Serializer):
|
|||
if 'work_flow' in instance:
|
||||
# 修改语音配置相关
|
||||
self.update_work_flow_model(instance)
|
||||
|
||||
if application.type == ApplicationTypeChoices.SIMPLE.value:
|
||||
application.is_publish = True
|
||||
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
|
||||
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
|
||||
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ urlpatterns = [
|
|||
path('workspace/<str:workspace_id>/application/<int:current_page>/<int:page_size>',
|
||||
views.ApplicationAPI.Page.as_view(), name='application_page'),
|
||||
path('workspace/<str:workspace_id>/application/<str:application_id>', views.ApplicationAPI.Operate.as_view()),
|
||||
path('workspace/<str:workspace_id>/application/<str:application_id>/publish',
|
||||
views.ApplicationAPI.Publish.as_view()),
|
||||
path('workspace/<str:workspace_id>/application/<str:application_id>/application_key',
|
||||
views.ApplicationKey.as_view()),
|
||||
path('workspace/<str:workspace_id>/application/<str:application_id>/application_stats',
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import {Result} from '@/request/Result'
|
||||
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
||||
import type {pageRequest} from '@/api/type/common'
|
||||
import type {ApplicationFormType} from '@/api/type/application'
|
||||
import {type Ref} from 'vue'
|
||||
import { Result } from '@/request/Result'
|
||||
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
import type { ApplicationFormType } from '@/api/type/application'
|
||||
import { type Ref } from 'vue'
|
||||
import useStore from '@/stores'
|
||||
|
||||
const prefix: any = {_value: '/workspace/'}
|
||||
const prefix: any = { _value: '/workspace/' }
|
||||
Object.defineProperty(prefix, 'value', {
|
||||
get: function () {
|
||||
const {user} = useStore()
|
||||
const { user } = useStore()
|
||||
return this._value + user.getWorkspaceId() + '/application'
|
||||
},
|
||||
})
|
||||
|
|
@ -199,7 +199,7 @@ const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (app
|
|||
*/
|
||||
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
data
|
||||
data,
|
||||
) => {
|
||||
return post(`${prefix.value}/${application_id}/platform/status`, data)
|
||||
}
|
||||
|
|
@ -208,11 +208,23 @@ const updatePlatformStatus: (application_id: string, data: any) => Promise<Resul
|
|||
*/
|
||||
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
type
|
||||
type,
|
||||
) => {
|
||||
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用发布
|
||||
* @param application_id
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const publish: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return put(`${prefix.value}/${application_id}/publish`, data, {}, loading)
|
||||
}
|
||||
export default {
|
||||
getAllApplication,
|
||||
getApplication,
|
||||
|
|
@ -231,5 +243,6 @@ export default {
|
|||
getApplicationSetting,
|
||||
getPlatformStatus,
|
||||
updatePlatformStatus,
|
||||
getPlatformConfig
|
||||
getPlatformConfig,
|
||||
publish,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<AppIcon iconName="app-save-outlined" class="mr-4"></AppIcon>
|
||||
{{ $t('common.save') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="publicHandle">
|
||||
<el-button type="primary" @click="publish">
|
||||
{{ $t('views.applicationWorkflow.setting.public') }}
|
||||
</el-button>
|
||||
|
||||
|
|
@ -256,29 +256,20 @@ function onmousedown(item: any) {
|
|||
function clickoutside() {
|
||||
showPopover.value = false
|
||||
}
|
||||
async function publicHandle() {
|
||||
// 后执行发布
|
||||
workflowRef.value
|
||||
?.validate()
|
||||
.then(async () => {
|
||||
const obj = {
|
||||
work_flow: getGraphData(),
|
||||
}
|
||||
await application.asyncPutApplication(id, obj, loading)
|
||||
const workflow = new WorkFlowInstance(obj.work_flow)
|
||||
try {
|
||||
workflow.is_valid()
|
||||
} catch (e: any) {
|
||||
MsgError(e.toString())
|
||||
return
|
||||
}
|
||||
// applicationApi.putPublishApplication(id as string, obj, loading).then(() => {
|
||||
|
||||
// application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
||||
// detail.value.name = res.data.name
|
||||
// MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
|
||||
// })
|
||||
// })
|
||||
const publish = () => {
|
||||
const workflow = getGraphData()
|
||||
const workflowInstance = new WorkFlowInstance(workflow)
|
||||
try {
|
||||
workflowInstance.is_valid()
|
||||
} catch (e: any) {
|
||||
MsgError(e.toString())
|
||||
return
|
||||
}
|
||||
applicationApi
|
||||
.publish(id, { work_flow: workflow }, loading)
|
||||
.then((ok: any) => {
|
||||
detail.value.name = ok.data.name
|
||||
MsgSuccess(t('views.applicationWorkflow.tip.publicSuccess'))
|
||||
})
|
||||
.catch((res: any) => {
|
||||
const node = res.node
|
||||
|
|
|
|||
Loading…
Reference in New Issue