| // src/components/multimodal/AIChatAnalysisPanel.tsx | |
| import type { AIAnalysisResult } from "@/types/multimodal"; | |
| import { Sparkles, ChevronRight, X, Loader2 } from "lucide-react"; | |
| interface AIChatAnalysisPanelProps { | |
| isOpen: boolean; | |
| onClose: () => void; | |
| analysis: AIAnalysisResult | null; | |
| loading: boolean; | |
| onAskFollowUp: (question: string) => void; | |
| } | |
| const FOLLOW_UP_SUGGESTIONS = [ | |
| "Summarize this", | |
| "Find key trends", | |
| "Suggest visualizations", | |
| "Explain in simple terms", | |
| ]; | |
| export function AIChatAnalysisPanel({ | |
| isOpen, | |
| onClose, | |
| analysis, | |
| loading, | |
| onAskFollowUp, | |
| }: AIChatAnalysisPanelProps) { | |
| if (!isOpen) return null; | |
| return ( | |
| <div className="w-96 bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 flex flex-col h-full"> | |
| {/* Header */} | |
| <div className="p-4 border-b flex items-center justify-between"> | |
| <h3 className="font-semibold flex items-center gap-2"> | |
| <Sparkles className="w-4 h-4 text-primary" /> | |
| AI Analysis | |
| </h3> | |
| <button onClick={onClose} className="text-gray-500 hover:text-gray-700"> | |
| <X className="w-4 h-4" /> | |
| </button> | |
| </div> | |
| {/* Content */} | |
| <div className="flex-1 overflow-y-auto p-4 space-y-4"> | |
| {loading ? ( | |
| <div className="flex flex-col items-center justify-center py-12 gap-3"> | |
| <Loader2 className="w-8 h-8 animate-spin text-primary" /> | |
| <p className="text-sm text-gray-500">Analyzing your file...</p> | |
| </div> | |
| ) : analysis ? ( | |
| <> | |
| {/* Summary */} | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase mb-1">Summary</h4> | |
| <p className="text-sm text-gray-800 dark:text-gray-200">{analysis.summary}</p> | |
| </div> | |
| {/* Key Points */} | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase mb-2">Key Points</h4> | |
| <ul className="space-y-1.5"> | |
| {analysis.keyPoints.map((point, i) => ( | |
| <li key={i} className="flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300"> | |
| <ChevronRight className="w-3.5 h-3.5 text-primary mt-0.5 shrink-0" /> | |
| {point} | |
| </li> | |
| ))} | |
| </ul> | |
| </div> | |
| {/* Chart Suggestions */} | |
| {analysis.chartSuggestions && analysis.chartSuggestions.length > 0 && ( | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase mb-1"> | |
| Suggested Visualizations | |
| </h4> | |
| <div className="flex flex-wrap gap-1"> | |
| {analysis.chartSuggestions.map((s, i) => ( | |
| <span key={i} className="text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full"> | |
| {s} | |
| </span> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| {/* Confidence */} | |
| <div className="flex items-center gap-2 text-xs text-gray-400"> | |
| <span>Confidence: {Math.round(analysis.confidence * 100)}%</span> | |
| <div className="flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full"> | |
| <div | |
| className="h-full bg-primary rounded-full" | |
| style={{ width: `${analysis.confidence * 100}%` }} | |
| /> | |
| </div> | |
| </div> | |
| </> | |
| ) : ( | |
| <div className="text-center py-12 text-gray-400"> | |
| <Sparkles className="w-10 h-10 mx-auto mb-3 opacity-30" /> | |
| <p className="text-sm">Click "Ask AI" on a file to analyze it</p> | |
| </div> | |
| )} | |
| </div> | |
| {/* Follow‑up suggestions */} | |
| {analysis && ( | |
| <div className="p-4 border-t"> | |
| <p className="text-xs text-gray-400 mb-2">Ask a follow‑up:</p> | |
| <div className="flex flex-wrap gap-1.5"> | |
| {FOLLOW_UP_SUGGESTIONS.map((q) => ( | |
| <button | |
| key={q} | |
| onClick={() => onAskFollowUp(q)} | |
| className="text-xs px-3 py-1.5 bg-gray-100 dark:bg-gray-700 rounded-full hover:bg-primary/10 hover:text-primary transition" | |
| > | |
| {q} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 4.43 kB
- Xet hash:
- 04c62b467ce22c0721a7acaf64d05c91b45985538757427728622ce2ab39da6a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.