Commit ecad083f authored by Ethan0x0000's avatar Ethan0x0000
Browse files

fix(ops): prefer upstream_model in ops error displays

parent bd8eadb7
...@@ -59,13 +59,13 @@ ...@@ -59,13 +59,13 @@
<div class="rounded-xl bg-gray-50 p-4 dark:bg-dark-900"> <div class="rounded-xl bg-gray-50 p-4 dark:bg-dark-900">
<div class="text-xs font-bold uppercase tracking-wider text-gray-400">{{ t('admin.ops.errorDetail.model') }}</div> <div class="text-xs font-bold uppercase tracking-wider text-gray-400">{{ t('admin.ops.errorDetail.model') }}</div>
<div class="mt-1 text-sm font-medium text-gray-900 dark:text-white"> <div class="mt-1 text-sm font-medium text-gray-900 dark:text-white">
<template v-if="detail.requested_model && detail.upstream_model && detail.requested_model !== detail.upstream_model"> <template v-if="hasModelMapping(detail)">
<span class="font-mono">{{ detail.requested_model }}</span> <span class="font-mono">{{ detail.requested_model }}</span>
<span class="mx-1 text-gray-400"></span> <span class="mx-1 text-gray-400"></span>
<span class="font-mono text-primary-600 dark:text-primary-400">{{ detail.upstream_model }}</span> <span class="font-mono text-primary-600 dark:text-primary-400">{{ detail.upstream_model }}</span>
</template> </template>
<template v-else> <template v-else>
{{ detail.requested_model || detail.model || '' }} {{ displayModel(detail) || '' }}
</template> </template>
</div> </div>
</div> </div>
...@@ -250,6 +250,22 @@ function formatRequestTypeLabel(type: number | null | undefined): string { ...@@ -250,6 +250,22 @@ function formatRequestTypeLabel(type: number | null | undefined): string {
} }
} }
function hasModelMapping(d: OpsErrorDetail | null): boolean {
if (!d) return false
const requested = String(d.requested_model || '').trim()
const upstream = String(d.upstream_model || '').trim()
return !!requested && !!upstream && requested !== upstream
}
function displayModel(d: OpsErrorDetail | null): string {
if (!d) return ''
const upstream = String(d.upstream_model || '').trim()
if (upstream) return upstream
const requested = String(d.requested_model || '').trim()
if (requested) return requested
return String(d.model || '').trim()
}
const correlatedUpstream = ref<OpsErrorDetail[]>([]) const correlatedUpstream = ref<OpsErrorDetail[]>([])
const correlatedUpstreamLoading = ref(false) const correlatedUpstreamLoading = ref(false)
......
...@@ -99,8 +99,8 @@ ...@@ -99,8 +99,8 @@
<!-- Model --> <!-- Model -->
<td class="px-4 py-2"> <td class="px-4 py-2">
<div class="max-w-[160px]"> <div class="max-w-[160px]">
<template v-if="log.requested_model && log.upstream_model && log.requested_model !== log.upstream_model"> <template v-if="hasModelMapping(log)">
<el-tooltip :content="`${log.requested_model} → ${log.upstream_model}`" placement="top" :show-after="500"> <el-tooltip :content="modelMappingTooltip(log)" placement="top" :show-after="500">
<span class="flex items-center gap-1 truncate font-mono text-[11px] text-gray-700 dark:text-gray-300"> <span class="flex items-center gap-1 truncate font-mono text-[11px] text-gray-700 dark:text-gray-300">
<span class="truncate">{{ log.requested_model }}</span> <span class="truncate">{{ log.requested_model }}</span>
<span class="flex-shrink-0 text-gray-400"></span> <span class="flex-shrink-0 text-gray-400"></span>
...@@ -232,8 +232,26 @@ function formatEndpointTooltip(log: OpsErrorLog): string { ...@@ -232,8 +232,26 @@ function formatEndpointTooltip(log: OpsErrorLog): string {
return parts.join('\n') || '' return parts.join('\n') || ''
} }
function hasModelMapping(log: OpsErrorLog): boolean {
const requested = String(log.requested_model || '').trim()
const upstream = String(log.upstream_model || '').trim()
return !!requested && !!upstream && requested !== upstream
}
function modelMappingTooltip(log: OpsErrorLog): string {
const requested = String(log.requested_model || '').trim()
const upstream = String(log.upstream_model || '').trim()
if (!requested && !upstream) return ''
if (requested && upstream) return `${requested}${upstream}`
return upstream || requested
}
function displayModel(log: OpsErrorLog): string { function displayModel(log: OpsErrorLog): string {
return log.requested_model || log.model || '' const upstream = String(log.upstream_model || '').trim()
if (upstream) return upstream
const requested = String(log.requested_model || '').trim()
if (requested) return requested
return String(log.model || '').trim()
} }
function formatRequestType(type: number | null | undefined): string { function formatRequestType(type: number | null | undefined): string {
...@@ -315,4 +333,4 @@ function formatSmartMessage(msg: string): string { ...@@ -315,4 +333,4 @@ function formatSmartMessage(msg: string): string {
return msg.length > 200 ? msg.substring(0, 200) + '...' : msg return msg.length > 200 ? msg.substring(0, 200) + '...' : msg
} }
</script> </script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment