web_based_rag / frontend /src /components /results /ConfidenceIndicator.tsx
yuvrajsingh6
feat: RAG system with OCR for Hugging Face Spaces
4d592a4
import React from 'react';
interface ConfidenceIndicatorProps {
confidence: number;
}
export const ConfidenceIndicator: React.FC<ConfidenceIndicatorProps> = ({ confidence }) => {
const getColor = () => {
if (confidence >= 80) return 'text-green-500';
if (confidence >= 60) return 'text-yellow-500';
return 'text-red-500';
};
const getBgColor = () => {
if (confidence >= 80) return 'bg-green-500';
if (confidence >= 60) return 'bg-yellow-500';
return 'bg-red-500';
};
const getLabel = () => {
if (confidence >= 80) return 'High';
if (confidence >= 60) return 'Medium';
return 'Low';
};
return (
<div className="flex items-center gap-2" title={`Confidence: ${confidence}%`}>
<div className="w-16 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden">
<div
className={`h-full ${getBgColor()} transition-all duration-500`}
style={{ width: `${confidence}%` }}
/>
</div>
<span className={`text-xs font-medium ${getColor()}`}>
{confidence}%
</span>
<span className={`text-xs font-medium ${getColor()}`}>
{getLabel()}
</span>
</div>
);
};