@@ -10,7 +10,6 @@ import { promisify } from 'node:util'
10
10
import pdfToText from 'pdf-parse-fork'
11
11
import { pdfToPng , type PngPageOutput } from 'pdf-to-png-converter'
12
12
import logger from './logger.ts'
13
- import { MARKDOWN_PROMPT , TRANSCRIPTION_PROMPT_2 } from './prompts.ts'
14
13
15
14
dotenv . config ( )
16
15
@@ -304,7 +303,13 @@ const worker = new Worker(
304
303
headers : { 'Content-Type' : 'application/json' } ,
305
304
body : JSON . stringify ( {
306
305
model : 'qwen2.5vl:7b' ,
307
- system : TRANSCRIPTION_PROMPT_2 ,
306
+ system : `Your task is to transcribe the content of a PDF page given to you as an image.
307
+ If the given PDF page contains an image, or a diagram, describe it in detail.
308
+ Enclose the description in an **image** tag. For example: **image** This is an image of a cat. **image**.
309
+ You are also given the text extracted from the PDF using a PDF parser.
310
+ Your task is to combine these two sources of information to produce the most accurate transcription possible.
311
+ When there are discrepancies between the image transcription and the PDF text, prioritize the parsed PDF text.
312
+ But you are always obligated to keep the **image** tags intact.` ,
308
313
prompt : `Parsed PDF text:\n${ pdfText } \n\nImage transcription:` ,
309
314
stream : false ,
310
315
images : [ image . toString ( 'base64' ) ] ,
@@ -335,7 +340,13 @@ const worker = new Worker(
335
340
} ,
336
341
body : JSON . stringify ( {
337
342
model : 'qwen2.5vl:7b' ,
338
- system : MARKDOWN_PROMPT ,
343
+ system : `Your task is to accurately extract and combine text from image transcription and PDF sources into Markdown.
344
+ You are given text containing both the transcription text and PDF text.
345
+ When there are discrepancies between the transcription text and the PDF text, prioritize the PDF text!
346
+ Transcription can contain errors, PDF is the source of truth! If the texts are similar, merge them to create a comprehensive version.
347
+ Ensure the final output is well-structured Markdown and free of errors. Do not output anything else than Markdown.
348
+ Do not surround the output with a Markdown code block! Use headings, lists, bold, italics, tables etc. where appropriate.
349
+ Remeber you are always obligated to keep the **image** tags and tags insides intact.` ,
339
350
prompt : `Transcription:\n${ transcription } \n\nPDF:\n${ pdfText } \n\nCombined Markdown:` ,
340
351
stream : false ,
341
352
} ) ,
0 commit comments