mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
feat(documents): rasterize PDFs so image-only-wire providers can read them
Only Anthropic accepts a native PDF block; codex and other image-only-wire providers dropped it. Add a bounded, best-effort server-side rasterizer that renders a PDF's pages to JPEG images those providers read as ordinary image input, so a scanned/image-only PDF is legible on the auto-read path. - @napi-rs/canvas promoted to a direct dependency; its musl prebuilts + the pdfjs loader pinned into the standalone trace (next.config.ts) - rasterize-pdf.ts: lazy pdfjs import (keeps DOMMatrix out of the eager chunk), first 10 pages, 1600px long edge, JPEG q80, never throws - prepareVisionInput rasterizes a PDF for a non-Anthropic vision provider and keeps the native PDF block for Anthropic; the document capability reports PDFs readable via raster so the UI offers the read
This commit is contained in:
1 parent
73a3ac9c36
commit
d2451021bc
12 files changed
+366
-21
No files matched your search
@@ -184,7 +184,7 @@ async function handleVisionIndex(
|
||||
);
|
||||
if (!rl.allowed) return rateLimited(rl);
|
||||
|
||||
const vision = prepareVisionInput(document, pick.pdfSupported);
|
||||
const vision = await prepareVisionInput(document, pick.pdfSupported);
|
||||
if (!vision.ok) {
|
||||
if (vision.reason === "pdfNeedsAnthropic") {
|
||||
return apiError(
|
||||
|
||||
@@ -233,7 +233,7 @@ async function handleVisionSuggest(
|
||||
);
|
||||
if (!rl.allowed) return rateLimited(rl);
|
||||
|
||||
const vision = prepareVisionInput(document, pick.pdfSupported);
|
||||
const vision = await prepareVisionInput(document, pick.pdfSupported);
|
||||
if (!vision.ok) {
|
||||
if (vision.reason === "pdfNeedsAnthropic") {
|
||||
return apiError(
|
||||
|
||||
@@ -258,7 +258,7 @@ async function handleVisionSummary(
|
||||
);
|
||||
if (!rl.allowed) return rateLimited(rl);
|
||||
|
||||
const vision = prepareVisionInput(document, pick.pdfSupported);
|
||||
const vision = await prepareVisionInput(document, pick.pdfSupported);
|
||||
if (!vision.ok) {
|
||||
if (vision.reason === "pdfNeedsAnthropic") {
|
||||
return apiError(
|
||||
|
||||
Reference in new issue
Block a user