• New

New

/** * v0 by Vercel. * @see https://v0.dev/t/tL9Ma0PmuCy * Documentation: https://v0.dev/docs#integrating-generated-code-into-your-nextjs-app */ “use client” import { useState } from “react” import { Button } from “@/components/ui/button” export default function Component() { const [documentUrl, setDocumentUrl] = useState(“”) const [pdfFile, setPdfFile] = useState(null) const [summary, setSummary] = useState(“”) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const handleUrlChange = (e) => { setDocumentUrl(e.target.value) } const handleFileChange = (e) => { setPdfFile(e.target.files[0]) } const generateSummary = async () => { setLoading(true) setError(null) try { let documentContent if (documentUrl) { const response = await fetch(“YOUR_API_URL”) documentContent = await response.text() } else if (pdfFile) { const pdfBytes = await pdfFile.arrayBuffer() documentContent = await pdfToText(pdfBytes) } else { setError(“Please provide a document URL or upload a PDF file.”) return } const summary = await summarizeDocument(documentContent) setSummary(summary) } catch (err) { setError(“Error generating summary. Please try again later.”) } finally { setLoading(false) } } const pdfToText = async (pdfBytes) => { const pdf = await pdfjsLib.getDocument(pdfBytes).promise const page = await pdf.getPage(1) const textContent = await page.getTextContent() return textContent.items.map((item) => item.str).join(” “) } const summarizeDocument = async (documentContent) => { const summary = await nlpLib.summarize(documentContent, { maxSentences: 5 }) return summary } return (

Document Summarizer

{error &&

{error}

} {summary && (

Summary

{summary}

)}

) }

Scroll
0964997777
0964997777