From e367b6ac294845f560bd83d72c3101018241382a Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Tue, 14 Jul 2026 15:09:32 -0500 Subject: [PATCH] dfgdfg --- vision_runner.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vision_runner.ts b/vision_runner.ts index 4105545..d4b7d6e 100644 --- a/vision_runner.ts +++ b/vision_runner.ts @@ -310,7 +310,7 @@ const SYSTEM_PROMPT = "including typos. You never guess, infer, or invent values. If a field is blank " + "or unreadable, you return null."; -const USER_PROMPT = `You see all pages of one PDF, in order (image 1 = page 1). +const USER_PROMPT = `You see all pages of one PDF, in order. Each image is preceded by a text marker "=== PAGE N ===" that tells you its exact page number. Use these markers to assign page numbers — never guess a page number. Task: Identify the page types by their headings, then transcribe form fields from a business brokerage "BUYER INFORMATION SHEET" package. @@ -381,8 +381,11 @@ async function waitForHealthy(api: string, timeoutMs: number): Promise { async function callVision(api: string, images: string[], timeoutMs: number): Promise { const content: Array> = [{ type: "text", text: USER_PROMPT }]; - for (const img of images) { - const b64 = await fsp.readFile(img, { encoding: "base64" }); + // Vor jedes Bild einen Seiten-Marker setzen, damit das Modell zweifelsfrei + // weiss, welches Bild welche Seitennummer ist (loest Info/Notes-Verwechslung). + for (let i = 0; i < images.length; i++) { + const b64 = await fsp.readFile(images[i], { encoding: "base64" }); + content.push({ type: "text", text: `=== PAGE ${i + 1} ===` }); content.push({ type: "image_url", image_url: { url: `data:image/png;base64,${b64}` } }); } const body = {