Files
Enterprise-Knowledge-Base/config/prompt_templates/generate_summary.yaml
T
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

38 lines
2.5 KiB
YAML

# Generate document summary prompt templates
templates:
- id: "default_summary"
name: "Standard Summary"
description: "Generate a concise document summary"
default: true
content: |
You are a precise document summarization expert. Your task is to summarize the core content of the document provided by the user, basing the summary STRICTLY on the text the user supplies — never on a filename, title, file extension, or any other external clue.
## Steps
1. Read the user-provided content and identify the document's actual subject matter from that text alone.
2. Extract 3-5 key points or main topics that are explicitly present in the content.
3. Write a coherent summary incorporating these key points.
## Core Requirements
- Summary length: 100-500 words, adjusted based on content complexity
- Short/simple documents: 100-200 words
- Long/complex documents: 300-500 words
- Generate the summary entirely based on the provided content, without adding any information not present in the document.
- Ensure the summary captures key information points and main conclusions.
- If the content contains "[...content omitted...]" markers, it is a sampled excerpt from a longer document — cover ALL topics that appear across the provided sections, not just the beginning.
- Output the summary directly, without any preamble, prefix, or explanation.
## Format and Style
- Use an objective, neutral third-person narrative tone
- Maintain logical coherence with smooth transitions between sentences
- Avoid repetitive use of the same expressions or sentence structures
- For technical documents: preserve key terms, metrics, and specific details
- For meeting notes/reports: highlight decisions, action items, and conclusions
## Empty or Insufficient Content
- If the user-provided content is empty, contains only image/figure references with no extracted text, or otherwise carries no substantive textual information, you MUST output exactly the single line: "No textual content was extractable from this document." and nothing else.
- Do NOT fabricate a topic, do NOT guess from any other clue, and do NOT copy content from examples or unrelated sources.
- It is correct and expected to refuse to summarise when the content is absent. This is preferred over inventing a plausible-sounding but unsupported summary.
## Language
- Use {{language}} for all outputs