Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ui/src/api/admin/workspace/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
ApplicationAccessTokenPayload,
ApplicationApiKeyEnable,
ApplicationApiKeyEnablePayload,
ApplicationCleanTimePayload,
ApplicationDetail,
ApplicationDisplaySetting,
ApplicationFormPayload,
Expand Down Expand Up @@ -105,6 +106,15 @@ const putBatchMoveApplications = (applicationIds: string[], folderId: string) =>
return put<{ folder_id: string; id_list: string[] }, boolean>(`${getPrefix()}/batch_move`, { folder_id: folderId, id_list: applicationIds })
}

/** 批量设置工作空间智能体对话日志清除策略。 */
const putBatchApplicationCleanTime = (applicationIds: string[], cleanTime: number, fileCleanTime: number) => {
return put<ApplicationCleanTimePayload, boolean>(`${getPrefix()}/batch_clean_time`, {
id_list: applicationIds,
clean_time: cleanTime,
file_clean_time: fileCleanTime,
})
}

/** 发布工作空间智能体。 */
const putApplicationPublish = (applicationId: string, publishName: string, publishDesc?: string) => {
return put<Record<string, unknown>, ApplicationDetail>(`${getPrefix()}/${applicationId}/publish`, {
Expand Down Expand Up @@ -132,6 +142,7 @@ export default {
putMoveApplication,
putBatchDeleteApplications,
putBatchMoveApplications,
putBatchApplicationCleanTime,
putApplicationPublish,
getAllApplication,
}
4 changes: 2 additions & 2 deletions ui/src/api/admin/workspace/application/chat-log.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { del, get, post, postExportExcel, put } from '../../core/request'
import type { ParamsPage, ResponsePage } from '../../core/types'
import type { ChatLog, ChatLogAddKnowledgePayload, ChatLogRecord, Dict } from '@/api/types'
import type { ApplicationCleanTimePayload, ChatLog, ChatLogAddKnowledgePayload, ChatLogRecord, Dict } from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = () => `/workspace/${getWorkspaceId()}/application`
Expand All @@ -15,7 +15,7 @@ const postExportChatLog = (applicationId: string, applicationName: string, query

/** 保存当前智能体的日志与文件清除策略。 */
const putChatLogCleanTime = (applicationId: string, cleanTime: number, fileCleanTime: number) =>
put<{ id_list: string[]; clean_time: number; file_clean_time: number }, boolean>(`${getPrefix()}/batch_clean_time`, {
put<ApplicationCleanTimePayload, boolean>(`${getPrefix()}/batch_clean_time`, {
id_list: [applicationId],
clean_time: cleanTime,
file_clean_time: fileCleanTime,
Expand Down
7 changes: 7 additions & 0 deletions ui/src/api/types/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ export interface ApplicationDetail extends Omit<ApplicationFormPayload, 'desc'>
work_flow?: LogicFlow.GraphConfigData
}

/** 智能体对话日志与附件清除策略保存参数。 */
export interface ApplicationCleanTimePayload {
id_list: string[]
clean_time: number
file_clean_time: number
}

export interface ApplicationFormPayload {
clean_time?: number
file_clean_time?: number
Expand Down
84 changes: 84 additions & 0 deletions ui/src/views/application/components/ButtonBatchCleanStrategy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<script setup lang="ts">
import { ref } from 'vue'
import ApplicationApi from '@/api/admin/workspace/application/application'
import { MsgSuccess } from '@/utils/message'

const props = defineProps<{ applicationIds: string[] }>()
const emit = defineEmits<{ refresh: [] }>()

const visible = ref(false)
const loading = ref(false)
const selectedApplicationIds = ref<string[]>([])
const days = ref(180)
const fileDays = ref(180)

function handleOpenDialog() {
if (loading.value || !props.applicationIds.length) return
selectedApplicationIds.value = [...props.applicationIds]
visible.value = true
}

function handleSubmit() {
if (loading.value || !selectedApplicationIds.value.length) return
loading.value = true
return ApplicationApi.putBatchApplicationCleanTime(selectedApplicationIds.value, days.value, Math.min(fileDays.value, days.value))
.then(() => {
MsgSuccess('保存成功')
visible.value = false
emit('refresh')
})
.finally(() => {
loading.value = false
})
}

function resetData() {
selectedApplicationIds.value = []
days.value = 180
fileDays.value = 180
}
</script>

<template>
<!-- 批量设置对话日志清除策略 -->
<el-button type="primary" plain :disabled="!applicationIds.length" @click="handleOpenDialog">清除策略</el-button>

<MkDialog v-model="visible" title="清除策略" @closed="resetData">
<div class="space-y-4">
<div class="flex-align-center gap-2">
<span>删除</span>
<el-input-number
v-model="days"
class="w-40!"
controls-position="right"
align="left"
:min="1"
:max="100000"
:value-on-clear="1"
step-strictly
/>
<span>天之前的对话记录</span>
</div>
<div class="flex-align-center gap-2">
<span>删除</span>
<el-input-number
v-model="fileDays"
class="w-40!"
controls-position="right"
align="left"
:min="1"
:max="days"
:value-on-clear="1"
step-strictly
/>
<span>天之前的对话上传的附件</span>
</div>
</div>
<template #footer>
<!-- 取消清除策略设置 -->
<el-button plain :disabled="loading" @click="visible = false">取消</el-button>
<!-- 保存批量清除策略 -->
<el-button type="primary" :loading="loading" @click="handleSubmit">保存</el-button>
</template>
</MkDialog>
</template>
18 changes: 17 additions & 1 deletion ui/src/views/application/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from './application-card/action-dropdown'
import ButtonCreateApplication from './components/ButtonCreateApplication.vue'
import ButtonTemplateStore from './components/ButtonTemplateStore.vue'
import ButtonBatchCleanStrategy from './components/ButtonBatchCleanStrategy.vue'
import perm from '@/permission/index.ts'
import { getWorkspaceId } from '@/utils/resource-context.ts'

Expand Down Expand Up @@ -137,6 +138,11 @@ function cancelBatchSelection() {
selectedApplicationIds.value = []
}

function handleBatchCleanStrategySuccess() {
cancelBatchSelection()
return refreshApplications()
}

function handleApplicationSelect(applicationId: string, selected: boolean) {
if (selected) {
if (!selectedApplicationIds.value.includes(applicationId)) selectedApplicationIds.value.push(applicationId)
Expand Down Expand Up @@ -219,7 +225,11 @@ function handleBatchDelete() {
<div class="flex-align-center gap-3">
<MkComplexSearch :fields="searchFields" @change="handleSearchChange" />
<!-- 批量选择 -->
<span v-if="perm.application.workspace.batchMove() || perm.application.workspace.batchDelete()">
<span
v-if="
perm.application.workspace.batchMove() || perm.application.workspace.batchCleanStrategy() || perm.application.workspace.batchDelete()
"
>
<el-button :disabled="!applicationData.length" :type="batchSelectionMode ? 'primary' : undefined" plain @click="toggleBatchSelection">
<MkIcon name="icon_Batch_outlined" />
<span>{{ batchSelectionMode ? '取消选择' : '批量选择' }}</span>
Expand Down Expand Up @@ -343,6 +353,12 @@ function handleBatchDelete() {
>
移动到
</el-button>
<!-- 批量设置清除策略 -->
<ButtonBatchCleanStrategy
v-if="perm.application.workspace.batchCleanStrategy()"
:application-ids="selectedApplicationIds"
@refresh="handleBatchCleanStrategySuccess"
/>
<el-button
v-if="perm.application.workspace.batchDelete()"
type="danger"
Expand Down
Loading