fix(pipeline): retry on 0-entity response, save raw debug, improve template

- SourcePipeline: retry split_entities stage once when 0 entity delimiters
  are found (free-tier models intermittently return short non-formatted
  responses); save raw LLM response to <stage>-raw.md alongside prompts
- Return None (pause pipeline) rather than writing empty view file when
  no entities found after max retries
- _http.py: wrap json.JSONDecodeError in LLMAPIError with body preview
- extract-entities.md: add explicit H2-heading format example to Output
  Format section to prevent models from using inline "Section:" format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 14:26:28 +01:00
parent 72d9904485
commit 5ede1de4b8
3 changed files with 70 additions and 6 deletions

View File

@@ -52,3 +52,35 @@ already contains it. Only extract entities that are genuinely new.
Output each entity as a separate markdown document, delimited by
`--- ENTITY: <entity-name> ---` markers.
Use **H2 headings** (`##`) for each section inside the entity document.
Do NOT use inline `Section:` format or H3 headings.
Example of a correctly formatted entity:
```
--- ENTITY: division of labour ---
# Division of Labour
## Definition
The separation of a work process into distinct tasks performed by specialised
workers, increasing productivity through greater dexterity, saved time, and
the invention of labour-saving machinery.
## Source Chapter
Book I, Chapter 1
## Context
The opening chapter's central argument, illustrated by Smith's pin factory
example showing how dividing 18 operations dramatically increases output.
## Economic Domain
Production
---
```