fix(data-process): 补齐原文参照与详情统计
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import type { ResultItem } from './types'
|
||||
import type { PreviewItem, ResultItem } from './types'
|
||||
|
||||
const props = defineProps<{
|
||||
items: ResultItem[]
|
||||
previewItems: PreviewItem[]
|
||||
selectedId: string | null
|
||||
}>()
|
||||
|
||||
@@ -17,6 +18,35 @@ const search = ref('')
|
||||
const invalidOnly = ref(false)
|
||||
const selectedItem = computed(() => props.items.find((item) => item.id === props.selectedId) ?? props.items[0])
|
||||
const selectedIndex = computed(() => props.items.findIndex((item) => item.id === selectedItem.value?.id))
|
||||
const selectedSource = computed(() => {
|
||||
const previewItemId = selectedItem.value?.previewItemId
|
||||
if (!previewItemId) return null
|
||||
return props.previewItems.find((item) => item.id === previewItemId) ?? null
|
||||
})
|
||||
const selectedSourceContent = computed(() => (
|
||||
selectedSource.value?.editedContent.trim()
|
||||
|| selectedSource.value?.originalContent.trim()
|
||||
|| ''
|
||||
))
|
||||
const selectedSourceWasPreprocessed = computed(() => Boolean(
|
||||
selectedSource.value
|
||||
&& selectedSource.value.editedContent.trim()
|
||||
&& selectedSource.value.editedContent !== selectedSource.value.originalContent
|
||||
))
|
||||
const selectedSourceMeta = computed(() => {
|
||||
const source = selectedSource.value
|
||||
if (!source) return ''
|
||||
const parts: string[] = []
|
||||
if (source.sourceStartLine != null) {
|
||||
parts.push(
|
||||
source.sourceEndLine != null && source.sourceEndLine !== source.sourceStartLine
|
||||
? `第 ${source.sourceStartLine}–${source.sourceEndLine} 行`
|
||||
: `第 ${source.sourceStartLine} 行`,
|
||||
)
|
||||
}
|
||||
if (source.tokenCount > 0) parts.push(`${source.tokenCount} Token`)
|
||||
return parts.join(' · ')
|
||||
})
|
||||
|
||||
const filteredItems = computed(() => props.items.filter((item, index) => {
|
||||
const keyword = search.value.trim().toLowerCase()
|
||||
@@ -79,6 +109,19 @@ function selectRelative(offset: number) {
|
||||
<el-button link @click="emit('restore:item', selectedItem.id)"><i class="fa fa-undo" /> 恢复生成结果</el-button>
|
||||
</div>
|
||||
|
||||
<article class="source-reference" aria-labelledby="source-reference-title">
|
||||
<div class="source-reference-heading">
|
||||
<div>
|
||||
<strong id="source-reference-title">原文参照</strong>
|
||||
<span v-if="selectedSourceMeta">{{ selectedSourceMeta }}</span>
|
||||
</div>
|
||||
<el-tag v-if="selectedSourceWasPreprocessed" size="small" effect="plain">已智能预处理</el-tag>
|
||||
</div>
|
||||
<pre v-if="selectedSourceContent">{{ selectedSourceContent }}</pre>
|
||||
<p v-else>当前结果没有关联到可用的原文切片。</p>
|
||||
<small v-if="selectedSourceWasPreprocessed">这里展示的是实际送入模型的预处理后原文,便于核对问题和答案是否有依据。</small>
|
||||
</article>
|
||||
|
||||
<div class="field-editor">
|
||||
<label>Instruction <em>必填</em></label>
|
||||
<el-input
|
||||
@@ -255,6 +298,62 @@ function selectRelative(offset: number) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.source-reference {
|
||||
margin: 14px 18px 2px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #dfe4ec;
|
||||
border-radius: 7px;
|
||||
background: #f8fafc;
|
||||
|
||||
pre {
|
||||
max-height: 168px;
|
||||
margin: 10px 0 0;
|
||||
overflow: auto;
|
||||
color: #344054;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 10px 0 0;
|
||||
color: #98a2b3;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
> small {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
color: #8a93a3;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.source-reference-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
|
||||
> div {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #344054;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #8a93a3;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.field-editor {
|
||||
padding: 13px 18px 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user