ontocast.agent¶
Agent module for OntoCast.
This module provides a collection of agents that handle various aspects of ontology processing, including document conversion, text chunking, fact aggregation, and ontology management. Each agent is designed to perform a specific task in the ontology processing pipeline.
The names re-exported here are the pipeline steps the graph and the unit loop
drive. Helper entry points that are only meaningful inside one agent -- the
*_fresh render paths, the evidence planner/fetcher -- are reached through
their own module rather than from here.
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
normalize_ontology_units(units, tools, base_ontology=None, require_base=False, delete_graph=None)
¶
Merge ontology unit deltas as TripleOps, then apply to base ontology.
Units contain ontology insert delta graphs; delete_graph carries the
reconciled delete delta (triples to remove from the base). Deletes execute
first, then inserts, as one ordered GraphUpdate — so the applied update
list feeds version-bump analysis with true operation types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
list[ContentUnit]
|
ContentUnits with type=ONTOLOGIES and delta graph from each unit. |
required |
tools
|
ToolBox
|
ToolBox instance. |
required |
base_ontology
|
Ontology | None
|
Optional ontology to use as base; merged delta is applied to it. |
None
|
require_base
|
bool
|
Whether map/reduce caller expects a base ontology. |
False
|
delete_graph
|
RDFGraph | None
|
Optional triples to delete from the base before inserts. Requires a catalog base; ignored (with a warning) otherwise. |
None
|
Returns:
| Type | Description |
|---|---|
Ontology
|
Tuple of ( ontology with cleaned graph, list of applied GraphUpdates for versioning, provenance artifact graph stripped from ontology output, |
list[GraphUpdate]
|
). |
Source code in ontocast/agent/normalize_ontology.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
select_catalog_ontology_for_excerpt(ontology_manager, llm_tool, excerpt, ontology_selection_user_instruction='')
async
¶
Use the LLM to select one catalog ontology, or :data:NULL_ONTOLOGY if none fit.
The excerpt is usually a content unit's text. Empty excerpt or an empty
catalog yields NULL_ONTOLOGY without calling the model.