Files
short-drama-agent-front/src/features/production/components/KeyframeValidationSteps.vue
T

92 lines
4.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { NCollapse, NCollapseItem } from 'naive-ui'
import { formatDate } from '../../../lib/format'
import { userFacingText } from '../../../lib/user-facing-text'
import type { KeyframeValidationStep } from '../quality.types'
import type { ValidationExecutionStep } from '../validation-executions.types'
import {
validationQualityLabels,
validationStatusLabels,
validationStepNames,
validationUsageLabels
} from '../validation-execution-labels'
/** 原任务摘要与逐次执行共用公开步骤展示,复用用量不重复归入本次。 */
defineProps<{
/** 原有摘要没有逐次归属时,不从缺省值推断新调用。 */ steps: readonly (
| KeyframeValidationStep
| ValidationExecutionStep
)[]
}>()
/**
* 将执行状态与质量结论分开标示,保留复用语义。
* @param step 本条公开步骤
* @returns 可读标题
*/
function stepTitle(step: KeyframeValidationStep | ValidationExecutionStep) {
return (
`${validationStepNames[step.name]} · ${validationStatusLabels[step.status] ?? '状态待确认'}` +
('quality' in step
? ` · ${validationQualityLabels[step.quality]}${step.executionKind === 'reused' ? '(复用)' : ''}`
: '')
)
}
</script>
<template>
<!-- 以下是各步骤自己的结论、问题与计量模块 -->
<NCollapse v-if="steps.length" class="mt-3">
<NCollapseItem v-for="step in steps" :key="step.name" :name="step.name" :title="stepTitle(step)">
<template v-if="'executionKind' in step">
<p>
{{
step.executionKind === 'executed'
? '本次执行步骤'
: step.executionKind === 'reused'
? '复用已有步骤,不重复提交'
: '执行方式未记录'
}}
</p>
<p v-if="step.usageAttribution === 'reused'" class="text-muted">以下为原调用计量,不重复计入本次。</p>
<p v-else-if="step.usageAttribution === 'unknown'" class="text-muted">
计量归属未记录,不能推算本次费用。
</p>
</template>
<ul v-if="step.issues?.length" class="mt-2 space-y-1 text-xs">
<li v-for="(issue, index) in step.issues" :key="index">
{{ issue.subjectRef ? issue.subjectRef + ' · ' : '' }}{{ userFacingText(issue.description) }}
</li>
</ul>
<p v-else class="mt-2 text-xs text-muted">{{ step.issues ? '未记录问题。' : '未记录问题证据。' }}</p>
<p v-if="step.error" class="mt-2 text-sm">{{ userFacingText(step.error) }}</p>
<!-- 以下是必要的原始请求、时间和计量,默认收起 -->
<NCollapse class="mt-2"
><NCollapseItem name="diagnostics" title="高级详情">
<dl class="space-y-1 wrap-anywhere text-xs text-muted">
<div v-if="step.startedAt">开始:{{ formatDate(step.startedAt) }}</div>
<div v-if="step.finishedAt">完成:{{ formatDate(step.finishedAt) }}</div>
<div v-if="step.requestId">请求编号:{{ step.requestId }}</div>
<div v-if="step.providerRequestId">模型服务请求编号:{{ step.providerRequestId }}</div>
<div v-if="'sourceExecutionId' in step && step.sourceExecutionId">
复用来源执行:{{ step.sourceExecutionId }}
</div>
<div v-if="'usageAttribution' in step">
计量归属:{{
step.usageAttribution === 'this_execution'
? '本次新调用'
: step.usageAttribution === 'reused'
? '原调用复用'
: '未记录'
}}
</div>
<div v-for="(count, unit) in step.usage" :key="unit">
{{ validationUsageLabels[unit] }}词元:{{ count }}
</div>
<div v-if="!step.usage || !Object.keys(step.usage).length">未记录计量。</div>
</dl>
</NCollapseItem></NCollapse
>
</NCollapseItem>
</NCollapse>
</template>