'use client'; // File: components/ai/intent-classification/classification-result-card.tsx // Change Log // - 2026-05-19: สร้าง Classification Result Card component (ADR-024). import { Badge } from '@/components/ui/badge'; import { Card, CardContent } from '@/components/ui/card'; import type { ClassificationResult } from '@/lib/services/ai-intent.service'; interface ClassificationResultCardProps { query: string; result: ClassificationResult; } /** สีของ method badge */ const METHOD_COLORS: Record = { pattern: 'bg-green-100 text-green-800 border-green-200', llm_fallback: 'bg-blue-100 text-blue-800 border-blue-200', semaphore_overflow: 'bg-yellow-100 text-yellow-800 border-yellow-200', llm_error: 'bg-red-100 text-red-800 border-red-200', }; /** สีของ confidence bar */ function getConfidenceColor(confidence: number): string { if (confidence >= 0.9) return 'bg-green-500'; if (confidence >= 0.7) return 'bg-blue-500'; if (confidence >= 0.5) return 'bg-yellow-500'; return 'bg-red-500'; } /** * Card แสดงผลลัพธ์การจำแนก Intent * แสดง intentCode, confidence, method, latency */ export function ClassificationResultCard({ query, result, }: ClassificationResultCardProps) { const confidencePercent = Math.round(result.confidence * 100); return ( {/* Query */}

"{query}"

{/* Intent Code + Method */}
{result.intentCode}
{result.method} {result.latencyMs}ms
{/* Confidence Bar */}
{confidencePercent}%
{/* Params (ถ้ามี) */} {result.params && Object.keys(result.params).length > 0 && (
            {JSON.stringify(result.params, null, 2)}
          
)} ); }