feat: robust metric extraction with confidence score and proof snippets

- fixed Year-Prefix Bug in MetricParser
- added metric_confidence and metric_proof_text to database
- added Entity-Check and Annual-Priority to LLM prompt
- improved UI: added confidence traffic light and mouse-over proof tooltip
- restored missing API endpoints (create, bulk, wiki-override)
This commit is contained in:
2026-01-23 21:16:07 +00:00
parent b4595ef974
commit 5721c05688
7006 changed files with 1367435 additions and 201 deletions

View File

@@ -43,6 +43,9 @@ type CompanyDetail = {
standardized_metric_unit: string | null
metric_source: string | null
metric_source_url: string | null
metric_proof_text: string | null
metric_confidence: number | null
metric_confidence_reason: string | null
}
export function Inspector({ companyId, initialContactId, onClose, apiBase }: InspectorProps) {
@@ -909,18 +912,44 @@ export function Inspector({ companyId, initialContactId, onClose, apiBase }: Ins
</div>
)}
{/* Source */}
{/* Source & Confidence */}
{data.metric_source && (
<div className="flex justify-end items-center gap-1 text-[10px] text-slate-500 pt-2 border-t border-slate-200 dark:border-slate-800">
<Database className="h-3 w-3" />
<span>Source:</span>
{data.metric_source_url ? (
<a href={data.metric_source_url} target="_blank" rel="noopener noreferrer" className="font-medium text-blue-600 dark:text-blue-400 capitalize hover:underline">
{data.metric_source}
</a>
) : (
<span className="font-medium text-slate-600 dark:text-slate-400 capitalize">{data.metric_source}</span>
<div className="flex justify-between items-center text-[10px] text-slate-500 pt-2 border-t border-slate-200 dark:border-slate-800">
{/* Confidence Score */}
{data.metric_confidence != null && (
<div className="flex items-center gap-1.5" title={data.metric_confidence_reason || "No reason provided"}>
<span className="uppercase font-bold tracking-tight text-[9px]">Confidence:</span>
<div className="flex items-center gap-1">
<div className={clsx("h-2 w-2 rounded-full",
data.metric_confidence >= 0.8 ? "bg-green-500" :
data.metric_confidence >= 0.5 ? "bg-yellow-500" : "bg-red-500")} />
<span className={clsx("font-medium",
data.metric_confidence >= 0.8 ? "text-green-700 dark:text-green-400" :
data.metric_confidence >= 0.5 ? "text-yellow-700 dark:text-yellow-400" : "text-red-700 dark:text-red-400"
)}>
{(data.metric_confidence * 100).toFixed(0)}%
</span>
</div>
</div>
)}
{/* Source Link */}
<div className="flex items-center gap-1">
<Database className="h-3 w-3" />
<span>Source:</span>
<span
title={data.metric_proof_text || "No proof text available"}
className="font-medium text-slate-600 dark:text-slate-400 capitalize cursor-help border-b border-dotted border-slate-400"
>
{data.metric_source}
</span>
{data.metric_source_url && (
<a href={data.metric_source_url} target="_blank" rel="noopener noreferrer" className="ml-1 text-blue-600 dark:text-blue-400 hover:underline">
<ExternalLink className="h-3 w-3 inline" />
</a>
)}
</div>
</div>
)}