export const RULE_TYPE_LABEL: Record = { keyword_match: '关键词匹配', response_time: '响应时长', llm_score: 'LLM 评分', } export const RULE_TYPE_DESC: Record = { keyword_match: '关键词命中比例', response_time: '智能体首响时延', llm_score: '大模型综合评分 (0–10)', } export function ruleTypeLabel(type: string): string { return RULE_TYPE_LABEL[type] || type } /** Convert stored score (0–1) into a human-readable display in the rule's natural unit. */ export function formatRuleScore(type: string, score?: number | null): string { if (score == null) return '-' switch (type) { case 'keyword_match': return `${Math.round(score * 100)}%` case 'llm_score': return `${(score * 10).toFixed(1)}/10` case 'response_time': // score is inverted latency ratio; not directly meaningful. Show raw score. return score.toFixed(2) default: return score.toFixed(2) } }