File size: 1,397 Bytes
25d0747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { motion } from 'framer-motion';

const IntentProbabilities = ({ probabilities }) => {
  if (!probabilities) return null;

  const intents = Object.entries(probabilities).map(([intent, prob]) => ({
    name: intent,
    value: prob,
    color: getIntentColor(intent)
  }));

  function getIntentColor(intent) {
    const colors = {
      agreement: 'bg-green-500',
      confusion: 'bg-red-500',
      hesitation: 'bg-yellow-500',
      confidence: 'bg-blue-500',
      neutral: 'bg-gray-500'
    };
    return colors[intent] || 'bg-gray-500';
  }

  return (
    <div className="bg-gray-800 rounded-xl p-4 glassmorphism">
      <h2 className="text-xl font-semibold mb-4 text-lime-400">Intent Probabilities</h2>
      <div className="space-y-3">
        {intents.map((intent, index) => (
          <div key={intent.name}>
            <div className="flex justify-between text-sm mb-1">
              <span className="capitalize">{intent.name}</span>
              <span>{(intent.value * 100).toFixed(1)}%</span>
            </div>
            <motion.div
              initial={{ width: 0 }}
              animate={{ width: `${intent.value * 100}%` }}
              transition={{ duration: 0.5, delay: index * 0.1 }}
              className={`h-3 ${intent.color} rounded-full`}
            />
          </div>
        ))}
      </div>
    </div>
  );
};

export default IntentProbabilities;