ontocast.onto.model¶
BasePydanticModel
¶
Bases: BaseModel
Base class for Pydantic models with serialization capabilities.
Source code in ontocast/onto/model.py
__init__(**kwargs)
¶
load(file_path)
classmethod
¶
Load state from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path to the JSON file. |
required |
Returns:
| Type | Description |
|---|---|
|
The loaded model instance. |
Source code in ontocast/onto/model.py
serialize(file_path)
¶
Serialize the state to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path to save the JSON file. |
required |
Source code in ontocast/onto/model.py
OntologyCritiqueReport
¶
Bases: BaseModel
Report from ontology update critique process.
Source code in ontocast/onto/model.py
OntologySelectorReport
¶
Bases: BasePydanticModel
Base class for ontology selection report.
Note: Use create_ontology_selector_report_model() to create a model with the correct answer_index constraint.
Source code in ontocast/onto/model.py
SemanticTriplesFactsReport
¶
Bases: BaseModel
Report containing semantic triples and evaluation scores.
Attributes:
| Name | Type | Description |
|---|---|---|
semantic_graph |
RDFGraph
|
Semantic triples (facts) representing the document in turtle (ttl) format. |
ontology_relevance_score |
float | None
|
Score 0-100 for how relevant the ontology is to the document. 0 is the worst, 100 is the best. |
triples_generation_score |
float | None
|
Score 0-100 for how well the facts extraction / triples generation was performed. 0 is the worst, 100 is the best. |
Source code in ontocast/onto/model.py
Suggestions
¶
Bases: BaseModel
Report from knowledge graph critique process.
Attributes:
| Name | Type | Description |
|---|---|---|
systemic_critique_summary |
str
|
A compilation of general improvement suggestions. |
actionable_fixes |
list[TripleFix]
|
An itemized list of concrete suggestions for improvement. |
Source code in ontocast/onto/model.py
from_critique_report(critique)
classmethod
¶
Create Suggestions from any critique report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
critique
|
OntologyCritiqueReport | FactsCritiqueReport
|
Either an OntologyCritiqueReport or FactsCritiqueReport to convert. |
required |
Returns:
| Type | Description |
|---|---|
Suggestions
|
Suggestions object with actionable fixes and systemic critique summary. |
Source code in ontocast/onto/model.py
to_markdown()
¶
Convert actionable fixes and systemic critique summary to a unified markdown block.
Returns:
| Type | Description |
|---|---|
str
|
Markdown formatted string with both actionable fixes and systemic critique summary. |
Source code in ontocast/onto/model.py
TripleFix
¶
Bases: BaseModel
Source code in ontocast/onto/model.py
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 | |
normalize_severity(v)
classmethod
¶
Normalize severity values to accepted literals.
Maps 'major' to 'important' for backward compatibility with prompts that use 'major' terminology. This allows the LLM to use either term.
Source code in ontocast/onto/model.py
to_markdown()
¶
Convert this TripleFix to markdown format.
Returns:
| Type | Description |
|---|---|
str
|
Markdown formatted string representing this fix. |
Source code in ontocast/onto/model.py
create_ontology_selector_report_model(num_ontologies)
¶
Create a dynamic OntologySelectorReport model with answer_index constraint.
The answer_index field is constrained to be between 1 and num_ontologies + 1, where: - 1 to num_ontologies: corresponds to the ontology at that index (1-based) - num_ontologies + 1: represents "None" (no suitable ontology)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_ontologies
|
int
|
The number of ontologies in the selection list. |
required |
Returns:
| Type | Description |
|---|---|
type[BasePydanticModel]
|
A dynamically created Pydantic model class with the appropriate constraint. |