| // src/components/discovery/SummarizerPanel.tsx | |
| import { useState } from "react"; | |
| import { useResearchSummarizer } from "@/hooks/useResearchSummarizer"; | |
| import { Sparkles, Loader2, FileText, ChevronDown, ChevronUp } from "lucide-react"; | |
| import type { SummaryLevel } from "@/types/discovery"; | |
| export function SummarizerPanel() { | |
| const { summary, loading, level, setLevel, summarize } = useResearchSummarizer(); | |
| const [paperId, setPaperId] = useState(""); | |
| return ( | |
| <div className="space-y-4"> | |
| <h2 className="text-xl font-bold flex items-center gap-2"><Sparkles className="w-5 h-5 text-purple-500"/> AI Research Summarizer</h2> | |
| <div className="flex gap-2"> | |
| <input type="text" value={paperId} onChange={e => setPaperId(e.target.value)} placeholder="Enter article ID or DOI" className="input flex-1"/> | |
| <button onClick={() => summarize(paperId)} disabled={!paperId.trim() || loading} className="btn btn-primary gap-2"> | |
| {loading ? <Loader2 className="w-4 h-4 animate-spin"/> : <Sparkles className="w-4 h-4"/>} | |
| Summarize | |
| </button> | |
| </div> | |
| <div className="flex gap-2"> | |
| {(["tldr","paragraph","page"] as SummaryLevel[]).map(l => ( | |
| <button key={l} onClick={() => setLevel(l)} className={`px-4 py-1.5 text-sm rounded-full ${level === l ? "bg-primary text-white" : "bg-white/10 text-gray-500"}`}>{l}</button> | |
| ))} | |
| </div> | |
| {summary && ( | |
| <div className="glass rounded-xl p-5 space-y-4"> | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase">TL;DR</h4> | |
| <p className="text-sm">{summary.tldr}</p> | |
| </div> | |
| {level !== "tldr" && ( | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase">{level === "paragraph" ? "One Paragraph" : "One Page Summary"}</h4> | |
| <p className="text-sm whitespace-pre-wrap">{summary[level]}</p> | |
| </div> | |
| )} | |
| {summary.keyFigures.length > 0 && ( | |
| <div> | |
| <h4 className="text-xs font-semibold text-gray-500 uppercase">Key Figures</h4> | |
| <div className="flex gap-2 mt-2"> | |
| {summary.keyFigures.map((fig, i) => ( | |
| <img key={i} src={fig.url} alt={fig.caption} className="w-24 h-16 object-cover rounded-lg" title={fig.caption}/> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 2.48 kB
- Xet hash:
- bdb5fa5530a3b4ac5802552ac05cc0dccc696434c86ada5e945dbec5bfba7d55
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.