WeKnora/config/prompt_templates
Claude 15550d14d4 fix(ingest): stop hallucinating summaries from filenames on empty PDFs
Scanned PDFs without a successful OCR pass (e.g. when no VLM is configured
on the KB, or when the VLM returned a "no text content" reply that the
sanitizer discarded) reach the summary and wiki-ingest pipelines with
nothing but markdown image references for content. The downstream LLM
prompts used to receive the filename, file type, and title alongside that
empty content, and the generate_summary template explicitly forbade the
model from refusing — so the model would invent a topic from the filename
alone, producing e.g. a "Canon scanner manual" summary for an MX5280.pdf
that is actually a scanned legal letter.

Two changes shut this down:

1. Drop filename / title / file-type from every LLM prompt input. The
   wiki summary, knowledge extract, candidate slug, and chunk citation
   prompts now see only the document content. The knowledge summary
   path no longer prepends the "Document Type: X / File Name: Y" intro.

2. Add a content-sufficiency guard in front of the LLM call. A new
   helper strips markdown image references and HTML image tags and
   refuses to invoke the model when fewer than 50 real-text runes
   remain. getSummary returns a sentinel error in that case and the
   caller marks the knowledge as SummaryStatusFailed instead of
   surfacing the first chunk's bare image reference. Wiki ingest skips
   LLM extraction with a clear log message.

The generate_summary.yaml prompt is also updated: the "NEVER output
refusal phrases" clause is removed and replaced with an explicit
empty-content rule that returns a deterministic placeholder line.

Real OCR (Tesseract / PaddleOCR) and filename-pattern sanitisation are
intentionally left for separate PRs.
2026-05-06 11:23:32 +08:00
..
agent_system_prompt.yaml fix(wiki): address PR review feedbacks regarding citation format, rule conflicts, and search loops 2026-05-04 23:52:38 +08:00
context_template.yaml feat(prompt): enhance context and intent classification in templates 2026-03-26 18:57:12 +08:00
fallback.yaml fix: inject KB document listing on fallback for broad queries (#959) 2026-04-28 23:31:04 +08:00
generate_questions.yaml refactor(prompt_templates): improve question generation guidelines and context handling 2026-04-01 21:59:22 +08:00
generate_session_title.yaml fix: update session title word count requirement 2026-03-17 22:23:24 +08:00
generate_summary.yaml fix(ingest): stop hallucinating summaries from filenames on empty PDFs 2026-05-06 11:23:32 +08:00
graph_extraction.yaml feat: enhance localization and configuration support 2026-03-17 22:23:24 +08:00
intent_prompts.yaml fix: Update intent prompts for knowledge assistant response clarity 2026-04-22 21:17:20 +08:00
keywords_extraction.yaml feat: enhance localization and configuration support 2026-03-17 22:23:24 +08:00
rewrite.yaml fix: inject KB document listing on fallback for broad queries (#959) 2026-04-28 23:31:04 +08:00
system_prompt.yaml refactor(prompt): streamline context handling in templates 2026-03-25 22:08:29 +08:00