ontocast.agent.consolidate_ontology¶
Decide every term a document minted, before it is written.
After the ontology fan-out, the merged update holds every term the units
minted, the plan's and the candidates (terms a unit minted outside the plan).
One structured LLM call per batch of terms returns an action per term
(:class:~ontocast.onto.model.OntologyTermAction); the actions are compiled
into the update without a model
(:mod:ontocast.tool.ontology_validation.consolidate).
Each term is shown with what the decision needs and a unit cannot see: the whole document's other terms, its catalog neighbours, the findings on it, and short excerpts from every unit that minted it.
Attributes¶
EVIDENCE_PER_TERM = 2
module-attribute
¶
EVIDENCE_WINDOW = 200
module-attribute
¶
TARGETS_PER_REASON = 3
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
TermContext
¶
What the consolidation prompt shows about one minted term.
Source code in ontocast/agent/consolidate_ontology.py
Attributes¶
definition = ''
instance-attribute
¶
excerpts = []
instance-attribute
¶
findings = []
instance-attribute
¶
iri = iri
instance-attribute
¶
label = ''
instance-attribute
¶
nearest = []
instance-attribute
¶
parents = []
instance-attribute
¶
reasons = []
instance-attribute
¶
role = role
instance-attribute
¶
status = 'planned'
instance-attribute
¶
Methods:¶
__init__(iri, role)
¶
Source code in ontocast/agent/consolidate_ontology.py
Functions:¶
build_term_contexts(state, *, carriers, minted, flagged, candidates, findings, term_units, plan)
¶
One context per flagged term, ordered by IRI.
Source code in ontocast/agent/consolidate_ontology.py
consolidate_terms(state, tools, contexts, *, prefixes, batch_size, other_terms='')
async
¶
Ask for an action per term, batch_size terms per call.
Returns:
| Type | Description |
|---|---|
list[OntologyTermAction]
|
Every action returned, and the number of calls that failed; a failed |
int
|
batch leaves its terms to their defaults. |
Source code in ontocast/agent/consolidate_ontology.py
flag_targets(reasons)
¶
The terms a term's flags point at, each with what relates them.
Source code in ontocast/agent/consolidate_ontology.py
format_other_terms(minted, flagged, carriers, prefixes)
¶
One line per minted term that needs no decision: possible merge targets.
Source code in ontocast/agent/consolidate_ontology.py
format_term_block(context, prefixes)
¶
The prompt lines for one term.