Skip to content

Commit e027e31

Browse files
committed
Revert "Better dalai prompts maybe"
This reverts commit 103d389.
1 parent 7568bb1 commit e027e31

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

dalai/prompts.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

dalai/worker.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { promisify } from 'node:util'
1010
import pdfToText from 'pdf-parse-fork'
1111
import { pdfToPng, type PngPageOutput } from 'pdf-to-png-converter'
1212
import logger from './logger.ts'
13-
import { MARKDOWN_PROMPT, TRANSCRIPTION_PROMPT_2 } from './prompts.ts'
1413

1514
dotenv.config()
1615

@@ -304,7 +303,13 @@ const worker = new Worker(
304303
headers: { 'Content-Type': 'application/json' },
305304
body: JSON.stringify({
306305
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.`,
308313
prompt: `Parsed PDF text:\n${pdfText}\n\nImage transcription:`,
309314
stream: false,
310315
images: [image.toString('base64')],
@@ -335,7 +340,13 @@ const worker = new Worker(
335340
},
336341
body: JSON.stringify({
337342
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.`,
339350
prompt: `Transcription:\n${transcription}\n\nPDF:\n${pdfText}\n\nCombined Markdown:`,
340351
stream: false,
341352
}),

0 commit comments

Comments
 (0)