diff --git a/admin-ui/src/views/chorus/generations/helpers.js b/admin-ui/src/views/chorus/generations/helpers.js new file mode 100644 index 0000000..974426c --- /dev/null +++ b/admin-ui/src/views/chorus/generations/helpers.js @@ -0,0 +1,37 @@ +const eventTitle = attempt => { + if (attempt.type === 'lease') return '任务认领' + if (attempt.type === 'local_rate_limit') return '本地限流' + if (attempt.type === 'provider') return attempt.provider_model_id ? `模型 #${attempt.provider_model_id}` : '模型未记录' + return '系统事件' +} + +export function attemptPresentation(value) { + const attempt = value && typeof value === 'object' ? value : {} + const presentation = { + title: eventTitle(attempt), + status: '进行中', + type: 'warning', + timestamp: attempt.finished_at || attempt.started_at || attempt.deferred_until || '' + } + + if (attempt.error_code) { + presentation.status = attempt.error_code + presentation.type = 'danger' + return presentation + } + if (attempt.type === 'lease') { + presentation.status = '已认领' + presentation.type = 'primary' + return presentation + } + if (attempt.type === 'local_rate_limit') { + presentation.status = attempt.deferred_until ? '等待限流窗口' : '限流检查完成' + presentation.type = attempt.deferred_until ? 'warning' : 'info' + return presentation + } + if (attempt.finished_at) { + presentation.status = '成功' + presentation.type = 'success' + } + return presentation +} diff --git a/admin-ui/src/views/chorus/generations/index.vue b/admin-ui/src/views/chorus/generations/index.vue index ded52a9..c1a1693 100644 --- a/admin-ui/src/views/chorus/generations/index.vue +++ b/admin-ui/src/views/chorus/generations/index.vue @@ -11,7 +11,7 @@
选择一条生成记录查看详情
{{ attempt.error_code || (attempt.succeeded ? '成功' : '失败') }} · {{ attempt.error_message }}
尚无尝试记录。
+{{ attempt.presentation.status }} · {{ attempt.error_message }}
尚无尝试记录。
@@ -20,10 +20,11 @@