ontocast.agent.summarize_chunks¶
LLM summarization of content units before extraction.
ensure_unit_summary(state, unit_index, tools, budget_tracker=None)
async
¶
Summarise one content unit in place, if it is due one and lacks one.
Called from inside the extraction fan-outs rather than from a preceding node. A unit's summary depends only on that unit, so a document-level summarize stage made every unit wait for the slowest summary before any extraction could start, for no dependency.
Idempotent, so the facts fan-out is a no-op when the ontology fan-out
already summarised the unit. Failures are logged and leave summary as
None: extraction then falls back to the unit's full text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Any
|
Document state; |
required |
unit_index
|
int
|
Index of the unit to summarise. |
required |
tools
|
ToolBox
|
Tool container providing the LLM. |
required |
budget_tracker
|
Any
|
Charged for the call. |
None
|
Source code in ontocast/agent/summarize_chunks.py
should_summarize_unit(unit, summarize_sections)
¶
Whether a unit should be passed through the summarization node.
Source code in ontocast/agent/summarize_chunks.py
summarize_chunk(unit, tools, *, max_sentences, budget_tracker=None)
async
¶
Compress a content unit for downstream extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
ContentUnit
|
The content unit to summarize. |
required |
tools
|
ToolBox
|
Tool container. |
required |
max_sentences
|
int
|
Upper bound on summary length. |
required |
budget_tracker
|
Any
|
Charged for this call. Summarization used to call the shared LLM tool directly, so its tokens landed on whichever tracker another unit happened to have bound. |
None
|