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
1 change: 1 addition & 0 deletions ui/src/api/types/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,5 @@ export interface ToolExecutionRecord extends ToolExecutionRecordDetail {
source_icon?: string | null
trigger_type?: import('./trigger').TriggerType | null
create_time: string
workspace_name?: string
}
2 changes: 1 addition & 1 deletion ui/src/assets/iconfont.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions ui/src/components/global/mk-status-label/index.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script setup lang="ts">
import { computed, type Component } from 'vue'
import { computed } from 'vue'
import { STATE_LABELS } from '@/constants/state'
import { STATE_TYPES } from '@/api/enums'
import type { State } from '@/api/types'
import { SuccessFilled, CircleCloseFilled, Loading } from '@element-plus/icons-vue'

defineOptions({ name: 'MkStatusLabel' })

Expand All @@ -18,13 +17,13 @@ const props = withDefaults(
)

/* 状态文案与 STATE_LABELS 共用状态键,兼容原有启用/禁用展示。 */
const statusOptions: Partial<Record<State, { icon?: Component; className: string }>> = {
[STATE_TYPES.SUCCESS]: { icon: SuccessFilled, className: 'text-success!' },
[STATE_TYPES.FAILURE]: { icon: CircleCloseFilled, className: 'text-danger!' },
[STATE_TYPES.STARTED]: { icon: Loading, className: 'is-loading' },
[STATE_TYPES.REVOKE]: { icon: Loading, className: 'is-loading' },
[STATE_TYPES.PENDING]: { icon: Loading, className: 'is-loading' },
[STATE_TYPES.REVOKED]: { icon: CircleCloseFilled, className: 'text-danger!' },
const statusOptions: Partial<Record<State, { name?: string; loading?: boolean }>> = {
[STATE_TYPES.SUCCESS]: { name: 'icon_succeed_colorful' },
[STATE_TYPES.FAILURE]: { name: 'icon_close_colorful' },
[STATE_TYPES.STARTED]: { loading: true },
[STATE_TYPES.REVOKE]: { loading: true },
[STATE_TYPES.PENDING]: { loading: true },
[STATE_TYPES.REVOKED]: { name: 'icon_close_colorful' },
}
const presentation = computed(() => {
if (props.status !== undefined) return statusOptions[props.status]
Expand All @@ -37,7 +36,8 @@ const label = computed(() =>

<template>
<span class="flex-align-center gap-2">
<MkIcon v-if="presentation?.icon" :icon="presentation.icon" :class="presentation.className" />
<LoadingIcon v-if="presentation?.loading" :size="16" />
<MkIcon v-else-if="presentation?.name" :name="presentation.name" />
<MkIcon v-else-if="status === undefined && !active" name="icon_ban_filled" class="text-N500!" />
<span>{{ label }}</span>
</span>
Expand Down
3 changes: 3 additions & 0 deletions ui/src/constants/CONSTANT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ const knowledgeTypeLabel = KNOWLEDGE_TYPE_LABELS[knowledgeType]

`state.ts` 的 `STATE_LABELS` 统一维护公共枚举 `STATE_TYPES` 的展示文案。触发器、文件等业务
按需复用 `api/enums/state.ts` 中的状态值;新增状态时同步补齐文案和 `MkStatusLabel` 的图标映射。

`document.ts` 的 `DOCUMENT_HIT_HANDLING_LABELS` 维护文档命中处理方式的展示文案,
映射键引用 API 枚举 `DOCUMENT_HIT_HANDLING`。
7 changes: 7 additions & 0 deletions ui/src/constants/document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DOCUMENT_HIT_HANDLING } from '@/api/enums'

/** 文档命中处理方式的展示文案。 */
export const DOCUMENT_HIT_HANDLING_LABELS = {
[DOCUMENT_HIT_HANDLING.OPTIMIZATION]: '模型优化',
[DOCUMENT_HIT_HANDLING.DIRECTLY_RETURN]: '直接回答',
} as const
45 changes: 34 additions & 11 deletions ui/src/views/knowledge-detail/document/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import DocumentApi from '@/api/admin/workspace/knowledge/document'
import SharedDocumentApi from '@/api/admin/workspace/shared/knowledge/document'
import CommonApi from '@/api/admin/workspace/common'
import CommonSystemApi from '@/api/admin/system/common'
import { DOCUMENT_HIT_HANDLING, DOCUMENT_TASK_STATE, DOCUMENT_TASK_TYPE } from '@/api/enums'
import { DOCUMENT_TASK_STATE, DOCUMENT_TASK_TYPE } from '@/api/enums'
import { DOCUMENT_HIT_HANDLING_LABELS } from '@/constants/document'
import type { Dict, DocumentItem, OptionItem } from '@/api/types'
import { datetimeFormat } from '@/utils/time'
import { isWorkspaceSharedResource } from '@/utils/resource-context'
import { numberFormat } from '@/utils/number'

defineOptions({ name: 'DocumentListView' })
defineProps<ResourceDetailPageProps>()
Expand Down Expand Up @@ -54,7 +56,6 @@ function loadDocuments() {
...documentQuery.value,
status: documentStatusFilter.value.status,
task_type: documentStatusFilter.value.task_type,
resource_type: 'document',
})
.then((page) => {
documentData.value = page.records
Expand Down Expand Up @@ -90,24 +91,46 @@ onMounted(() => {
:max-table-height="210"
@current-change="loadDocuments"
@size-change="loadDocuments"
resizable
>
<el-table-column prop="name" label="文档名称" min-width="220" show-overflow-tooltip />

<el-table-column prop="status" label="文件状态" width="120">
<!-- // TODO: 补充文档状态类型 -->
<template #default="{ row }"><MkStatusLabel :active="row.status" /></template>
</el-table-column>
<el-table-column label="启用状态" width="100">
<template #default="{ row }"><MkStatusLabel :active="row.is_active" /></template>
</el-table-column>
<el-table-column prop="char_length" label="字符数">
<template #default="{ row }">
<StatusValue :status="row.status" :status-meta="row.status_meta"></StatusValue>
{{ numberFormat(row.char_length) }}
</template>
</el-table-column>
<el-table-column prop="char_length" label="字符数" width="110" />
<el-table-column prop="paragraph_count" label="分段数" width="100" />
<el-table-column prop="hit_num" label="召回次数" width="120" />
<el-table-column label="命中处理" width="110">
<template #default="{ row }">{{ row.hit_handling_method === DOCUMENT_HIT_HANDLING.DIRECTLY_RETURN ? '直接返回' : '模型优化' }}</template>
<el-table-column prop="paragraph_count" label="分段">
<template #default="{ row }">
{{ numberFormat(row.paragraph_count) }}
</template>
</el-table-column>
<el-table-column label="启用状态" width="100">
<template #default="{ row }"><MkStatusLabel :active="row.is_active" /></template>
<!-- 标签 -->

<el-table-column label="召回处理" width="110">
<template #default="{ row }: { row: DocumentItem }">
{{ DOCUMENT_HIT_HANDLING_LABELS[row.hit_handling_method] }}
</template>
</el-table-column>
<el-table-column prop="hit_num" label="召回次数">
<template #default="{ row }">
{{ numberFormat(row.hit_num) }}
</template>
</el-table-column>
<el-table-column label="最后一次召回时间" width="180">
<template #default="{ row }">{{ datetimeFormat(row.last_hit_time) }}</template>
</el-table-column>
<el-table-column prop="nick_name" label="创建者" show-overflow-tooltip />
<el-table-column label="更新时间" width="180">
<template #default="{ row }">{{ datetimeFormat(row.update_time) }}</template>
</el-table-column>
<el-table-column prop="nick_name" label="创建者" min-width="120" show-overflow-tooltip />
<el-table-column label="创建时间" width="180">
<template #default="{ row }">{{ datetimeFormat(row.create_time) }}</template>
</el-table-column>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/system/resource-management/tool/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ onMounted(() => {
<el-table-column label="来源" width="120">
<template #default="{ row }">{{ row.template_id ? '工具商店' : '自定义' }}</template>
</el-table-column>
<el-table-column label="状态" width="120">
<el-table-column label="启用状态" width="100">
<template #default="{ row }"><MkStatusLabel :active="row.is_active" /></template>
</el-table-column>
<el-table-column v-if="auth.isEE" prop="workspace_name" label="工作空间" min-width="160" show-overflow-tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type WorkflowApi from '@/api/admin/workspace/tool/workflow'
import { TOOL_RECORD_SOURCE, KNOWLEDGE_TYPE } from '@/api/enums'
import type { ToolExecutionRecord, ToolExecutionRecordDetail } from '@/api/types'
import { datetimeFormat } from '@/utils/time'
import { isSystemSharedResource } from '@/utils/resource-context'
import ExecutionDetailContent from '@/workflow-canvas/execution-details/index.vue'
import type { ExecutionNodeDetail } from '@/workflow-canvas/execution-details/types'
import { WorkflowMode } from '@/workflow-canvas/types'
Expand Down Expand Up @@ -70,7 +71,12 @@ watch(
<span class="min-w-0 flex-1 truncate" :title="record.source_name ?? undefined">{{ record.source_name || '-' }}</span>
</div>
</div>
<!-- // TODO 共享资源需要显示工作空间 -->

<!-- TODO 可能需要调整ui -->
<div v-if="isSystemSharedResource()">
<p class="mb-1 text-N600">工作空间</p>
{{ record?.workspace_name || '-' }}
</div>
<div>
<p class="mb-1 text-N600">状态</p>
<MkStatusLabel :status="detail?.state ?? record.state" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { computed, ref } from 'vue'
import type WorkflowApi from '@/api/admin/workspace/tool/workflow'
import { TOOL_RECORD_SOURCE, KNOWLEDGE_TYPE, STATE_TYPES } from '@/api/enums'
import type { Dict, ToolExecutionRecord } from '@/api/types'
import { datetimeFormat } from '@/utils/time'
import ExecutionDetailDrawer from './ExecutionDetailDrawer.vue'
import { STATE_LABELS } from '@/constants/state'
import { datetimeFormat } from '@/utils/time'
import { isSystemSharedResource } from '@/utils/resource-context'

const props = defineProps<{ api: typeof WorkflowApi; toolId: string }>()
const emit = defineEmits<{ closed: [] }>()
Expand Down Expand Up @@ -36,9 +37,9 @@ const searchFields = [
label: '资源类型',
value: 'source_type',
options: [
{ label: '智能体', value: TOOL_RECORD_SOURCE.APPLICATION },
{ label: '知识库', value: TOOL_RECORD_SOURCE.KNOWLEDGE },
{ label: '触发器', value: TOOL_RECORD_SOURCE.TRIGGER },
{ label: sourceLabels[TOOL_RECORD_SOURCE.APPLICATION], value: TOOL_RECORD_SOURCE.APPLICATION },
{ label: sourceLabels[TOOL_RECORD_SOURCE.KNOWLEDGE], value: TOOL_RECORD_SOURCE.KNOWLEDGE },
{ label: sourceLabels[TOOL_RECORD_SOURCE.TRIGGER], value: TOOL_RECORD_SOURCE.TRIGGER },
],
},
]
Expand Down Expand Up @@ -124,28 +125,32 @@ defineExpose({ open })
@size-change="loadRecords()"
>
<el-table-column label="触发来源" min-width="130" show-overflow-tooltip>
<template #default="{ row }"
><div class="flex-align-center gap-2">
<template #default="{ row }">
<div class="flex-align-center gap-2">
<ApplicationIcon v-if="row.source_type === TOOL_RECORD_SOURCE.APPLICATION" :icon="row.source_icon" :size="20" />
<KnowledgeIcon v-else-if="row.source_type === TOOL_RECORD_SOURCE.KNOWLEDGE" :type="KNOWLEDGE_TYPE.WORKFLOW" :size="20" />
<TriggerIcon v-else-if="row.source_type === TOOL_RECORD_SOURCE.TRIGGER" :type="row.trigger_type ?? undefined" :size="20" />
<span class="min-w-0 flex-1 truncate" :title="row.source_name || '-'">{{ row.source_name || '-' }}</span>
</div>
</template>
</el-table-column>
<!-- // TODO 共享资源需要显示工作空间 -->
<el-table-column label="类型" width="90"
><template #default="{ row }">{{ sourceLabels[row.source_type as keyof typeof sourceLabels] || '-' }}</template></el-table-column
>
<el-table-column label="状态" width="100"
><template #default="{ row }"><MkStatusLabel :status="row.state" /></template
></el-table-column>
<el-table-column label="耗时" width="90"
><template #default="{ row }">{{ row.run_time == null ? '-' : `${row.run_time.toFixed(2)} s` }}</template></el-table-column
>
<el-table-column label="执行时间" prop="create_time" width="180"
><template #default="{ row }">{{ datetimeFormat(row.create_time) }}</template></el-table-column
>
<el-table-column v-if="isSystemSharedResource()" prop="workspace_name" label="工作空间" show-overflow-tooltip>
<template #default="{ row }">
{{ row.workspace_name }}
</template>
</el-table-column>
<el-table-column label="类型" width="90">
<template #default="{ row }">{{ sourceLabels[row.source_type as keyof typeof sourceLabels] || '-' }}</template>
</el-table-column>
<el-table-column label="状态" width="100">
<template #default="{ row }"><MkStatusLabel :status="row.state" /></template>
</el-table-column>
<el-table-column label="耗时" width="90">
<template #default="{ row }">{{ row.run_time == null ? '-' : `${row.run_time.toFixed(2)} s` }}</template>
</el-table-column>
<el-table-column label="执行时间" prop="create_time" width="180">
<template #default="{ row }">{{ datetimeFormat(row.create_time) }}</template>
</el-table-column>
<el-table-column label="操作" width="70">
<template #default="{ row }">
<!-- 查看执行详情 -->
Expand Down
7 changes: 3 additions & 4 deletions ui/src/workflow-canvas/execution-details/BaseHeader.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { computed, type Component } from 'vue'
import { SuccessFilled, CircleCloseFilled, Loading } from '@element-plus/icons-vue'
import { formatTokenNumber } from '@/utils/number'
import { iconComponent } from '@/workflow-canvas/icons/utils'
import type { ExecutionNodeDetail } from './types'
Expand Down Expand Up @@ -29,9 +28,9 @@ const tokenCount = computed(() => (props.data?.message_tokens || 0) + (props.dat
<span v-if="showTokens">{{ formatTokenNumber(tokenCount) }} tokens</span>
<span v-if="!isRunning">{{ data?.run_time?.toFixed(2) || '0.00' }} s</span>

<MkIcon v-if="isSuccess" :icon="SuccessFilled" class="text-success!" />
<MkIcon v-else-if="isRunning" :icon="Loading" class="is-loading" />
<MkIcon v-else :icon="CircleCloseFilled" class="text-danger!" />
<MkIcon v-if="isSuccess" name="icon_succeed_colorful" />
<LoadingIcon v-else-if="isRunning" :size="16" />
<MkIcon v-else name="icon_close_colorful" />
</div>
</div>
</template>
Loading