This commit is contained in:
2026-07-14 15:09:32 -05:00
parent 7b99d18f2c
commit e367b6ac29

View File

@@ -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<void> {
async function callVision(api: string, images: string[], timeoutMs: number): Promise<VisionRaw> {
const content: Array<Record<string, unknown>> = [{ 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 = {