(title, sourceNodes, sourceEdges, entries, topPapers)
| 3424 | const isPdf = kind === "pdf"; |
| 3425 | const sourceLabel = isPdf ? ui().common.localPdf : ui().common.arxiv; |
| 3426 | const payload = { |
| 3427 | user_id: currentUser(), |
| 3428 | write_feishu: isPdf ? Boolean($("directPdfWriteFeishu")?.checked) : Boolean($("directWriteFeishu")?.checked) |
| 3429 | }; |
| 3430 | let route = "/api/read/arxiv"; |
| 3431 | if (!isPdf) { |
| 3432 | const raw = $("directArxivId").value.trim(); |
| 3433 | payload.arxiv_id = raw.replace(/^https?:\/\/arxiv\.org\/abs\//, ""); |
| 3434 | if (!payload.arxiv_id) { |
| 3435 | setDirectReadStatus("arxiv", "warning", ui().reports.arxivRequiredTitle, ui().reports.arxivRequiredDetail); |
| 3436 | throw new Error(ui().reports.arxivRequiredTitle); |
| 3437 | } |
| 3438 | } else { |
| 3439 | route = "/api/read/pdf"; |
| 3440 | payload.pdf_path = $("directPdfPath").value.trim(); |
| 3441 | payload.title = $("directPdfTitle").value.trim(); |
| 3442 | if (!payload.pdf_path) { |
| 3443 | setDirectReadStatus("pdf", "warning", ui().reports.pdfRequiredTitle, ui().reports.pdfRequiredDetail); |
| 3444 | throw new Error(ui().reports.pdfRequiredTitle); |
| 3445 | } |
| 3446 | } |
| 3447 | payload.response_language = responseLanguage(); |
| 3448 | setDirectReadBusy(kind, true); |
| 3449 | setDirectReadStatus( |
| 3450 | kind, |
| 3451 | "pending", |
| 3452 | ui().reports.generatingTitle(sourceLabel), |
| 3453 | ui().reports.generatingDetail |
| 3454 | ); |
| 3455 | try { |
| 3456 | const data = await api(route, { method: "POST", body: JSON.stringify(payload) }); |
| 3457 | const reports = data.reports || data; |
| 3458 | const doc = reports?.created_docs?.[0]; |
| 3459 | if (!doc?.report_id) { |
| 3460 | throw new Error(ui().reports.missingReportId); |
| 3461 | } |
| 3462 | const reportTitle = doc.title || doc.paper?.title || ui().reports.defaultTitle; |
| 3463 | const reportPath = doc.report_path || ""; |
| 3464 | const warning = reports.feishu_warning || ""; |
no test coverage detected